public void InitNewGame() { m_FirstPlayer.CoinsCount = 2; m_SecondPlayer.CoinsCount = 2; m_Board = new Board(m_BoardSize); m_Status = statusGame.Going; }
private void ExcuteMoveLAN(Form form) { if (form.InvokeRequired) { // this is worker thread updateExcuteLANDelegate del = new updateExcuteLANDelegate(ExcuteMoveLAN); form.Invoke(del, new object[] { form }); } else { // this is UI thread Point position = Mode1AndMode2.moveLAN; // x la diem dau- y la diem den ChessPieces piece = (ChessPieces)this.boardGui.boardLogic.GetCell(position.X).GetChessPieces().Clone(); // MessageBox.Show(piece.chessPieceType.chessPieceName); Cell cell = this.boardGui.boardLogic.GetCell(position.Y); Move move; if (cell.Occupied()) { move = new AttackMove(piece, position.Y, cell.GetChessPieces()); } else { move = new NormalMove(piece, position.Y); } CellGui cellG = this.boardGui.GetCellGui(position.X); // khong can thiet, cainay chi cap nhat game thoi ma, chi can hien ben nguoi choi duoc roi if (move.IsPromote()) { cellG.SetPromote(move); //set lai icon cho ben nay-ban chat la phia ben nay board logic khong co con nay //nhung chi co ben kia duoc di nen khong sao het- danh lua nguoi choi. } this.boardGui.boardLogic = move.ExcuteMove(this.boardGui.boardLogic); BoardGui.moveHistory.ListMoveHistory.Add(move); BoardGui.moveHistory.listRedo.Clear(); if (move.TheKingDie(this.boardGui.boardLogic)) { Mode1AndMode2.status_game = statusGame.EndGame; } //set lai icon tren ban co cho nguoi xem biet duoc da di.-> thay doi board gui this.boardGui.GetCellGui(position.X).SetImageIcon(); this.boardGui.GetCellGui(position.Y).SetImageIcon(); //reset thanh chua chon nuoc co nao va set nguoi choi tiep theo vi da danh xong nuoc co nay. this.boardGui.CellSelectedFirst = this.boardGui.CellSelectedSecond = null; this.boardGui.boardLogic.SetNextPlayer(); } }
private void playerMakeStep(Player i_Player, bool i_ShowMessageNoMoreOptions, string i_RivalName, int i_ColumnStep, int i_RowStep, bool i_QuittingTheGame) { bool legalSquer; i_Player.GetStep(m_Board.Size, i_ColumnStep, i_RowStep, m_Board.MatrixBoard); if (i_QuittingTheGame) { m_Status = statusGame.Quit; } legalSquer = m_Board.CheckLegalSquer(i_Player); }
private void timerCheckEndGame_Tick(object sender, EventArgs e) { if (Mode1AndMode2.status_game == statusGame.EndGame) { Mode1AndMode2.status_game = statusGame.ContinueGame; if (Mode1AndMode2.modeplay == 3) { SocketData data = new SocketData((int)TypeData.RESET, "", new Point(0, 0)); socket.Send(data); } ResetGame(); } }
public void UpdateGameStatus() { if (m_FirstPlayer.CoinsCount > m_SecondPlayer.CoinsCount) { m_Status = statusGame.Winning; m_Winner = m_FirstPlayer; m_FirstPlayer.WinCounts++; } else if (m_FirstPlayer.CoinsCount < m_SecondPlayer.CoinsCount) { m_Status = statusGame.Winning; m_Winner = m_SecondPlayer; m_SecondPlayer.WinCounts++; } else { m_Status = statusGame.Tie; } }