Class 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.
      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.
      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.
      an ArrayList of opponent BattleCharacters.
    • getPlayerCharacters

      public ArrayList<BattleCharacter> getPlayerCharacters()
      Returns the list of active player characters.
      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.
      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.
      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
      name - the name String of the BattleCharacter to be returned
      the BattleCharacter in the encounter with the given name
      NoSuchElementException - if no character in the party has the given name