Beispiel #1
0
 /**
  * Find targets.
  *
  * @param unit the unit
  */
 private void findTargets(Unit unit) {
   targets.clear();
   for (Node n : zone.getNodes()) {
     Unit u = grid.getUnit(n.x, n.y);
     if (u == null
         && grid.getTerrain(n.x, n.y).getMoveCost(net.fe.unit.Class.createClass("Phantom"))
             < unit.getStats().mov) {
       targets.add(n);
     }
   }
 }
  @Test
  public void testHealingItem_HighHealth_Server() {
    Statistics vals = new Statistics();
    vals = vals.copy("HP", 20);
    vals = vals.copy("Mov", 5);
    vals = vals.copy("Con", 8);
    Unit unit = new Unit("test", Class.createClass("Ike"), '-', vals, vals);
    unit.addToInventory(new HealingItem("Blarg", 15, 0, 1));
    unit.setHp(15);

    Object result = new UseCommand(0).applyServer(null, unit);

    assertEquals(20, unit.getHp());
    assertEquals(2, unit.getInventory().get(0).getUses());
    assertEquals(null, result);
  }
Beispiel #3
0
  /**
   * Generate summon.
   *
   * @param summoner the summoner
   * @return the unit
   */
  public static Unit generateSummon(Unit summoner) {
    WeaponFactory.loadWeapons();

    Statistics bases =
        new Statistics(
            /* hp = */ 1,
            /* str = */ 5,
            /* mag = */ 0,
            /* skl = */ 2,
            /* spd = */ 4,
            /* def = */ 0,
            /* res = */ 0,
            /* lck = */ 0,
            /* mov = */ 5,
            /* con = */ 11,
            /* aid = */ 10);
    Statistics growths =
        new Statistics(
            /* hp = */ 0,
            /* str = */ 55,
            /* mag = */ 15,
            /* skl = */ 35,
            /* spd = */ 45,
            /* def = */ 15,
            /* res = */ 15,
            /* lck = */ 50,
            /* mov = */ 0,
            /* con = */ 0,
            /* aid = */ 0);
    summonCount = summonCount + 1;
    final Unit summon =
        new Unit(
            "Phantom " + summonCount,
            net.fe.unit.Class.createClass("Phantom"),
            '-',
            bases,
            growths);
    summon.addToInventory(net.fe.unit.Item.getItem("Iron Axe"));
    summon.initializeEquipment();
    summon.setLevel(summoner.getLevel());
    summon.fillHp();
    summon.setMoved(true);

    summoner.getParty().addUnit(summon);
    summon.stage = summoner.stage;
    return summon;
  }
  @Test
  public void testRise_Server() {
    Statistics vals = new Statistics();
    vals = vals.copy("HP", 20);
    vals = vals.copy("Mov", 5);
    vals = vals.copy("Con", 8);
    Unit unit = new Unit("test", Class.createClass("Ike"), '-', vals, vals);
    unit.addToInventory(new RiseTome());
    unit.setHp(3);

    try {
      new UseCommand(0).applyServer(null, unit);
      fail("No exception thrown");
    } catch (IllegalStateException e) {
      // success
    }
  }
  @Test
  public void testHealingItem_OneUseWithWeapons_Server() {
    Statistics vals = new Statistics();
    vals = vals.copy("HP", 20);
    vals = vals.copy("Mov", 5);
    vals = vals.copy("Con", 8);
    Unit unit = new Unit("test", Class.createClass("Ike"), '-', vals, vals);
    unit.addToInventory(new HealingItem("Blarg", 15, 0, 1));
    unit.setHp(15);
    unit.getInventory().get(0).setUsesDEBUGGING(1);
    unit.addToInventory(createAxe(1));
    unit.addToInventory(createAxe(2));
    unit.addToInventory(createAxe(3));

    // assert doesn't throw anything
    Object result = new UseCommand(0).applyServer(null, unit);
    assertEquals(null, result);
  }