Package com.mg105.entities
Class Battle
java.lang.Object
com.mg105.entities.Battle
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 Summary
ConstructorDescriptionBattle
(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. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns whether the encounter has been won, lost or neither.getCharacter
(String name) Returns the character in the encounter based on the given nameRemoves the character at the front of the moveQueue, replaces it at the end, and returns the character.Returns the list of active opponent characters.Returns the list of active player characters.void
removeChar
(BattleCharacter fainted) Removes the given fainted character from the ArrayList corresponding to which side it is on, and the moveQueue.
-
Constructor Details
-
Battle
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
Returns the list of active opponent characters.- Returns:
- an ArrayList of opponent BattleCharacters.
-
getPlayerCharacters
Returns the list of active player characters.- Returns:
- an ArrayList of player BattleCharacters.
-
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
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
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
-