void AddMove(Pieces from, GridIndex to) { var seq = from.QueryMovable(MoveType.StandardMove); seq.Build(board, MoveType.StandardMove); if (seq.ContainsMove(to)) { var fromIndex = from.CellIndex; var action = from.MoveTo(to); undoStack.Push(ActionCommand.SimpleMove(action)); redoStack.Clear(); GenericAction(); board.Turnover(); } else if (from is King king) { AddCastling(king, to); } else if (from is Pawn pawn) { AddEnpassant(pawn, to); } }
void AddAttack(Pieces from, Pieces to) { if (from.Team == to.Team) { if (from == to) { selection = null; } else { selection = to.CellIndex; } } else { var seq = from.QueryMovable(MoveType.Attack); seq.Build(board, MoveType.Attack); if (seq.ContainsMove(to.CellIndex)) { var fromIndex = from.CellIndex; var action = from.MoveTo(to.CellIndex); undoStack.Push(ActionCommand.SimpleMove(action)); redoStack.Clear(); GenericAction(); board.Turnover(); } } }
public void BuildAttackHighlight(Pieces piece) { ClearAttackHighlight(); var attackSeq = piece.QueryMovable(MoveType.Attack); attackSeq.Build(board, MoveType.Attack); for (int i = 0; i < attackSeq.SequenceCount; ++i) { var single = attackSeq[i]; for (int j = 0; j < single.Count; ++j) { movableGlows.Add(CreateGlow(GlowType.UnderAttack, single[j])); } } }
public void BuildMoveHighlight(Pieces piece) { ClearMoveHighlight(); var moveSeq = piece.QueryMovable(MoveType.StandardMove); moveSeq.Build(board, MoveType.StandardMove); for (int i = 0; i < moveSeq.SequenceCount; ++i) { var single = moveSeq[i]; for (int j = 0; j < single.Count; ++j) { movableGlows.Add(CreateGlow(GlowType.Movable, single[j])); } } movableGlows.Add(CreateGlow(GlowType.Movable, piece.CellIndex)); }