@Test
 public void testGetGOLD() throws IOException, InterruptedException {
   Scanner sc = new Scanner(System.in);
   Name ok = new Name();
   Player gram = new Warrior(ok);
   assertTrue(gram.getGOLD() == 0);
 }
Beispiel #2
0
  @Before
  public void setUp() {
    p1 = new Player("p1", Mockito.mock(RealUser.class));
    p2 = new Player("p1", Mockito.mock(RealUser.class));

    p1.addObserver(p2);
    p2.addObserver(p1);
  }
 @Test
 public void testChgMAN() throws IOException, InterruptedException {
   Scanner sc = new Scanner(System.in);
   Name ok = new Name();
   Player gram = new Warrior(ok);
   gram.chgMAN(1);
   assertTrue(gram.ex_mana == 1);
 }
  @Test
  public void testBoolConstructor() {
    Player p1 = new Player(true);
    assertEquals('X', p1.getMarker());

    Player p2 = new Player(false);
    assertEquals('O', p2.getMarker());
  }
Beispiel #5
0
 @Test
 public void testAttack() throws Exception {
   Damage dmg = new Damage(WeaponTypes.Hands);
   Monster monster = new Monster("test", "monster description", 100, dmg, 1);
   Player player = new Player("test", "monster description", 100, dmg, 1, 1);
   monster.attack(player);
   assertTrue(player.getHitpoint() != 100);
 }
Beispiel #6
0
 /** Test of setGoals method, of class Player. */
 @Test
 public void testSetGoals() {
   System.out.println("setGoals");
   int goals = 0;
   Player instance = null;
   instance.setGoals(goals);
   // TODO review the generated test code and remove the default call to fail.
   fail("The test case is a prototype.");
 }
 @Test
 public void testSuspend() {
   Player player = new PlayerImpl("Zlatan");
   long now = new Date().getTime();
   long tomorrow = now + 86400 * 1000;
   long yesterday = now - 86400 * 1000;
   assertFalse(player.suspend(new Date(yesterday)));
   assertTrue(player.suspend(new Date(tomorrow)));
 }
Beispiel #8
0
 /** Test of setName method, of class Player. */
 @Test
 public void testSetName() {
   System.out.println("setName");
   String name = "";
   Player instance = null;
   instance.setName(name);
   // TODO review the generated test code and remove the default call to fail.
   fail("The test case is a prototype.");
 }
Beispiel #9
0
  @Test
  public void givenValuesToPlayerConstructorThenValuesAreSetForPlayer() {
    String name = "Bob";
    LotteryTicket ticket = new LotteryTicket(13);

    Player player = new Player(name, ticket);

    assertEquals(name, player.getName());
    assertEquals(ticket, player.getTicketNumber());
  }
 @Test
 public void testUseMPOT() throws IOException, InterruptedException {
   Scanner sc = new Scanner(System.in);
   Name ok = new Name();
   Player gram = new Warrior(ok);
   gram.useMPOT(true, 0); // uzycie
   assertTrue(gram.m_pot == 1);
   gram.useMPOT(false, 1); // dodanie
   assertTrue(gram.m_pot == 2);
 }
Beispiel #11
0
 /** Test of getName method, of class Player. */
 @Test
 public void testGetName() {
   System.out.println("getName");
   Player instance = null;
   String expResult = "";
   String result = instance.getName();
   assertEquals(expResult, result);
   // TODO review the generated test code and remove the default call to fail.
   fail("The test case is a prototype.");
 }
Beispiel #12
0
  @Test
  public void picksHealth() {
    // jogador apanha um bonus de vida (ganha vida)
    Player p = new Player(true);

    int life = p.getLifepoints();

    // cria objeto que da a vida ao player
    Health h = new Health(p.getX(), p.getY(), true);

    Obstacle ob = new Obstacle((int) p.getX(), (int) p.getY(), 20, true);

    // verifica se apanha
    assertTrue(h.colide(p));
    h.caught(p, true);

    // verifica se nao ganha vida, pois tem a vida cheia
    assertEquals(life, p.getLifepoints());

    // perde vida
    ob.damage(p);
    int life1 = p.getLifepoints();
    assertTrue(life > life1);

    // ganha vida
    h.caught(p, true);
    assertTrue(life1 < p.getLifepoints());
  }
Beispiel #13
0
  @Test
  public void picksFuel() {
    // jogador apanha um bonus de combustivel
    Player p = new Player(true);

    int fuel = p.getFuel();

    // cria objeto que da a vida ao player
    Fuel f = new Fuel(p.getX(), p.getY(), true);

    // verifica se apanha
    assertTrue(f.colide(p));
    f.caught(p, true);

    // nao ganha fuel, pois esta cheio
    assertFalse(fuel < p.getFuel());

    // retirar fuel
    p.addFuel(-100);
    assertTrue(fuel > p.getFuel());

    // ganha fuel
    int fuel1 = p.getFuel();
    f.caught(p, true);
    assertTrue(fuel1 < p.getFuel());
  }
Beispiel #14
0
 /** Test of getStartingLocation method, of class Player. */
 @Test
 public void testGetStartingLocation() {
   System.out.println("getStartingLocation");
   Player instance =
       new Player(
           new PlayerInfo("String", 0, "String"),
           new RouteRunner(new int[] {1, 1}, "String", "String"));
   int[] expResult = {1, 1};
   int[] result = instance.getStartingLocation();
   assertArrayEquals(expResult, result);
 }
Beispiel #15
0
 /** Test of compareTo method, of class Player. */
 @Test
 public void testCompareTo() {
   System.out.println("compareTo");
   Player t = null;
   Player instance = null;
   int expResult = 0;
   int result = instance.compareTo(t);
   assertEquals(expResult, result);
   // TODO review the generated test code and remove the default call to fail.
   fail("The test case is a prototype.");
 }
  @Test
  public void testAddEXP() throws IOException, InterruptedException {
    Scanner sc = new Scanner(System.in);
    Name ok = new Name();
    Player gram = new Warrior(ok);
    gram.addEXP(1);
    assertTrue(gram.exp == 1);

    gram.addEXP(500);
    assertTrue(gram.lvl == 2);
    assertTrue(gram.exp == 1);
  }
Beispiel #17
0
  @Test
  public void colidesWithMine() {
    // jogador fica com os controlos trocados
    Player p = new Player(true);
    Skymine s = new Skymine(p.getX(), p.getY(), true);

    assertFalse(p.isMalfunctioning());
    assertTrue(s.colide(p));
    s.caught(p, true);

    assertTrue(p.isMalfunctioning());
  }
Beispiel #18
0
 /** Test of giveBall method, of class Player. Keksi miten vertaillaan booleaneita */
 @Test
 public void testGiveBall() {
   System.out.println("giveBall");
   PlayerInfo pManning = new PlayerInfo("Peyton Manning", 18);
   int[] alkupaikka1 = {5, 5};
   RouteRunner testiOff = new RouteRunner(alkupaikka1, "879987", "Q");
   Player qb = new Player(pManning, testiOff);
   qb.setLocation(alkupaikka1);
   Player instance = qb;
   instance.giveBall();
   System.out.println("Peytonilla on pallo " + instance.isBallCarrier());
 }
Beispiel #19
0
 /** Test of getDefPlayerStrategy method, of class Player. */
 @Test
 public void testGetDefPlayerStrategy() {
   System.out.println("getDefPlayerStrategy");
   Player instance =
       new Player(
           new PlayerInfo("String", 0, "String"), new PassRusher(new int[] {1, 1}, "String"));
   boolean expResult = true;
   boolean result = instance.getDefPlayerStrategy().getIsOffensive() == false;
   result = instance.getDefPlayerStrategy().getIcon() == 'S';
   // result = instance.getDefPlayerStrategy().getStartingLocation() == new int[]{1, 1};
   assertEquals(expResult, result);
 }
Beispiel #20
0
 /** Test of setLocation method, of class Player. */
 @Test
 public void testSetLocation() {
   System.out.println("setLocation");
   int[] location = {2, 2};
   Player instance =
       new Player(
           new PlayerInfo("String", 0, "String"),
           new RouteRunner(new int[] {1, 1}, "String", "String"));
   instance.setLocation(location);
   int[] expResult = {2, 2};
   int[] result = instance.getLocation();
   assertArrayEquals(expResult, result);
 }
Beispiel #21
0
 /** Test of isBallCarrier method, of class Player. */
 @Test
 public void testIsBallCarrier() {
   System.out.println("isBallCarrier");
   PlayerInfo pManning = new PlayerInfo("Peyton Manning", 18);
   int[] alkupaikka1 = {5, 5};
   RouteRunner testiOff = new RouteRunner(alkupaikka1, "879987", "Q");
   Player qb = new Player(pManning, testiOff);
   qb.setLocation(alkupaikka1);
   Player instance = qb;
   boolean expResult = false;
   boolean result = instance.isBallCarrier();
   assertEquals(expResult, result);
 }
Beispiel #22
0
 /** Test of getLocation method, of class Player. */
 @Test
 public void testGetLocation() {
   System.out.println("getLocation");
   PlayerInfo pManning = new PlayerInfo("Peyton Manning", 18);
   int[] alkupaikka1 = {5, 5};
   RouteRunner testiOff = new RouteRunner(alkupaikka1, "879987", "Q");
   Player qb = new Player(pManning, testiOff);
   qb.setLocation(alkupaikka1);
   Player instance = qb;
   int[] expResult = new int[] {5, 5};
   int[] result = instance.getLocation();
   assertArrayEquals(expResult, result);
 }
 @Test
 public void testComputerMove() {
   // Function returns a random number in the range 0-8, so very rarely this test may fail
   Player p = new Player();
   ArrayList<Integer> list = new ArrayList<Integer>();
   for (int i = 0; i < 100; i++) {
     int a = p.getComputerMove();
     assertTrue(a >= 0 && a <= 8);
     list.add(a);
   }
   for (int i = 0; i <= 8; i++) {
     assertTrue(list.contains(i));
   }
 }
Beispiel #24
0
 @Test
 public void testTryMovePlayer9() {
   System.out.println("tryMovePlayer");
   int direction = 9;
   PlayerInfo pManning = new PlayerInfo("Peyton Manning", 18);
   int[] alkupaikka1 = {5, 5};
   RouteRunner testiOff = new RouteRunner(alkupaikka1, "879987", "Q");
   Player qb = new Player(pManning, testiOff);
   qb.setLocation(alkupaikka1);
   Player instance = qb;
   int[] expResult = {6, 6};
   int[] result = instance.tryMovePlayer(direction);
   assertArrayEquals(expResult, result);
 }
Beispiel #25
0
  /** Test of askIsOffence method, of class Player. */
  @Test
  public void testAskIsOffence() {
    System.out.println("askIsOffence");

    PlayerInfo pManning = new PlayerInfo("Peyton Manning", 18);
    int[] alkupaikka1 = {5, 5};
    RouteRunner testiOff = new RouteRunner(alkupaikka1, "879987", "Q");
    Player qb = new Player(pManning, testiOff);

    Player instance = qb;
    boolean expResult = true;
    boolean result = instance.askIsOffence();
    assertEquals(expResult, result);
  }
Beispiel #26
0
  /** Test of toString method, of class Player. */
  @Test
  public void testToString() {
    System.out.println("toString");

    PlayerInfo pManning = new PlayerInfo("Peyton Manning", 18);
    int[] alkupaikka1 = {5, 5};
    RouteRunner testiOff = new RouteRunner(alkupaikka1, "879987", "Q");
    Player qb = new Player(pManning, testiOff);

    Player instance = qb;
    String expResult = "18 Peyton Manning";
    String result = instance.toString();
    assertEquals(expResult, result);
  }
Beispiel #27
0
  /** Test of playerMoved method, of class Player. */
  @Test
  public void testPlayerMoved() {
    System.out.println("playerMoved");

    PlayerInfo pManning = new PlayerInfo("Peyton Manning", 18);
    int[] alkupaikka1 = {5, 5};
    RouteRunner testiOff = new RouteRunner(alkupaikka1, "879987", "Q");
    Player qb = new Player(pManning, testiOff);
    qb.setLocation(alkupaikka1);

    int[] where = {6, 6};
    Player instance = qb;
    instance.playerMoved(where);
  }
Beispiel #28
0
  /** Test of setPlayerStrategy method, of class Player. */
  @Test
  public void testSetPlayerStrategy() {
    System.out.println("setPlayerStrategy");

    PlayerInfo pManning = new PlayerInfo("Peyton Manning", 18);
    int[] alkupaikka1 = {5, 5};
    RouteRunner testiOff = new RouteRunner(alkupaikka1, "879987", "Q");
    Player qb = new Player(pManning, testiOff);
    qb.setLocation(alkupaikka1);

    PlayerStrategy strategy = new RouteRunner("666");
    Player instance = qb;
    instance.setPlayerStrategy(strategy);
  }
 @Test
 public void testGameFameCorrectAtGameStart() {
   List<Player> listOfPlayers = new ArrayList<>();
   GameSetup gameSetup = new GameSetup();
   listOfPlayers = gameSetup.initializePlayers(6);
   boolean didItFail = false;
   for (Player player : listOfPlayers) {
     int fame = player.getFame();
     if (fame != 1500) {
       didItFail = true;
     }
   }
   assertFalse(didItFail);
 }
 @Test
 public void testGameTokensOnGoAtGameStart() {
   List<Player> listOfPlayers = new ArrayList<>();
   GameSetup gameSetup = new GameSetup();
   listOfPlayers = gameSetup.initializePlayers(6);
   boolean didItFail = false;
   for (Player player : listOfPlayers) {
     int location = player.getLocation();
     if (location != 0) {
       didItFail = true;
     }
   }
   assertFalse(didItFail);
 }