public void distributePot(WinStatus winner) { stage = GameStage.DISTRIBUTE_POT; Winner = winner; if (winner == WinStatus.PLAYER_HUMAN) { HumanPlayer.Money += Pot; } else if (winner == WinStatus.PLAYER_ROBO) { RoboPlayer.Money += Pot; } else { RoboPlayer.Money += 20; HumanPlayer.Money += 20; } if (GameListener != null) { GameListener.PostDsitributePot(); } }
public void OnEnable() { currentWinStatus = WinStatus.None; cantCallAnymore = false; player1ProgressBar.currentPercent = 50; player2ProgressBar.currentPercent = 50; }
// public void FinishAction() { // finishedActing = true; // } public void EndBattle(WinStatus winStatus) { turnQueue.Clear(); WinStatus = winStatus; BattleState = BattleState.End; BattlePhase = BattlePhase.Nil; TurnState = TurnState.Nil; // finishedTurn = true; // battleOver = true; }
public static void WinAndLoseResponse(Game game) { foreach (Player player in game.players) { WinStatus winStatus = getGameResult(game, player); SocketHelper.WriteToPlayer(player, Encapsulation.Serialize(Encapsulation.FromValue(new GameEnd { PlayerWinStatus = winStatus }, MessageType.GameEnd))); } }
public static void NextRoundResponse(Game game) { Guid roundGuid = Guid.NewGuid(); foreach (Player player in game.players) { WinStatus winStatus = getGameResult(game, player); SocketHelper.WriteToPlayer(player, Encapsulation.Serialize(Encapsulation.FromValue(new RoundInfo { UniqueId = roundGuid, PlayerWinStatus = winStatus }, MessageType.NextRound))); } }
/// <summary> /// Class constructor /// </summary> public TicTacToe(List <string> inputStr, string azPlayerSymbol, string huPlayerSymbol) { // Convert board as list to 2d array board = new string[3, 3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { board[i, j] = inputStr[i * 3 + j]; } } winStatus = GetWinStatus(board); azurePlayerSymbol = azPlayerSymbol; humanPlayerSymbol = huPlayerSymbol; }
// private Dictionary <string, UnityEvent> eventDictionary; // private readonly UnityEvent endBattle = new UnityEvent(); // private readonly UnityEvent defeatedEnemyEvent = new UnityEvent(); // private readonly UnityEvent buffEvent = new UnityEvent(); // private bool axisDown; // private Direction currentDirection; // private Button currentButton; // private GameObject testMenu; // private ActionMenu actionMenu; // Get options from units Character component //private int currentOption = 0; private void OnEnable() { if (bm == null) { bm = this; } else if (bm != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); BattleState = BattleState.Nil; TurnState = TurnState.Nil; BattlePhase = BattlePhase.Nil; WinStatus = WinStatus.Nil; battleCanvas = GameObject.FindGameObjectWithTag("BattleCanvas"); }
[ProducesResponseType(typeof(int), StatusCodes.Status400BadRequest)] // Tells swagger that the response format will be an int for a BadRequest (400) public ActionResult <OutputPayload> ProcessComplexInput([FromBody] InputPayload inputPayload) { // Ensure valid player markers, valid board if (!(inputPayload.ValidPlayerMarkers()) || (!(TicTacToe.BoardIsValid(inputPayload.gameBoard)))) { return(BadRequest(400)); } // Compute response TicTacToe ttt = new TicTacToe(inputPayload.gameBoard, inputPayload.azurePlayerSymbol, inputPayload.humanPlayerSymbol); WinStatus ws = ttt.winStatus; // If game isn't over, get the AI's next move int?nextMove; if (ws.winner.Equals(TicTacToe.GAME_NOT_DONE_STR)) { int choice = ttt.MinimaxWithPruningMove(); ttt[TicTacToe.IndexToTuple(choice)] = inputPayload.azurePlayerSymbol; nextMove = choice; // Recalculate win status ws = TicTacToe.GetWinStatus(ttt.board); } else { nextMove = null; } // Assemble response payload OutputPayload complexOutput = new OutputPayload() { move = nextMove, azurePlayerSymbol = inputPayload.azurePlayerSymbol, humanPlayerSymbol = inputPayload.humanPlayerSymbol, winner = ws.winner, winPositions = (ws.winPositions == null) ? null : ws.winPositions.ConvertAll(i => i.ToString()), gameBoard = TicTacToe.BoardToList(ttt.board), }; return(complexOutput); }
private static WinStatus GetRowWinStatus( TicTacToeCellValue cellValue, TicTacToeBoard board) { for (int y = 0; y < 3; y++) { var horizontalCells = board.GetHorizontalCells(y); if (horizontalCells[0].CellValue == cellValue && horizontalCells[1].CellValue == cellValue && horizontalCells[2].CellValue == cellValue) { var message = $"Row win for {cellValue} on row {y + 1}"; return(WinStatus.CreateAsWin(message)); } } return(WinStatus.CreateAsNoWin()); }
private static WinStatus GetColumnWinStatus( TicTacToeCellValue cellValue, TicTacToeBoard board) { for (int x = 0; x < 3; x++) { var verticalCells = board.GetVerticalCells(x); if (verticalCells[0].CellValue == cellValue && verticalCells[1].CellValue == cellValue && verticalCells[2].CellValue == cellValue) { var message = $"Column win for {cellValue} on column {x + 1}"; return(WinStatus.CreateAsWin(message)); } } return(WinStatus.CreateAsNoWin()); }
public static WinStatus GetWinStatus( TicTacToeBoard board) { var columnWinStatusX = GetColumnWinStatus( TicTacToeCellValue.X, board); if (columnWinStatusX.IsWon) { return(columnWinStatusX); } var columnWinStatusO = GetColumnWinStatus( TicTacToeCellValue.O, board); if (columnWinStatusO.IsWon) { return(columnWinStatusO); } var rowWinStatusX = GetRowWinStatus( TicTacToeCellValue.X, board); if (rowWinStatusX.IsWon) { return(rowWinStatusX); } var rowWinStatusO = GetRowWinStatus( TicTacToeCellValue.O, board); if (rowWinStatusO.IsWon) { return(rowWinStatusO); } return(WinStatus.CreateAsNoWin()); }
public bool UpdateWinCondition() { switch (player1.pressCount.CompareTo(player2.pressCount)) { case -1: currentWinStatus = WinStatus.Player2; break; case 0: currentWinStatus = WinStatus.Tie; return(false); case 1: currentWinStatus = WinStatus.Player1; break; default: currentWinStatus = WinStatus.None; return(false); } switch (tugOfWarWinCondition) { case TugOfWarWinCondition.Percentage: int count = player1.pressCount + player2.pressCount + startingPressCount; switch (currentWinStatus) { case WinStatus.Player1: if (player1.pressCount / (float)count >= percentage) { return(true); } break; case WinStatus.Player2: if (player2.pressCount / (float)count >= percentage) { return(true); } break; } return(false); case TugOfWarWinCondition.PressCount: if (player1.pressCount >= pressCount || player2.pressCount >= pressCount) { return(true); } return(false); default: return(false); } }