Exemplo n.º 1
0
 /** Empties the removed fighters array. */
 private void emptyRemovedFighters() {
   for (int i = 0; i < removedFighters.size(); i++) {
     Character f = removedFighters.get(i);
     f.stopFighting();
   }
   removedFighters.clear();
 }
Exemplo n.º 2
0
 /** Regenerates the mana of the current Character. */
 private void regenerateMana() {
   Character c = getCurrentFighter();
   int oldMana = c.getMP();
   int manaMax = c.getMaxMP();
   int amount = (int) Math.floor(manaMax * MANA_GEN);
   c.gainMP(amount);
   regeneratedMana = c.getMP() - oldMana;
 }
Exemplo n.º 3
0
 /**
  * Decrements the team ID of all fighters on teams higher than the given team.
  *
  * @param teamId The ID to shift all fighters left towards.
  */
 private void reassignTeams(int teamId) {
   for (int i = teamId; i < fighters.size(); i++) {
     ArrayList<Character> team = fighters.get(i);
     for (Character c : team) {
       c.setTeamId(i);
     }
   }
 }
Exemplo n.º 4
0
 /**
  * Decrements the ID of all fighters on the given team with an higher than the given one.
  *
  * @param teamId The ID of the team whose fighters to reassign.
  * @param id The ID to shift all fighters left towards.
  */
 private void reassignIds(int teamId, int id) {
   ArrayList<Character> team = fighters.get(teamId);
   for (Character c : team) {
     if (c.getFighterId() > id) {
       c.setFighterId(c.getFighterId() - 1);
     }
   }
 }
Exemplo n.º 5
0
 /** Removes the targeted fighter if he is now dead. */
 private void checkDeath() {
   List<Character> targets = lastAction.getTargets();
   for (Character c : targets) {
     if (!c.isAlive()) {
       removeFighter(c);
     }
   }
 }
Exemplo n.º 6
0
 /**
  * Assigns characters to the fighters list. Each character's fighter ID and team ID is set and
  * they are added to the internal array. The team ID is arbitrary; as long as Characters on the
  * same team have the same team ID, the actual number doesn't matter. The fighter ID is simply set
  * in the order that the participants are given.
  */
 private void assignToFighters(Character[][] teams) {
   this.fighters = new ArrayList<ArrayList<Character>>(teams.length);
   for (Character[] t : teams) {
     ArrayList<Character> team = new ArrayList<Character>(t.length);
     for (Character c : t) {
       c.startFighting(team.size(), fighters.size());
       team.add(c);
     }
     fighters.add(team);
   }
 }
Exemplo n.º 7
0
 /**
  * Removes a fighter from the field. All of the Character's battle params are reset and it is
  * removed from the list of fighters.
  *
  * @param f The fighter to remove.
  */
 private void removeFighter(Character f) {
   int team = f.getTeamId();
   int id = f.getFighterId();
   int turnId = turnOrder.indexOf(f);
   turnOrder.remove(turnId);
   if (currentFighter > turnId) {
     currentFighter--;
   }
   fighters.get(team).remove(id);
   reassignIds(team, id);
   removedFighters.add(f);
 }