From 060b6d97e4f1063f59ab7731a77ff5bb391ab14a Mon Sep 17 00:00:00 2001
From: Chase Manning <chase@manning.dev>
Date: Thu, 12 Oct 2023 15:37:08 +0100
Subject: [PATCH] :bug: able to encounter trainers twice

---
 src/components/TrainerEncounter.tsx | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/components/TrainerEncounter.tsx b/src/components/TrainerEncounter.tsx
index 015ccd0..b5a0140 100644
--- a/src/components/TrainerEncounter.tsx
+++ b/src/components/TrainerEncounter.tsx
@@ -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);