🐛 able to encounter trainers twice

This commit is contained in:
Chase Manning 2023-10-12 15:37:08 +01:00
commit 060b6d97e4

View file

@ -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);