Exemple #1
0
 @Test
 public void testAddPoints() {
   ZilchGame game = new ZilchGame();
   Player p = new Player("Paris");
   game.add(p);
   assertEquals(0, game.getCurrentPlayer().getScore());
   p.addPoints(200);
   assertEquals(200, game.getCurrentPlayer().getScore());
 }
Exemple #2
0
  public void test_Jamaal_wins() {
    ZilchGame z = new ZilchGame();

    z.add(/*p = */ new Player(z.toString()));
    setAndPlayFirstDice(z, 1); // 100
    setAndPlayFirstDice(z, 1); // 200
    setAndPlayFirstDice(z, 1); // 300
    setAndPlayFirstDice(z, 1); // 400
    setAndPlayFirstDice(z, 1); // 500
    z.getCurrentPlayer().bank();
    assertEquals(500, z.getScore(z.getCurrentPlayer()));
  }
Exemple #3
0
  @Test
  public void testGetPlayerNames() {
    ZilchGame game = new ZilchGame();
    Player ruben = new Player("Ruben");
    Player oddmund = new Player("Oddmund");
    game.add(ruben);
    game.add(oddmund);
    assertEquals("Ruben", game.getCurrentPlayer().getName());
    game.endTurn();
    assertEquals("Oddmund", game.getCurrentPlayer().getName());
    game.endTurn();
    assertEquals("Ruben", game.getCurrentPlayer().getName());

    assertTrue(game.getAllPlayers().contains(ruben));
    assertTrue(game.getAllPlayers().contains(oddmund));
  }
Exemple #4
0
  @Test
  public void test_Jamaal_plays_zilch() {
    ZilchGame z = new ZilchGame();
    Player p, j;
    z.add(p = new Player("Jamaal"));
    z.add(j = new Player("Hussein"));

    p.addPoints(0);
    p.addPoints(0);
    p.addPoints(0);

    j.addPoints(0);
    j.addPoints(0);
    j.addPoints(0);

    j.addPoints(0);
    j.addPoints(0);
    j.addPoints(0);

    assertEquals((-1000), j.getScore());

    ArrayList<Die> dice = z.getDice();

    dice.get(0).setFace(1);

    Player pablo = z.getCurrentPlayer();

    int score = z.getScore(pablo);

    pablo.play(new boolean[] {true, false, false, false, false, false});

    assertEquals(5, z.getDice().size());

    dice = z.getDice();

    dice.get(0).setFace(3);
    pablo.play(new boolean[] {true, false, false, false, false});
    System.out.println(z.getScore(pablo));
    System.out.println(score);
    System.out.println(pablo.getName());

    assertTrue(z.getScore(pablo) + 1000 == score);
  }
Exemple #5
0
 @Test
 public void testZeroPointsAtStartOfGame() {
   ZilchGame game = new ZilchGame();
   game.add(new Player("Akilles"));
   assertEquals(0, game.getCurrentPlayer().getScore());
 }
Exemple #6
0
 private void setAndPlayFirstDice(ZilchGame z, int i) {
   System.out.println(z.getDice().size());
   z.getDice().get(0).setFace(i);
   z.getCurrentPlayer().play(new boolean[] {true});
 }
Exemple #7
0
 @Test
 public void test_() {
   ZilchGame game = new ZilchGame();
   game.add(new Player("JosŽ"));
   assertNotNull(game.getCurrentPlayer().getDiceThrow());
 }