コード例 #1
0
  @Before
  public void init() throws IOException {

    ScrabbleSystem.getInstance().destorySystem();
    Board.getInstance().destroyBoard();
    Bag.getInstance().resetTileBag();

    scrabbleSystem = ScrabbleSystem.getInstance();
    board = Board.getInstance();
    factory = new SpecialTileFactory();
    testFactory = new TestFactory();
    dict = new Dict();

    // first player's move
    moveList1 = testFactory.produceMoveList1();
    SpecialTile negativePoints = factory.produce(SpecialTileType.NEGATIVE_POINTS);
    SpecialMove specialMove1 = new SpecialMove(position5, negativePoints);
    specialMoveList1 = new ArrayList<>();
    specialMoveList1.add(specialMove1);

    // second player's move
    moveList2 = testFactory.produceMoveList2();
    specialMoveList2 = new ArrayList<>();

    // initialize game and start
    ArrayList<String> playerNameList = new ArrayList<>();
    playerNameList.add("Bob");
    playerNameList.add("Lucy");
    scrabbleSystem.startGame(playerNameList);
  }
コード例 #2
0
  @Test
  public void testNegativePoints() {
    // first player's move
    scrabbleSystem.isValid(moveList1, specialMoveList1);
    scrabbleSystem.move(moveList1, specialMoveList1);
    // second player's move, it will trigger special tile
    scrabbleSystem.nextPlayer();
    scrabbleSystem.getCurrentPlayer().setPlayerPoints(50);
    scrabbleSystem.isValid(moveList2, specialMoveList2);
    scrabbleSystem.move(moveList2, specialMoveList2);

    /*
     * the points should be (50 - 9) = 41, since the word points are set to
     * negative
     */
    assertEquals(41, scrabbleSystem.getCurrentPlayer().getPlayerPoints());
  }