private BoardInfoForClient CheckForPointThresholdEvents(BoardInfoForClient boardInfoForClient) { if (Team1.Score >= Game.ScoreToWin) { boardInfoForClient = EndGame(boardInfoForClient, teamThatWon: Team1); } else if (Team2.Score >= Game.ScoreToWin) { boardInfoForClient = EndGame(boardInfoForClient, teamThatWon: Team2); } return boardInfoForClient; }
private BoardInfoForClient CapturePiece(BoardInfoForClient boardInfoForClient, Tile targetTile) { var pieceToCapture = targetTile.CurrentPiece; pieceToCapture.IsCaptured = true; CapturedPieces.Add(pieceToCapture); boardInfoForClient.NewCapturedPieces.Add(pieceToCapture); if (pieceToCapture.CaptureDoesGivePoint) { boardInfoForClient = UpdateTeamScore(boardInfoForClient, pieceToCapture); } return boardInfoForClient; }
public BoardInfoForClient StartMovePiece(int targetTileId) { var boardInfoForClient = new BoardInfoForClient(); var targetTile = Game.GetTile(targetTileId); if (CurrentPlayerMoveOptions == null) return null; // Toggle off. if (targetTile.Id == SelectedTile.Id) { _matchState = MatchState.AwaitingCurrentPlayer; boardInfoForClient.UnHighlightAllTiles = true; return boardInfoForClient; } // The player clicked a square other than the current one - see if it's valid. else if (CurrentPlayerMoveOptions.Contains(targetTileId)) { // TODO: encapsulate capture moves and normal moves in a moveoption class. // TODO: instead of checking the landing tile, create a moveoption class so we already know what to expect there. // (or is that not safe?) if (targetTile.CurrentPiece != null && targetTile.CurrentPiece.TeamId != SelectedTile.CurrentPiece.TeamId) { // TODO: piece capturing should possibly be in the MakeMove method instead. boardInfoForClient = CapturePiece(boardInfoForClient, targetTile); } boardInfoForClient.BoardDelta = MovePieceAndGetTileDelta(targetTile); } return boardInfoForClient; }
public BoardInfoForClient GetTeamsInfo() { var delta = new BoardInfoForClient(); delta.Team1 = Team1; delta.Team2 = Team2; delta.UnassignedPlayers = GetUnassignedPlayers(); return delta; }
public BoardInfoForClient GetInitialBoardInfo() { if (Game == null) { return null; } var boardInfoForClient = new BoardInfoForClient(); boardInfoForClient.VariantId = Game.Id; boardInfoForClient.VariantName = Game.Name; boardInfoForClient.BoardWidth = Game.GetWidth(); boardInfoForClient.BoardHeight = Game.GetHeight(); boardInfoForClient.Team1 = Team1; boardInfoForClient.Team2 = Team2; boardInfoForClient.UnassignedPlayers = GetUnassignedPlayers(); boardInfoForClient.BoardDelta = Game.GetFullBoardDelta(this); return boardInfoForClient; }
public BoardInfoForClient EndGame(BoardInfoForClient boardinfoForClient, Team teamThatWon) { if (!IsOver) { _matchState = MatchState.GameOver; WinningTeam = teamThatWon; boardinfoForClient.GameOver = true; boardinfoForClient.WinningTeam = teamThatWon; } return boardinfoForClient; }