Beispiel #1
0
 // Constructors
 public Piece(GoInterface.PieceRepresentation pieceRepresentation, Army army, PiecePosition position)
 {
     this.army = army;
     this.pieceRepresentation = pieceRepresentation;
     this.position = position;
     if(army.LastPlay == position)
     {
         throw new PieceException(this, "Invalid place.");
     }
     int liberties = CheckNeighbours();
     if(!IsValidPosition(liberties))
     {
         RollbackChanges();
         throw new PieceException(this, "Invalid place.");
     }
     CommitChanges(liberties);
     army.LastPlay = position;
 }
Beispiel #2
0
 public void PutPiece(PiecePosition position, String playerName, GoInterface.PieceRepresentation pieceRepresentation)
 {
     if(!started)
     {
         throw new GameException("Game is not started. Please start game before playing.");
     }
     if(!active.Name.Equals(playerName))
     {
         throw new GameException("You are not the current player.");
     }
     try
     {
         new Piece(pieceRepresentation, active.Army, position);
         active = (active == white? black: white);
     }
     catch(PieceException exception)
     {
         throw new GameException(exception.Message, exception);
     }
 }