Beispiel #1
0
 /**
  * @param gameFile
  * @throws TegRequestException
  */
 @Test
 public void testCountriesOk() throws TegRequestException {
   int reqNum = 0;
   Iterator<PlayerRequest> it = _save.iterator(_g);
   while (it.hasNext()) {
     PlayerRequest req = it.next();
     if (_g.getState().atLeast(GameState.FIRST_PUT)) {
       for (Country c : _g.getBoard().getCountries()) {
         if (_g.getOwner(c) == null || _g.getArmies(c) < 1)
           Assert.fail(
               "#"
                   + reqNum
                   + ".Country "
                   + c.getName()
                   + " is owned by "
                   + (_g.getOwner(c))
                   + " with armies "
                   + _g.getArmies(c)
                   + " at req "
                   + req);
       }
     }
     req.perform(_g);
     reqNum++;
   }
 }
Beispiel #2
0
  /**
   * @param gameFile
   * @throws TegRequestException
   */
  @Test
  public void testAllValidAndNoExeptions() throws TegRequestException {
    int reqNum = 0;
    Iterator<PlayerRequest> it = _save.iterator(_g);
    while (it.hasNext()) {
      PlayerRequest req = it.next();

      if (!req.validate(_g))
        Assert.fail("#" + reqNum + "." + req.human() + " not vaid due " + req.whyNotValid(_g));
      req.perform(_g);
      reqNum++;
    }
    System.err.println("HAd " + reqNum + " reqs");
  }
Beispiel #3
0
 /**
  * @param gameFile
  * @throws TegRequestException
  */
 @Test
 public void testExchanges() throws TegRequestException {
   Iterator<PlayerRequest> it = _save.iterator(_g);
   while (it.hasNext()) {
     PlayerRequest req = it.next();
     int exchangesBefore = -1;
     if (req instanceof ExchangeCards)
       exchangesBefore = _g.getExchangesPerformed(_g.getPlayer(req.getOwner()));
     req.perform(_g);
     if (exchangesBefore > -1) {
       Assert.assertEquals(
           "exchange amount should be updated",
           exchangesBefore + 1,
           _g.getExchangesPerformed(_g.getPlayer(req.getOwner())));
     }
   }
 }