still working on shift marks function

This commit is contained in:
2026-01-26 01:41:03 -05:00
parent 2c74f67abe
commit 92759c4a12
2 changed files with 37 additions and 12 deletions

View File

@@ -57,22 +57,47 @@ public partial class Actor : Sprite2D
public bool ShiftMarks(int COLUMNS = 0, int ROWS = 0)
{
List<Actor> markers = new(_board._cells.Select(c=>c._marker).ToList());
for (int i = 0; i < _board._cells.Count; i++)
int[,] cellsToTable = {{0,1,2},{3,4,5},{6,7,8}};
for (int i = 0; i < cellsToTable.GetLength(0); i++) //ROWS / Y
{
int cellCol = i % 3;
int cellRow = (int)Math.Floor(i / 3f);
int newCol = cellCol + COLUMNS;
int newRow = cellRow + ROWS;
if (newCol >= 0 && newRow >= 0 && newCol <= 2 && newRow <= 2)
for (int j = 0; j < cellsToTable.GetLength(1); j++) //COLUMNS / X
{
int newAddress = newRow*3 + newCol;
GD.Print(i, cellCol, cellRow, newCol, newRow, newAddress);
if (_board._cells[i]._marker != null)
int toY = ROWS >= 0 ? cellsToTable.GetLength(0) - 1 - i : i;
int fromY = toY - ROWS;
int toX = COLUMNS >= 0 ? cellsToTable.GetLength(1) - 1 - j : j;
int fromX = toX - COLUMNS;
if (fromY >= 0 && fromY <= cellsToTable.GetLength(0) && fromX >= 0 && fromX <= cellsToTable.GetLength(1))
{
_board._cells[newAddress].Mark(_board._cells[i]._marker);
int toI = cellsToTable[toY, toX];
int fromI = cellsToTable[fromY, fromX];
if (_board._cells[fromI]._marker != null)
{
_board._cells[toI].Mark(_board._cells[fromI]._marker);
_board._cells[fromI].Clear();
}
else
{
_board._cells[toI].Clear();
}
}
// _board._cells[i].Clear();
}
// int actualIndex =
// int cellCol = i % 3;
// int cellRow = (int)Math.Floor(i / 3f);
// int newCol = cellCol + COLUMNS;
// int newRow = cellRow + ROWS;
// if (newCol >= 0 && newRow >= 0 && newCol <= 2 && newRow <= 2)
// {
// int newAddress = newRow*3 + newCol;
// GD.Print(i, cellCol, cellRow, newCol, newRow, newAddress);
// if (_board._cells[i]._marker != null)
// {
// _board._cells[newAddress].Mark(_board._cells[i]._marker);
// }
// // _board._cells[i].Clear();
// }
}
_board.RenumberCells();