This repository contains a simulation of Pokémon battles implemented in TypeScript. The system models Pokémon, Trainers, Pokéballs, and the battle mechanics between Pokémon.
- Pokemon Class: Represents a Pokémon with attributes such as
name,hitPoints,attackDamage,move, andtype. Methods includetakeDamage,useMove,hasFainted,isEffectiveAgainst, andisWeakTo. - Pokeball Class: Handles capturing and releasing Pokémon. It can check if it is empty and contains a Pokémon.
- Trainer Class: Manages a collection of up to 6 Pokéballs. Trainers can catch Pokémon and retrieve them from their Pokéballs.
- Battle Class: Simulates a battle between two Pokémon, calculating damage based on type effectiveness and switching turns between attackers.
- Constructor:
constructor(name: string, type: PokemonType = 'normal') - Methods:
takeDamage(damageAmount: number),useMove(),hasFainted(),isEffectiveAgainst(pokemon: Pokemon),isWeakTo(pokemon: Pokemon)
- Constructor:
constructor() - Methods:
isEmpty(),contains(),throw(pokemon?: Pokemon)
- Constructor:
constructor(name: string) - Methods:
catch(pokemon: Pokemon),getPokemon(pokemon: Pokemon)
- Constructor:
constructor(battler1: TrainerAndPokemon, battler2: TrainerAndPokemon) - Methods:
calculateDamage(),switchTurns(),fight()
- Create Pokémon: Instantiate Pokémon with their specific types and moves.
- Create Trainers: Instantiate Trainers and use their
catchmethod to capture Pokémon. - Initiate a Battle: Create a
Battleinstance with twoTrainerAndPokemonobjects and call thefightmethod to start the battle.