예제 #1
0
 /**
  * Constructor for CommandChannel.
  *
  * @param leader Player
  */
 public CommandChannel(Player leader) {
   _commandChannelLeader = leader;
   _commandChannelParties.add(leader.getParty());
   _commandChannelLvl = leader.getParty().getLevel();
   leader.getParty().setCommandChannel(this);
   broadCast(ExMPCCOpen.STATIC);
 }
예제 #2
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;
 }
예제 #3
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()));
  }
예제 #4
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");
  }
예제 #5
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);
 }
예제 #6
0
 /**
  * Этот метод рассчитывает количество дропнутых вещей в зависимости от рейтов. <br>
  * <br>
  * Следует учесть, что контроль за верхним пределом вещей в квестах, в которых нужно набить
  * определенное количество предметов не осуществляется. <br>
  * <br>
  * Ни один из передаваемых параметров не должен быть равен 0
  *
  * @param min минимальное количество при рейтах 1х
  * @param max максимальное количество при рейтах 1х
  * @param calcChance шанс при рейтах 1х, в процентах
  * @return количество вещей для дропа, может быть 0
  */
 public int rollDrop(int min, int max, double calcChance) {
   if ((calcChance <= 0) || (min <= 0) || (max <= 0)) {
     return 0;
   }
   int dropmult = 1;
   calcChance *= getRateQuestsDrop();
   if (getQuest().getParty() > Quest.PARTY_NONE) {
     Player player = getPlayer();
     if (player.getParty() != null) {
       calcChance *=
           Config.ALT_PARTY_BONUS[
               player.getParty().getMemberCountInRange(player, Config.ALT_PARTY_DISTRIBUTION_RANGE)
                   - 1];
     }
   }
   if (calcChance > 100) {
     if ((int) Math.ceil(calcChance / 100) <= (calcChance / 100)) {
       calcChance = Math.nextUp(calcChance);
     }
     dropmult = (int) Math.ceil(calcChance / 100);
     calcChance = calcChance / dropmult;
   }
   return Rnd.chance(calcChance) ? Rnd.get(min * dropmult, max * dropmult) : 0;
 }
예제 #7
0
    @Override
    public void onKill(Creature actor, Creature victim) {
      if (!victim.isPlayer()) {
        return;
      }

      Player actorPlayer = (Player) actor;
      List<Player> players = null;
      switch (_quest.getParty()) {
        case Quest.PARTY_NONE:
          players = Collections.singletonList(actorPlayer);
          break;
        case Quest.PARTY_ALL:
          if (actorPlayer.getParty() == null) {
            players = Collections.singletonList(actorPlayer);
          } else {
            players = new ArrayList<Player>(actorPlayer.getParty().getMemberCount());
            for (Player member : actorPlayer.getParty().getPartyMembers()) {
              if (member.isInRange(actorPlayer, Creature.INTERACTION_DISTANCE)) {
                players.add(member);
              }
            }
          }
          break;
        default:
          players = Collections.emptyList();
          break;
      }

      for (Player player : players) {
        QuestState questState = player.getQuestState(_quest.getClass());
        if ((questState != null) && !questState.isCompleted()) {
          _quest.notifyKill((Player) victim, questState);
        }
      }
    }
예제 #8
0
  /**
   * Method checkAuthority.
   *
   * @param creator Player
   * @return boolean
   */
  public static boolean checkAuthority(Player creator) {
    if ((creator.getClan() == null)
        || !creator.isInParty()
        || !creator.getParty().isLeader(creator)
        || (creator.getPledgeClass() < Player.RANK_BARON)) {
      creator.sendPacket(
          new SystemMessage(SystemMessage.YOU_DO_NOT_HAVE_AUTHORITY_TO_USE_THE_COMMAND_CHANNEL));
      return false;
    }

    boolean haveSkill = creator.getSkillLevel(CLAN_IMPERIUM_ID) > 0;
    boolean haveItem = creator.getInventory().getItemByItemId(STRATEGY_GUIDE_ID) != null;

    if (!haveSkill && !haveItem) {
      creator.sendPacket(
          new SystemMessage(SystemMessage.YOU_DO_NOT_HAVE_AUTHORITY_TO_USE_THE_COMMAND_CHANNEL));
      return false;
    }

    return true;
  }
예제 #9
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);
            }
          }
        };
  }