This project is a Pokémon battle simulator written in TypeScript. For teaching purposes, it is a simple implementation that focuses on the logic of the battle system. It allows you to simulate battles between different Pokémon, determining the first attacker based on their type and speed, and logging the battle history.
- Simulate battles between Pokémon
- Determine the first attacker based on type and speed
- Log battle history
- Handle special type advantages (e.g., Fire vs. Plant)
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
npm install
To run the battle simulation, you can use the Battle
class. Here is an example:
import { Battle } from './src/battle/Battle'
const battle = new Battle('Pikachu', 'Charmeleon')
const result = battle.fighting()
console.log(result)
This project uses vitest
for testing. To run the tests, use the following command:
npm test
src/
: Contains the source code for the projectbattle/
: Contains the battle logicconst/
: Contains constants used in the projectpokemon/
: Contains the Pokémon class and types
test/
: Contains test files.gitignore
: Specifies files to be ignored by Giteslint.config.js
: Configuration for ESLintpackage.json
: Project metadata and dependencies