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) public bool ShiftMarks(int COLUMNS = 0, int ROWS = 0)
{ {
List<Actor> markers = new(_board._cells.Select(c=>c._marker).ToList()); 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; for (int j = 0; j < cellsToTable.GetLength(1); j++) //COLUMNS / X
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; int toY = ROWS >= 0 ? cellsToTable.GetLength(0) - 1 - i : i;
GD.Print(i, cellCol, cellRow, newCol, newRow, newAddress); int fromY = toY - ROWS;
if (_board._cells[i]._marker != null) 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(); _board.RenumberCells();

View File

@@ -45,7 +45,7 @@ public partial class Cell : TextureButton
public void Clear() public void Clear()
{ {
// _marker = null; _marker = null;
TextureNormal = TexturePressed = TextureHover = TextureDisabled = TextureFocused = _defaultMark.Texture; TextureNormal = TexturePressed = TextureHover = TextureDisabled = TextureFocused = _defaultMark.Texture;
} }
} }