public void PutPiece(int square, BgPlayer player) { if (square < 0 || square > m_Board.SquareCount - 1) { return; } if (player == CurrentPlayer && square == 0) { return; } if (player == CurrentOpponentPlayer && square == 25) { return; } if ((m_Board.GetSquare(square, m_SwitchedBoard).Owner == BgPlayer.None || m_Board.GetSquare(square, m_SwitchedBoard).Owner == player) && m_Board.GetOffBoardSquare(player).Count > 0) { if (m_MaxFivePiecesOnAPoint && m_Board.GetSquare(square, m_SwitchedBoard).Count >= 5) { return; } m_Board.GetOffBoardSquare(player).RemovePiece(); m_Board.GetSquare(square, m_SwitchedBoard).PutPiece(player); } }
public bool EndTurn() { FindWinner(); if (m_Winner != BgPlayer.None) { BoardRepresentation finalBoard = new BoardRepresentation(this); if (m_History.Count() > 0 && !m_History.PeekLast().PatternMatches(finalBoard)) { m_History.Add(finalBoard); m_History.Winner = m_Winner; m_History.WinType = VictoryType(); } return(false); } if (!IsMovesUsed()) { if (DoesValidMoveExist()) { return(false); } } m_History.Add(new BoardRepresentation(this)); m_UndoStack.Clear(); m_CurrentPlayer = CurrentOpponentPlayer; SetCorrectlySwitchedBoard(); RollDices(); m_MaxMovesPossible = MaxMovesPossible(0); return(true); }
public void Double(BgPlayer player) { if (m_Owner == BgPlayer.None || m_Owner == player) { m_Value *= 2; } }
private void _NewGame(bool nackgammon, bool maxFivePiecesOnPoint) { m_MaxFivePiecesOnAPoint = maxFivePiecesOnPoint; m_Board.SetStartLayout(nackgammon); m_Cube.Reset(); m_UndoStack.Clear(); m_Winner = BgPlayer.None; m_History.Clear(); do { RollDices(); }while (m_BgDiceCup.GetDice(0).Value == m_BgDiceCup.GetDice(1).Value); if (m_Moves[0] > m_Moves[1]) { m_CurrentPlayer = BgPlayer.Dark; } else { m_CurrentPlayer = BgPlayer.Light; } SetCorrectlySwitchedBoard(); m_MaxMovesPossible = MaxMovesPossible(0); }
public void EditBoard() { m_Cube.Reset(); m_UndoStack.Clear(); m_Winner = BgPlayer.None; m_History.Clear(); m_Board.ClearBoard(); }
public BgTransaction(BgDeveloper developer, BgPlayer player, float value, BgCurrency currency = BgCurrency.AUD) { Developer = developer; Player = player; // TODO: validate value Value = value; Currency = currency; }
public BgSquare(BgPlayer owner, int count) : this() { if (owner != BgPlayer.None && count > 0) { m_Owner = owner; m_Count = count; } }
public BgSquare GetOffBoardSquare( BgPlayer player ) { if ( player == BgPlayer.Light ) return m_LightOffBoardSquare; else if ( player == BgPlayer.Dark ) return m_DarkOffBoardSquare; else return null; }
private void FindWinner() { if (m_Board.GetOffBoardSquare(BgPlayer.Dark).Count == 15) { m_Winner = BgPlayer.Dark; } else if (m_Board.GetOffBoardSquare(BgPlayer.Light).Count == 15) { m_Winner = BgPlayer.Light; } }
public void DoubleCube( BgPlayer player ) { if ( !IsMovesUsed() ) if ( DoesValidMoveExist() ) return; if ( m_Cube.Owner == BgPlayer.None || player == m_Cube.Owner ) { m_Cube.Double( player ); m_Cube.Owner = m_CurrentPlayer; } }
public int GetPips(BgPlayer player) { int result = 0; bool boardSwitch = (player == m_CurrentPlayer)? m_SwitchedBoard : !m_SwitchedBoard; for (int i = 0; i < m_Board.SquareCount; i++) { if (m_Board.GetSquare(i, boardSwitch).Owner == player) { result += i * m_Board.GetSquare(i, boardSwitch).Count; } } return(result); }
public BgSquare GetOffBoardSquare(BgPlayer player) { if (player == BgPlayer.Light) { return(m_LightOffBoardSquare); } else if (player == BgPlayer.Dark) { return(m_DarkOffBoardSquare); } else { return(null); } }
public void DoubleCube(BgPlayer player) { if (!IsMovesUsed()) { if (DoesValidMoveExist()) { return; } } if (m_Cube.Owner == BgPlayer.None || player == m_Cube.Owner) { m_Cube.Double(player); m_Cube.Owner = m_CurrentPlayer; } }
public BgPlayer RemovePiece() { if (m_Count > 0) { BgPlayer result = m_Owner; m_Count--; if (m_Count == 0) { m_Owner = BgPlayer.None; } return(result); } else { return(BgPlayer.None); } }
public bool PlayersTurn(BgPlayer player) { if (m_PlayerBoth.Checked && player != BgPlayer.None) { return(true); } else if (m_PlayerLight.Checked && player == BgPlayer.Light) { return(true); } else if (m_PlayerDark.Checked && player == BgPlayer.Dark) { return(true); } return(false); }
public bool PutPiece(BgPlayer piece) { if (m_Owner == BgPlayer.None) { m_Owner = piece; m_Count = 1; return(true); } else if (m_Owner == piece) { m_Count++; return(true); } else { return(false); } }
public bool PutPiece( BgPlayer piece ) { if ( m_Owner == BgPlayer.None ) { m_Owner = piece; m_Count = 1; return true; } else if ( m_Owner == piece ) { m_Count++; return true; } else { return false; } }
public void Double( BgPlayer player ) { if ( m_Owner == BgPlayer.None || m_Owner == player ) m_Value *= 2; }
public void Clear() { m_List.Clear(); m_Winner = BgPlayer.None; }
public void SwitchPlayer() { m_CurrentPlayer = CurrentOpponentPlayer; SetCorrectlySwitchedBoard(); }
public void PutPiece( int square, BgPlayer player ) { if ( square < 0 || square > m_Board.SquareCount - 1 ) return; if ( player == CurrentPlayer && square == 0 ) return; if ( player == CurrentOpponentPlayer && square == 25 ) return; if ( ( m_Board.GetSquare( square, m_SwitchedBoard ).Owner == BgPlayer.None || m_Board.GetSquare( square, m_SwitchedBoard ).Owner == player ) && m_Board.GetOffBoardSquare( player ).Count > 0 ) { if ( m_MaxFivePiecesOnAPoint && m_Board.GetSquare( square, m_SwitchedBoard ).Count >= 5 ) return; m_Board.GetOffBoardSquare( player ).RemovePiece(); m_Board.GetSquare( square, m_SwitchedBoard ).PutPiece( player ); } }
public int GetPips( BgPlayer player ) { int result = 0; bool boardSwitch = ( player == m_CurrentPlayer )? m_SwitchedBoard : !m_SwitchedBoard; for ( int i = 0; i < m_Board.SquareCount; i++ ) { if ( m_Board.GetSquare( i, boardSwitch ).Owner == player ) result += i * m_Board.GetSquare( i, boardSwitch ).Count; } return result; }
public void DrawSquare( int bgSquare, BgPlayer owner, int numPieces ) { if ( bgSquare < 0 || bgSquare > 25 || owner == BgPlayer.None || numPieces <= 0 ) return; int square = ( m_GammonGame.CurrentPlayer == BgPlayer.Light )? 25 - bgSquare : bgSquare; Image img = null; if ( owner == BgPlayer.Dark ) img = m_CheckerDark; else if ( owner == BgPlayer.Light ) img = m_CheckerLight; for ( int i = 1; i <= numPieces && i <= 5; i++ ) m_BoardPainter.DrawImage( img, GetSquaresLeftCoordinate( square ), GetSquaresFreeTopCoordinate( square, i ), 36, 36 ); if ( numPieces > 5 ) { m_BoardPainter.DrawImage( m_CheckerCount, GetSquaresLeftCoordinate( square ) + 6, GetSquaresFreeTopCoordinate( square, 5 ) + 6, 24, 24); int leftAdjust = ( numPieces < 10 )? 10 : 5; m_BoardPainter.DrawString( numPieces.ToString(), m_CheckerCountFont, m_CheckerCountFontBrush, GetSquaresLeftCoordinate( square ) + leftAdjust, GetSquaresFreeTopCoordinate( square, 5 ) + 9 ); } }
public void Reset() { m_Value = 1; m_Owner = BgPlayer.None; }
public void EditBoard() { m_Cube.Reset(); m_UndoStack.Clear(); m_Winner = BgPlayer.None; m_History.Clear(); m_Board.ClearBoard(); }
public void Reset() { m_Value = 1; m_Owner = BgPlayer.None; }
public GameHistory() { m_List = new ArrayList(); m_Winner = BgPlayer.None; m_WinType = 0; }
public BgSquare() { m_Owner = BgPlayer.None; m_Count = 0; }
public bool IsAgentPlaying(BgPlayer player) { return(m_GUI.PlayersTurn(player)); }
public BgSquare( BgPlayer owner, int count ) : this() { if ( owner != BgPlayer.None && count > 0 ) { m_Owner = owner; m_Count = count; } }
public void SwitchPlayer() { m_CurrentPlayer = CurrentOpponentPlayer; SetCorrectlySwitchedBoard(); }
public bool PlayersTurn( BgPlayer player ) { if ( m_PlayerBoth.Checked && player != BgPlayer.None ) return true; else if ( m_PlayerLight.Checked && player == BgPlayer.Light ) return true; else if ( m_PlayerDark.Checked && player == BgPlayer.Dark ) return true; return false; }
public BgSquare() { m_Owner = BgPlayer.None; m_Count = 0; }
public void SetWinner(BgPlayer w) { m_Winner = w; }
public int PiecesRemoved( BgPlayer player ) { return m_Board.GetOffBoardSquare( player ).Count; }
private void _NewGame( bool nackgammon, bool maxFivePiecesOnPoint ) { m_MaxFivePiecesOnAPoint = maxFivePiecesOnPoint; m_Board.SetStartLayout( nackgammon ); m_Cube.Reset(); m_UndoStack.Clear(); m_Winner = BgPlayer.None; m_History.Clear(); do { RollDices(); } while ( m_BgDiceCup.GetDice( 0 ).Value == m_BgDiceCup.GetDice( 1 ).Value ); if ( m_Moves[0] > m_Moves[1] ) m_CurrentPlayer = BgPlayer.Dark; else m_CurrentPlayer = BgPlayer.Light; SetCorrectlySwitchedBoard(); m_MaxMovesPossible = MaxMovesPossible( 0 ); }
public void SetWinner( BgPlayer w ) { m_Winner = w; }
public int PiecesRemoved(BgPlayer player) { return(m_Board.GetOffBoardSquare(player).Count); }
private void FindWinner() { if ( m_Board.GetOffBoardSquare( BgPlayer.Dark ).Count == 15 ) m_Winner = BgPlayer.Dark; else if ( m_Board.GetOffBoardSquare( BgPlayer.Light ).Count == 15 ) m_Winner = BgPlayer.Light; }
public GameHistory() { m_List = new ArrayList(); m_Winner = BgPlayer.None; m_WinType = 0; }
public BgPlayer RemovePiece() { if ( m_Count > 0 ) { BgPlayer result = m_Owner; m_Count--; if ( m_Count == 0 ) m_Owner = BgPlayer.None; return result; } else { return BgPlayer.None; } }
public void Clear() { m_List.Clear(); m_Winner = BgPlayer.None; }
public bool EndTurn() { FindWinner(); if ( m_Winner != BgPlayer.None ) { BoardRepresentation finalBoard = new BoardRepresentation( this ); if ( m_History.Count() > 0 && !m_History.PeekLast().PatternMatches( finalBoard ) ) { m_History.Add( finalBoard ); m_History.Winner = m_Winner; m_History.WinType = VictoryType(); } return false; } if ( !IsMovesUsed() ) if ( DoesValidMoveExist() ) return false; m_History.Add( new BoardRepresentation( this ) ); m_UndoStack.Clear(); m_CurrentPlayer = CurrentOpponentPlayer; SetCorrectlySwitchedBoard(); RollDices(); m_MaxMovesPossible = MaxMovesPossible( 0 ); return true; }
public bool IsAgentPlaying( BgPlayer player ) { return m_GUI.PlayersTurn( player ); }