Esempio n. 1
0
 /**
  * Gets the unit.
  *
  * @param id the Unit Identifier
  * @return the unit
  */
 public static Unit getUnit(UnitIdentifier id) {
   for (Player p : getPlayers().values()) {
     if (!p.isSpectator() && p.getParty().getColor().equals(id.partyColor)) {
       return p.getParty().search(id.name);
     }
   }
   return null;
 }
Esempio n. 2
0
  /**
   * 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()));
  }
Esempio n. 3
0
  /* (non-Javadoc)
   * @see chu.engine.Game#init(int, int, java.lang.String)
   */
  public void init(int width, int height, String name) {
    super.init(width, height, name);
    Player p1 = new Player("Player", (byte) 0);
    localPlayer = p1;
    ByteBuffer icon16, icon32;
    icon16 = icon32 = null;
    try {
      icon16 =
          ByteBuffer.wrap(
              TextureLoader.getTexture(
                      "PNG", ResourceLoader.getResourceAsStream("res/gui/icon16.png"))
                  .getTextureData());
      icon32 =
          ByteBuffer.wrap(
              TextureLoader.getTexture(
                      "PNG", ResourceLoader.getResourceAsStream("res/gui/icon32.png"))
                  .getTextureData());
    } catch (IOException e) {
      e.printStackTrace();
    }
    Display.setIcon(new ByteBuffer[] {icon16, icon32});
    FEResources.loadResources();
    FEResources.loadBitmapFonts();
    WeaponFactory.loadWeapons();
    UnitFactory.loadUnits();
    p1.getParty().setColor(Party.TEAM_BLUE);

    /* OpenGL final setup */
    glEnable(GL_LINE_SMOOTH);

    UnitFactory.getUnit("Lyn");
    connect = new ConnectStage();
    setCurrentStage(new TitleStage());
    SoundTrack.loop("main");
  }
Esempio n. 4
0
 /** Test draft stage. */
 public void testDraftStage() {
   Player p1 = localPlayer;
   testSession =
       new Session(
           new net.fe.overworldStage.objective.Rout(),
           "test",
           6,
           new java.util.HashSet<>(),
           new net.fe.pick.Draft());
   Player p2 = new Player("p2", (byte) 1);
   Player p3 = new Player("p3", (byte) 2);
   p2.getParty().setColor(Party.TEAM_RED);
   p3.getParty().setColor(Party.TEAM_GREEN);
   p2.getParty().addUnit(UnitFactory.getUnit("Mia"));
   p2.getParty().addUnit(UnitFactory.getUnit("L'Arachel"));
   testSession.addPlayer(p1);
   testSession.addPlayer(p2);
   testSession.addPlayer(p3);
   currentStage = new TeamDraftStage(testSession);
 }
Esempio n. 5
0
  /** Test overworld stage. */
  public void testOverworldStage() {
    testSession =
        new Session(new Seize(), "test", 8, new java.util.HashSet<>(), new net.fe.pick.Draft());
    testSession.addPlayer(localPlayer);

    Player p2 = new Player("P2", (byte) 1);
    p2.getParty().setColor(Party.TEAM_RED);
    testSession.addPlayer(p2);
    localPlayer.getParty().setColor(Party.TEAM_BLUE);
    p2.setTeam(2);
    localPlayer.setTeam(1);

    Unit u1 = UnitFactory.getUnit("Natasha");
    u1.addToInventory(WeaponFactory.getWeapon("Physic"));
    u1.setHp(1);
    localPlayer.getParty().addUnit(u1);

    Unit u3 = UnitFactory.getUnit("Oswin");
    u3.addToInventory(WeaponFactory.getWeapon("Silver Axe"));
    u3.equip(0);
    u3.setHp(1);
    p2.getParty().addUnit(u3);

    Unit u4 = UnitFactory.getUnit("Eirika");
    u4.addToInventory(WeaponFactory.getWeapon("Silver Sword"));
    u4.equip(0);
    u4.setHp(1);
    p2.getParty().addUnit(u4);

    Unit u2 = UnitFactory.getUnit("Lute");
    u2.addToInventory(WeaponFactory.getWeapon("Physic"));
    u2.setHp(1);
    localPlayer.getParty().addUnit(u2);

    currentStage = new ClientOverworldStage(testSession);

    this.client =
        new Client("nope", 12345) {
          @Override
          public void sendMessage(Message message) {
            if (message instanceof CommandMessage) {
              ((ClientOverworldStage) currentStage).processCommands((CommandMessage) message);
            }
          }
        };
  }