processes turns in order of neutral->hostiler->friendly
This commit is contained in:
+15
-10
@@ -109,24 +109,25 @@ public partial class PegController : TurnController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandlePegTurn()
|
public void HandlePegTurn(MapCellOccupant.Disposition DISPOSITION)
|
||||||
{
|
{
|
||||||
_tweenStages.Clear();
|
List<Peg> dispositionPegs = [.. _pegs.Where(p => p._disposition == DISPOSITION)];
|
||||||
|
GD.Print(dispositionPegs.Count);
|
||||||
int loop = 0;
|
int loop = 0;
|
||||||
bool anyPegsActed = true;
|
bool anyPegsActed = true;
|
||||||
while (anyPegsActed)
|
while (anyPegsActed)
|
||||||
{
|
{
|
||||||
anyPegsActed = false;
|
anyPegsActed = false;
|
||||||
for (int i = 0; i < _pegs.Count; i++)
|
for (int i = 0; i < dispositionPegs.Count; i++)
|
||||||
{
|
{
|
||||||
Peg peg = _pegs[i];
|
Peg peg = dispositionPegs[i];
|
||||||
PegAction action = peg.SelectAction();
|
PegAction action = peg.SelectAction();
|
||||||
|
|
||||||
if (action != null)
|
if (action != null)
|
||||||
{
|
{
|
||||||
action.DoImmediately(peg);
|
action.DoImmediately(peg);
|
||||||
string key = action._priority + ":" + loop;
|
string key = (int)peg._disposition + ":" + action._priority + ":" + loop;
|
||||||
|
GD.Print(key);
|
||||||
|
|
||||||
if (!_tweenStages.ContainsKey(key))
|
if (!_tweenStages.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -142,7 +143,6 @@ public partial class PegController : TurnController
|
|||||||
}
|
}
|
||||||
loop++;
|
loop++;
|
||||||
}
|
}
|
||||||
ProcessTween();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandlePegClick(Node CLICKED_NODE, int CLICK_TYPE)
|
public void HandlePegClick(Node CLICKED_NODE, int CLICK_TYPE)
|
||||||
@@ -212,8 +212,8 @@ public partial class PegController : TurnController
|
|||||||
|
|
||||||
public void ProcessTween()
|
public void ProcessTween()
|
||||||
{
|
{
|
||||||
_tweenStages = _tweenStages.OrderBy(s => int.Parse(s.Key.Split(":")[0])).ThenBy(s => int.Parse(s.Key.Split(":")[1])).ToDictionary();
|
_tweenStages = _tweenStages.OrderBy(s => int.Parse(s.Key.Split(":")[0])).ThenBy(s => int.Parse(s.Key.Split(":")[1])).ThenBy(s => int.Parse(s.Key.Split(":")[2])).ToDictionary();
|
||||||
|
GD.Print(string.Join(", ",_tweenStages.Keys));
|
||||||
if (_tweenStages.Count <= 0)
|
if (_tweenStages.Count <= 0)
|
||||||
{
|
{
|
||||||
EndTurn();
|
EndTurn();
|
||||||
@@ -246,6 +246,7 @@ public partial class PegController : TurnController
|
|||||||
|
|
||||||
public override void StartTurn()
|
public override void StartTurn()
|
||||||
{
|
{
|
||||||
|
_tweenStages.Clear();
|
||||||
AddHostilePegs(4);
|
AddHostilePegs(4);
|
||||||
|
|
||||||
for (int i = 0; i < _pegs.Count; i++)
|
for (int i = 0; i < _pegs.Count; i++)
|
||||||
@@ -254,7 +255,11 @@ public partial class PegController : TurnController
|
|||||||
}
|
}
|
||||||
HandlePegSort();
|
HandlePegSort();
|
||||||
|
|
||||||
HandlePegTurn();
|
HandlePegTurn(MapCellOccupant.Disposition.NEUTRAL);
|
||||||
|
HandlePegTurn(MapCellOccupant.Disposition.HOSTILE);
|
||||||
|
HandlePegTurn(MapCellOccupant.Disposition.FRIENDLY);
|
||||||
|
|
||||||
|
ProcessTween();
|
||||||
_playArea.HighlightCells();
|
_playArea.HighlightCells();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public partial class BasicMovement : PegAction
|
|||||||
|
|
||||||
map.SetCellPeg(cell, PEG);
|
map.SetCellPeg(cell, PEG);
|
||||||
PEG._path.Add(cell);
|
PEG._path.Add(cell);
|
||||||
|
base.DoImmediately(PEG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool MeetsCriteria(Peg PEG)
|
public override bool MeetsCriteria(Peg PEG)
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ public partial class PegAction : Node2D
|
|||||||
|
|
||||||
public virtual void DoImmediately(Peg PEG)
|
public virtual void DoImmediately(Peg PEG)
|
||||||
{
|
{
|
||||||
|
_usesRemaining--;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool MeetsCriteria(Peg PEG)
|
public virtual bool MeetsCriteria(Peg PEG)
|
||||||
|
|||||||
Reference in New Issue
Block a user