private void CheckKingKilling(TurnNode currentNode, Lib.PlayersSide whoseTurn, IChecker checker, int level) { int i = checker.CurrentCoord.Row; int j = checker.CurrentCoord.Column; while ((i <= 8) && (j <= 8)) { if (checker.CheckPossibilityToKill(new Coord(i, j), gameField)) { currentNode.AddChild(KillingRecurcion(currentNode, whoseTurn, checker, new Coord(i, j), level)); } i++; j++; } i = checker.CurrentCoord.Row; j = checker.CurrentCoord.Column; while ((i <= 8) && (j >= 1)) { if (checker.CheckPossibilityToKill(new Coord(i, j), gameField)) { currentNode.AddChild(KillingRecurcion(currentNode, whoseTurn, checker, new Coord(i, j), level)); } i++; j--; } i = checker.CurrentCoord.Row; j = checker.CurrentCoord.Column; while ((i >= 1) && (j <= 8)) { if (checker.CheckPossibilityToKill(new Coord(i, j), gameField)) { currentNode.AddChild(KillingRecurcion(currentNode, whoseTurn, checker, new Coord(i, j), level)); } i--; j++; } i = checker.CurrentCoord.Row; j = checker.CurrentCoord.Column; while ((i >= 1) && (j >= 1)) { if (checker.CheckPossibilityToKill(new Coord(i, j), gameField)) { currentNode.AddChild(KillingRecurcion(currentNode, whoseTurn, checker, new Coord(i, j), level)); } i--; j--; } }
public bool CheckCheckersMovement(Coord newCoord, IChecker checker) { bool result = false; ICommand commandToPlayer = null; if (checker.CheckPossibilityToMove(newCoord, this) || checker.CheckPossibilityToKill(newCoord, this)) { result = true; SendCommandToPlayerEvent(checker, checker.CurrentCoord, newCoord); } return(result); }
public void ExecuteStep(IChecker killer, IChecker victim, Coord coord) { if (killer.CheckPossibilityToKill(coord, GameField)) { LogStepWithKill(killer.CurrentCoord, coord, killer, victim); MoveCheckerDirectly(killer, coord); Kill(victim); CheckGameOver(); CheckGettingKing(killer); SwitchTurn(killer); NextTurn(); } }
} // функция валидации хода private IChecker[][] ExecuteOperationToKill(IChecker[][] newBoardState, IChecker killer, IChecker victim, Coord coord) { if (killer.CheckPossibilityToKill(coord, gameField)) { newBoardState[killer.CurrentCoord.Row][killer.CurrentCoord.Column] = null; killer.CurrentCoord = coord; newBoardState[killer.CurrentCoord.Row][killer.CurrentCoord.Column] = killer; newBoardState[victim.CurrentCoord.Row][victim.CurrentCoord.Column] = null; CheckGettingKing(killer); } return(newBoardState); } //виртуальное исполнение команды на убийство
private void CheckKilling(TurnNode currentNode, Lib.PlayersSide whoseTurn, IChecker checker, int level) { List <TurnNode> turnNodes = new List <TurnNode>(); if (checker.CheckPossibilityToKill(new Coord(checker.CurrentCoord.Row + 2, checker.CurrentCoord.Column + 2), gameField)) { turnNodes.Add(KillingRecurcion(currentNode, whoseTurn, checker, new Coord(checker.CurrentCoord.Row + 2, checker.CurrentCoord.Column + 2), level)); } if (checker.CheckPossibilityToKill(new Coord(checker.CurrentCoord.Row - 2, checker.CurrentCoord.Column + 2), gameField)) { turnNodes.Add(KillingRecurcion(currentNode, whoseTurn, checker, new Coord(checker.CurrentCoord.Row - 2, checker.CurrentCoord.Column + 2), level)); } if (checker.CheckPossibilityToKill(new Coord(checker.CurrentCoord.Row + 2, checker.CurrentCoord.Column - 2), gameField)) { turnNodes.Add(KillingRecurcion(currentNode, whoseTurn, checker, new Coord(checker.CurrentCoord.Row + 2, checker.CurrentCoord.Column - 2), level)); } if (checker.CheckPossibilityToKill(new Coord(checker.CurrentCoord.Row - 2, checker.CurrentCoord.Column - 2), gameField)) { turnNodes.Add(KillingRecurcion(currentNode, whoseTurn, checker, new Coord(checker.CurrentCoord.Row - 2, checker.CurrentCoord.Column - 2), level)); } currentNode.AddChild(turnNodes); }