mirror of
https://github.com/chase-manning/pokemon-js.git
synced 2025-08-03 17:49:12 +00:00
🚀 don't set fainted pokemon as first active
This commit is contained in:
parent
dc0943fd92
commit
1f98c5d3a1
3 changed files with 15 additions and 3 deletions
4
TODO.md
4
TODO.md
|
@ -1,6 +1,6 @@
|
|||
===========
|
||||
|
||||
- If first pokemon is fainted, don't set that one as active by default
|
||||
- What happens if user saves within battle
|
||||
- Learning new moves on level up
|
||||
- Split out Pokemon Encounter into separate components or handlers
|
||||
- Add support for healing your pokemon at healing place
|
||||
|
@ -12,7 +12,7 @@
|
|||
- Fix these boolean props console errors, add `$`
|
||||
- Give enemy attack when switching pokemon
|
||||
- bug: Can move encounter menu while start menu is open
|
||||
- Attack sounds
|
||||
- battle sounds
|
||||
- Encounter frequency seems off
|
||||
- Implement one way walls (and add to route 1)
|
||||
- Change Menu to use new Arrow component
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
PokemonInstance,
|
||||
endEncounter,
|
||||
recoverFromFainting,
|
||||
resetActivePokemon,
|
||||
selectActivePokemon,
|
||||
selectName,
|
||||
selectPokemon,
|
||||
|
@ -525,7 +526,7 @@ const PokemonEncounter = () => {
|
|||
|
||||
const endEncounter_ = () => {
|
||||
dispatch(endEncounter());
|
||||
dispatch(setActivePokemon(0));
|
||||
dispatch(resetActivePokemon());
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -261,6 +261,16 @@ export const gameSlice = createSlice({
|
|||
state.map = map;
|
||||
state.pos = pos;
|
||||
},
|
||||
resetActivePokemon: (state) => {
|
||||
let fistIndexWithHp = 0;
|
||||
for (let i = 0; i < state.pokemon.length; i++) {
|
||||
if (state.pokemon[i].hp > 0) {
|
||||
fistIndexWithHp = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
state.activePokemonIndex = fistIndexWithHp;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -285,6 +295,7 @@ export const {
|
|||
updatePokemonEncounter,
|
||||
updatePokemon,
|
||||
recoverFromFainting,
|
||||
resetActivePokemon,
|
||||
} = gameSlice.actions;
|
||||
|
||||
export const selectPos = (state: RootState) => state.game.pos;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue