public void MoveChecker(CheckerModel fromPlace, CheckerModel toPlace, bool addToHistory = true) { CheckerModel foundChecker = NextMovePlayer.PlayerPositions.SingleOrDefault(x => x.Column == fromPlace.Column && x.Row == fromPlace.Row); CheckerModel toPosition = EmptyCellsAsPlayer.PlayerPositions.SingleOrDefault(x => x.Column == toPlace.Column && x.Row == toPlace.Row); if (toPlace.Side == fromPlace.Side) { toPosition = NextMovePlayer.PlayerPositions.SingleOrDefault(x => x.Column == toPlace.Column && x.Row == toPlace.Row); } int currentCol = foundChecker.Column; int currentRow = foundChecker.Row; int nextCol = toPosition.Column; int nextRow = toPosition.Row; HistoryMove historyMove = NextMovePlayer.MoveCheckerToNewPlace(currentCol, currentRow, nextCol, nextRow); ReCalculateNeighborsAndPaths(); bool isGameEnded = GetIsGameEnded(); if (!isGameEnded) { ChangeTurn(); } if (addToHistory) { _actionsHistory.Push(historyMove); } }
public IEnumerable <KeyValuePair <CheckerModel, CheckerModel> > GetAllAvailableMoves() { return(NextMovePlayer.GetLegalMovements()); }