Class Battle

java.lang.Object
com.mg105.entities.Battle

public class Battle extends Object
Battle is a class which contains information about the status of a combat encounter, the participating characters, and the order in which they would move, along with a number of upgrade tokens upon victory.
  • Constructor Details

    • Battle

      public Battle(ArrayList<BattleCharacter> opponents, ArrayList<BattleCharacter> party)
      Creates a new Battle instance with ongoing status, given BattleCharacters, and a Queue of the characters sorted by their speed stats.
      Parameters:
      opponents - a collection of opponent BattleCharacters.
      party - a collection of player BattleCharacters.
  • Method Details

    • getBattleStatus

      public int getBattleStatus()
      Returns whether the encounter has been won, lost or neither.
      Returns:
      an integer in {-1, 0, 1} representing the current status of the battle.
    • getOpponents

      public ArrayList<BattleCharacter> getOpponents()
      Returns the list of active opponent characters.
      Returns:
      an ArrayList of opponent BattleCharacters.
    • getPlayerCharacters

      public ArrayList<BattleCharacter> getPlayerCharacters()
      Returns the list of active player characters.
      Returns:
      an ArrayList of player BattleCharacters.
    • getMovingCharacter

      public BattleCharacter getMovingCharacter()
      Removes the character at the front of the moveQueue, replaces it at the end, and returns the character.
      Returns:
      the next BattleCharacter to move.
    • removeChar

      public void removeChar(BattleCharacter fainted)
      Removes the given fainted character from the ArrayList corresponding to which side it is on, and the moveQueue.
      Parameters:
      fainted - the BattleCharacter to be removed from the game.
    • getCharacter

      public BattleCharacter getCharacter(String name) throws NoSuchElementException
      Returns the character in the encounter based on the given name
      Parameters:
      name - the name String of the BattleCharacter to be returned
      Returns:
      the BattleCharacter in the encounter with the given name
      Throws:
      NoSuchElementException - if no character in the party has the given name