Package pile.piles
Class Active
java.lang.Object
pile.Pile
pile.piles.Active
Represents the active pile in the Pokémon Trading Card Game, where the player's active Pokémon is placed.
This class extends the Pile class and provides methods for attacking with the active Pokémon.
- Version:
- 1.0
- Author:
- Tyler Mong
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
applyMoveDamage
(int damage, PokemonCard attacker, PokemonCard defender) Applies the move's damage to the defender's HP and checks if the defender is knocked out.boolean
Performs an attack with the active Pokémon on the target Pokémon.private int
calculateMoveDamage
(Move move, PokemonCard attacker, PokemonCard defender) Calculates the move's damage based on the move's base damage and the defender's weakness/resistance to the attacker's type.private Move
selectMove
(PokemonCard attacker, PokemonCard defender) Displays the attacker's moves, prompts the player to select a move, validates the selection, and returns the selected move.Methods inherited from class pile.Pile
addCard, display, drawCard, getCardAtIndex, getCards, getSize, isEmpty, removeCard, secondaryDisplay, shuffle
-
Field Details
-
in
-
-
Constructor Details
-
Active
public Active()Constructor for the Active class. Initializes the active pile for the player.
-
-
Method Details
-
attack
Performs an attack with the active Pokémon on the target Pokémon. Displays the attacker's and defender's HP, displays the moves, prompts for move selection, applies the move's damage, and returns true if the defender is knocked out.- Parameters:
target
- The target Pokémon (defender) to be attacked.- Returns:
- True if the defender is knocked out, false otherwise.
-
selectMove
Displays the attacker's moves, prompts the player to select a move, validates the selection, and returns the selected move.- Parameters:
attacker
- The attacking Pokémon.defender
- The defending Pokémon.- Returns:
- The selected move if valid, null if the player chooses to skip the attack.
-
calculateMoveDamage
Calculates the move's damage based on the move's base damage and the defender's weakness/resistance to the attacker's type.- Parameters:
move
- The move being used by the attacker.attacker
- The attacking Pokémon.defender
- The defending Pokémon.- Returns:
- The final damage value to be applied to the defender's HP (0 if negative after resistance calculation).
-
applyMoveDamage
Applies the move's damage to the defender's HP and checks if the defender is knocked out. Displays the damage dealt and the defender's remaining HP. If the defender's HP is less than or equal to 0 (i.e., knocked out), return true to indicate a knockout, otherwise return false.- Parameters:
damage
- The damage to be applied to the defender's HP.attacker
- The attacking Pokémon.defender
- The defending Pokémon.- Returns:
- True if the defender is knocked out, false otherwise.
-