add runwon and runlost functions, default win cards, call button that calls a loaded contact, added rotatecells, shiftcells, and swapcells functions to actor, reworked address to be 0-8 instead of 1-9, added underscore naming convention to function parameters, business cards to be slightly transparent when not met, added actions to contacts and made a couple examples

This commit is contained in:
2026-01-25 15:01:48 -05:00
parent c1ef887be3
commit 2fdf0d6442
27 changed files with 473 additions and 104 deletions

View File

@@ -2,7 +2,7 @@ using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
public partial class Actor : Sprite2D
{
@@ -17,23 +17,80 @@ public partial class Actor : Sprite2D
_markFocused = GetNode<Sprite2D>("MarkFocused");
}
// public List<List<int>> CheckGoals()
// {
// List<Cell> ownedCells = _board._cells.Where<Cell>(c=>c._marker == this).ToList();
// List<int> ownedCellAddresses = ownedCells.Select(c=>c._address).ToList();
// string ownedCellAddressesString = string.Join("",ownedCellAddresses);
// CALLABLE ACTIONS
// List<List<int>> goalsMet = new();
// for (int i = 0; i < _goal._eligibleGoals.Count; i++)
// {
// Goal.GoalName goalName = _goal._eligibleGoals[i];
// List<int> goal = _goal._conditions[goalName];
// if (goal.All(n=>ownedCellAddresses.Contains(n)))
// {
// goalsMet.Add(goal);
// }
// }
// return goalsMet;
// }
public bool RotateCells(int ROTATIONS = 1, bool JUST_MARKS = false)
{
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
List<int> addresses = new(_board._cells.Select(c=>c._address).ToList());
Dictionary<int, int> cwShifts = new()
{
{0,1}, {1,2}, {2,5}, {3,0}, {4,4}, {5,8}, {6,3}, {7,6}, {8,7}
};
Dictionary<int, int> ccwShifts = new()
{
{0,3}, {1,0}, {2,1}, {3,6}, {4,4}, {5,2}, {6,7}, {7,8}, {8,5}
};
Dictionary<int, int> shifts = ROTATIONS > 0 ? cwShifts : ccwShifts;
for (int i = 0; i < Math.Abs(ROTATIONS); i++)
{
for (int j = 0; j < addresses.Count; j++)
{
int address = addresses[j];
int newAddress = shifts[address];
addresses[j] = newAddress;
}
}
for (int i = 0; i < _board._cells.Count; i++)
{
int newCellAddress = addresses[i];
_board._cells[i].Position = positions[newCellAddress];
}
_board.RenumberCells();
return true;
}
public bool ShiftCells(int SHIFT_SPOTS = 1)
{
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
int start = SHIFT_SPOTS > 0 ? 0 : 9;
for (int i = 0; i < _board._cells.Count; i++)
{
int newSpot = (start + i + SHIFT_SPOTS) % 9;
_board._cells[i].Position = positions[newSpot];
}
_board.RenumberCells();
return true;
}
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)
{
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);
}
if (CELL_B_ADDRESS == -1)
{
CELL_B_ADDRESS = random.Next(8);
while (CELL_B_ADDRESS == CELL_A_ADDRESS)
{
CELL_B_ADDRESS = random.Next(8);
}
}
_board._cells[CELL_A_ADDRESS].Position = positions[CELL_B_ADDRESS];
_board._cells[CELL_B_ADDRESS].Position = positions[CELL_A_ADDRESS];
_board.RenumberCells();
return true;
}
}