예제 #1
0
 /**
  * Returns the MoveDouble associated with this SaveMoveDouble.
  *
  * @return the MoveDouble associated with this SaveMoveDouble.
  */
 @Override
 public Move move() {
   if (moves.size() < 2) return null;
   SaveMoveTicket move1 = moves.get(0);
   SaveMoveTicket move2 = moves.get(1);
   MoveDouble move =
       MoveDouble.instance(
           Colour.valueOf(super.colour), (MoveTicket) move1.move(), (MoveTicket) move2.move());
   return move;
 }
예제 #2
0
    /**
     * Constructs a new SaveMoveDouble object.
     *
     * @param move the MoveDouble to convert to a SaveMoveDouble.
     */
    public SaveMoveDouble(MoveDouble move) {
      super(move.colour);

      moves = new ArrayList<SaveMoveTicket>();
      MoveTicket mt1 = move.move1;
      SaveMoveTicket newMove1 = new SaveMoveTicket(mt1);
      moves.add(newMove1);
      MoveTicket mt2 = move.move2;
      SaveMoveTicket newMove2 = new SaveMoveTicket(mt2);
      moves.add(newMove2);
    }
예제 #3
0
 /**
  * Returns true if there are saved moves available, false otherwise.
  *
  * @return true if there are saved moves available, false otherwise.
  */
 public boolean hasSavedMove() {
   if (savedMoves == null) {
     savedMoves = moves;
     moves = new ArrayList<SaveMove>();
   }
   return savedMoves.size() > 0;
 }
예제 #4
0
 /**
  * Adds a Move to the save game.
  *
  * @param move the Move to be added to the save game.
  */
 public void addMove(Move move) {
   SaveMove saveMove = null;
   if (move instanceof MoveDouble) {
     saveMove = new SaveMoveDouble((MoveDouble) move);
   } else if (move instanceof MovePass) {
     saveMove = new SaveMovePass((MovePass) move);
   } else if (move instanceof MoveTicket) {
     saveMove = new SaveMoveTicket((MoveTicket) move);
   }
   if (saveMove != null) moves.add(saveMove);
 }
예제 #5
0
 /**
  * Returns the next saved move in the game.
  *
  * @return the next saved move in the game.
  */
 public Move getSavedMove() {
   SaveMove sMove = savedMoves.get(0);
   Move move = sMove.move();
   savedMoves.remove(0);
   return move;
 }