mirror of
https://github.com/chase-manning/pokemon-js.git
synced 2025-08-06 02:49:12 +00:00
🐛 able to encounter trainers twice
This commit is contained in:
parent
e0c2495713
commit
060b6d97e4
1 changed files with 6 additions and 0 deletions
|
@ -21,6 +21,7 @@ import Frame from "./Frame";
|
|||
import useEvent from "../app/use-event";
|
||||
import { Event } from "../app/emitter";
|
||||
import getPokemonEncounter from "../app/pokemon-encounter-helper";
|
||||
import { showText } from "../state/uiSlice";
|
||||
|
||||
const StyledTrainerEncounter = styled.div`
|
||||
position: absolute;
|
||||
|
@ -81,6 +82,11 @@ const TrainerEncounter = () => {
|
|||
trainer.pos.y === pos.y + facingPos.y
|
||||
);
|
||||
if (!trainer) throw new Error("Trainer not found");
|
||||
const trainerId = `${mapId}-${trainer.pos.x}-${trainer.pos.y}`;
|
||||
if (defeatedTrainers.includes(trainerId)) {
|
||||
dispatch(showText(trainer.outtro));
|
||||
return;
|
||||
}
|
||||
dispatch(encounterTrainer(trainer));
|
||||
setTimeout(() => {
|
||||
setIntroIndex(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue