This commit is contained in:
2026-01-25 21:04:47 -05:00
parent 2fdf0d6442
commit 2c74f67abe
16 changed files with 90 additions and 43 deletions

View File

@@ -1,6 +1,7 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
@@ -53,7 +54,32 @@ public partial class Actor : Sprite2D
return true;
}
public bool ShiftCells(int SHIFT_SPOTS = 1)
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 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();
return true;
}
public bool SlideCells(int SHIFT_SPOTS = 1)
{
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
int start = SHIFT_SPOTS > 0 ? 0 : 9;
@@ -68,22 +94,25 @@ public partial class Actor : Sprite2D
public bool SwapCells(int CELL_A_ADDRESS = -1, int CELL_B_ADDRESS = -1)
{
if (CELL_A_ADDRESS < -1 || CELL_A_ADDRESS > 8 || CELL_B_ADDRESS < -1 || CELL_B_ADDRESS > 8)
if (CELL_A_ADDRESS < -1 || CELL_A_ADDRESS > 8 || CELL_B_ADDRESS < -1 || CELL_B_ADDRESS > 8 || CELL_A_ADDRESS == CELL_B_ADDRESS)
{
return false;
}
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
Random random = new ();
if (CELL_A_ADDRESS == -1)
{
CELL_A_ADDRESS = random.Next(8);
CELL_A_ADDRESS = Globals._rng.Next(0,8);
while (CELL_A_ADDRESS == CELL_B_ADDRESS)
{
CELL_A_ADDRESS = Globals._rng.Next(0,8);
}
}
if (CELL_B_ADDRESS == -1)
{
CELL_B_ADDRESS = random.Next(8);
CELL_B_ADDRESS = Globals._rng.Next(0,8);
while (CELL_B_ADDRESS == CELL_A_ADDRESS)
{
CELL_B_ADDRESS = random.Next(8);
CELL_B_ADDRESS = Globals._rng.Next(0,8);
}
}
_board._cells[CELL_A_ADDRESS].Position = positions[CELL_B_ADDRESS];
@@ -92,5 +121,14 @@ public partial class Actor : Sprite2D
return true;
}
//MoveMark
//ShiftColumns
//ShiftRows
}