From a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sun, 17 Jan 2021 13:53:57 +0900 Subject: bossfight processor --- .../bossfight/BossfightProcessor.java | 10 +++ .../bossfight/GeneralBossfightProcessor.java | 71 ++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomprocessor') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java new file mode 100644 index 00000000..c893258e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java @@ -0,0 +1,10 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; + +import java.util.List; + +public interface BossfightProcessor extends RoomProcessor { + List getPhases(); + String getCurrentPhase(); +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java new file mode 100644 index 00000000..4fa60623 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java @@ -0,0 +1,71 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; + +import lombok.Builder; +import lombok.Data; +import net.minecraft.util.IChatComponent; + +import java.util.*; + +public class GeneralBossfightProcessor implements BossfightProcessor { + private Map phases = new HashMap(); + private PhaseData currentPhase = null; + + public void addPhase(PhaseData phaseData) { + if (phaseData == null) return; + if (currentPhase == null) currentPhase = phaseData; + phases.put(phaseData.getPhase(), phaseData); + } + + @Override + public List getPhases() { + List phases = new ArrayList(); + for (PhaseData pd:this.phases.values()) + phases.add(pd.getPhase()); + return phases; + } + + @Override + public String getCurrentPhase() { + return currentPhase == null ? "unknown" : currentPhase.getPhase(); + } + + @Override + public void chatReceived(IChatComponent chat) { + if (currentPhase == null) return; + + for (String nextPhase : currentPhase.getNextPhases()) { + PhaseData phaseData = phases.get(nextPhase); + if (phaseData == null) continue; + if (phaseData.signatureMsg.contains(chat.getFormattedText())) { + currentPhase = phaseData; + onPhaseChange(); + return; + } + } + } + + @Override + public void actionbarReceived(IChatComponent chat) {} + + @Override + public void tick() {} + + @Override + public void drawScreen(float partialTicks) {} + + @Override + public void drawWorld(float partialTicks) {} + + @Override + public boolean readGlobalChat() {return true;} + + public void onPhaseChange() {} + + @Data + @Builder + public static class PhaseData { + private String phase; + private Set signatureMsg; + private Set nextPhases; + } +} -- cgit