Exemple #1
0
  @Before
  public void init() throws IOException, JAXBException {
    GameSave gs = GameSave.load(_gameSavePath);

    GameDefinition def = gs.getDef();
    def.setGameManager(new GameManager());
    _g = def.getManager().create(def.getId());
    _save = gs;
  }
Exemple #2
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++;
   }
 }
Exemple #3
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");
  }
Exemple #4
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())));
     }
   }
 }