Build a pokemon battle where two pokemon battle each other as shown in the video below.
This repository is setup with typescript and ava.
Install all dependencies ready to go with:
npm i
npm run test
npm run test:watch
Mac
open ./coverage/lcov-report/index.html
Linux
xdg-open ./coverage/lcov-report/index.html
{
name: 'Bulbasaur',
type: 'GRASS',
level: 5,
hp: 21,
stats: {
attack: 11,
defense: 11,
speed: 11,
},
moves: [{
name: 'Tackle',
power: 40,
type: 'NORMAL'
}, {
name: 'Growl',
type: 'NORMAL'
}]
}
{
name: 'Charmander',
type: 'FIRE',
level: 5,
hp: 20,
stats: {
attack: 11,
defense: 10,
speed: 13,
},
moves: [{
name: 'Scratch',
power: 40,
type: 'NORMAL'
}, {
name: 'Leer',
type: 'NORMAL'
}]
}
When a pokemon uses a move that has power
then the damage should be calculated and the resulting value should be decremented from the defending pokemons hp
If a pokemons hp
attribute drops to zero or below it loses the battle.
- Power is the attacking pokemons moves
power
- A is the attacking pokemons
attack
- D is the defenmding pokemons
defense
- Modifier for this example will always be
0.1
Damage should be an integer not a float.
Growl
and Leer
can reduce the opposing pokemons stats within the current battle.
Growl
affects the defense
stat.
Leer
affects the attack
stat.
Stats can only be decreased a maximum of 6 stages.
Stage | % Of Base Stat |
---|---|
0 | 100% |
-1 | 67% |
-2 | 50% |
-3 | 40% |
-4 | 33% |
-5 | 29% |
-6 | 25% |