/**
   * Test fight stage.
   *
   * <p>Use debugStat on units to mess with fights, is also useful for testing animations.
   * Intentionally crashes at the end for lack of session info, so don't worry about it.
   *
   * <p>range can be set by messing with map.addUnit(), and you can change all the other
   * unit-related things to test them out. I can see us using this to use this bit for speed testing
   * in the future, if I ever make a gui or something for it.
   *
   * <p>TODO: gui for speed balancing
   */
  public void testFightStage() {
    Player p1 = localPlayer;
    testSession =
        new Session(new Seize(), "test", 8, new java.util.HashSet<>(), new net.fe.pick.Draft());
    Player p2 = new Player("p2", (byte) 1);
    p2.getParty().setColor(Party.TEAM_RED);
    p1.getParty().setColor(Party.TEAM_BLUE);
    p2.setTeam(2);
    p1.setTeam(1);

    testSession.addPlayer(p1);
    testSession.addPlayer(p2);

    final ClientOverworldStage map = new ClientOverworldStage(testSession);
    Unit u1 = UnitFactory.getUnit("Eirika");
    u1.getInventory().add(WeaponFactory.getWeapon("Silver Sword"));
    u1.equip(0);
    map.addUnit(u1, 0, 0);
    u1.setLevel(20);
    u1.loadMapSprites();
    p1.getParty().addUnit(u1);

    Unit u2 = UnitFactory.getUnit("Dart");
    u2.getInventory().add(WeaponFactory.getWeapon("Tomahawk"));
    map.addUnit(u2, 1, 0);
    u2.equip(0);
    u2.setLevel(1);
    u2.loadMapSprites();
    p2.getParty().addUnit(u2);

    map.processAddStack();
    int u2Uses = u2.getWeapon().getMaxUses();

    // u1.debugStat("Skl");
    // u1.debugStat("Str");

    // ^------- put all pre-calc stuff here

    CombatCalculator calc =
        new CombatCalculator(
            new UnitIdentifier(u1), new UnitIdentifier(u2), FEMultiplayer::getUnit);
    System.out.println(calc.getAttackQueue());

    u2.getWeapon().setUsesDEBUGGING(u2Uses);
    u1.fillHp();
    u2.fillHp();

    setCurrentStage(
        new FightStage(
            new UnitIdentifier(u1),
            new UnitIdentifier(u2),
            calc.getAttackQueue(),
            map,
            new EmptyRunnable()));
  }
Example #2
0
 public void equip(Weapon w) {
   if (equippable(w)) {
     weapon = w;
     if (stage != null) {
       ((ClientOverworldStage) stage).addCmd("EQUIP");
       ((ClientOverworldStage) stage).addCmd(new UnitIdentifier(this));
       ((ClientOverworldStage) stage).addCmd(findItem(w));
     }
     inventory.remove(w);
     inventory.add(0, w);
   }
 }
Example #3
0
 public void setHp(int hp) {
   this.hp = Math.max(hp, 0);
   if (hp == 0) {
     ((OverworldStage) stage).removeUnit(xcoord, ycoord);
     if (rescuedUnit != null) {
       drop(xcoord, ycoord);
     }
     if (Game.glContextExists()) {
       ((ClientOverworldStage) stage).setControl(false);
       stage.addEntity(new Corpse(this));
     }
   }
 }