mirror of
https://github.com/chase-manning/pokemon-js.git
synced 2025-08-24 02:18:47 +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
|
- Learning new moves on level up
|
||||||
- Split out Pokemon Encounter into separate components or handlers
|
- Split out Pokemon Encounter into separate components or handlers
|
||||||
- Add support for healing your pokemon at healing place
|
- Add support for healing your pokemon at healing place
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
- Fix these boolean props console errors, add `$`
|
- Fix these boolean props console errors, add `$`
|
||||||
- Give enemy attack when switching pokemon
|
- Give enemy attack when switching pokemon
|
||||||
- bug: Can move encounter menu while start menu is open
|
- bug: Can move encounter menu while start menu is open
|
||||||
- Attack sounds
|
- battle sounds
|
||||||
- Encounter frequency seems off
|
- Encounter frequency seems off
|
||||||
- Implement one way walls (and add to route 1)
|
- Implement one way walls (and add to route 1)
|
||||||
- Change Menu to use new Arrow component
|
- Change Menu to use new Arrow component
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
PokemonInstance,
|
PokemonInstance,
|
||||||
endEncounter,
|
endEncounter,
|
||||||
recoverFromFainting,
|
recoverFromFainting,
|
||||||
|
resetActivePokemon,
|
||||||
selectActivePokemon,
|
selectActivePokemon,
|
||||||
selectName,
|
selectName,
|
||||||
selectPokemon,
|
selectPokemon,
|
||||||
|
@ -525,7 +526,7 @@ const PokemonEncounter = () => {
|
||||||
|
|
||||||
const endEncounter_ = () => {
|
const endEncounter_ = () => {
|
||||||
dispatch(endEncounter());
|
dispatch(endEncounter());
|
||||||
dispatch(setActivePokemon(0));
|
dispatch(resetActivePokemon());
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -261,6 +261,16 @@ export const gameSlice = createSlice({
|
||||||
state.map = map;
|
state.map = map;
|
||||||
state.pos = pos;
|
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,
|
updatePokemonEncounter,
|
||||||
updatePokemon,
|
updatePokemon,
|
||||||
recoverFromFainting,
|
recoverFromFainting,
|
||||||
|
resetActivePokemon,
|
||||||
} = gameSlice.actions;
|
} = gameSlice.actions;
|
||||||
|
|
||||||
export const selectPos = (state: RootState) => state.game.pos;
|
export const selectPos = (state: RootState) => state.game.pos;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue