diff options
author | syeyoung <cyong06@naver.com> | 2021-01-17 13:53:57 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-17 13:53:57 +0900 |
commit | a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8 (patch) | |
tree | 530ced631575eb91a270a421f3e305a21322be9d /src/main/java/kr/syeyoung/dungeonsguide/roomprocessor | |
parent | abd7802a7b07224c0367e64b40f92fe80d284520 (diff) | |
download | Skyblock-Dungeons-Guide-a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8.tar.gz Skyblock-Dungeons-Guide-a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8.tar.bz2 Skyblock-Dungeons-Guide-a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8.zip |
bossfight processor
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomprocessor')
2 files changed, 81 insertions, 0 deletions
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<String> 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<String, PhaseData> phases = new HashMap<String, PhaseData>(); + 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<String> getPhases() { + List<String> phases = new ArrayList<String>(); + 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<String> signatureMsg; + private Set<String> nextPhases; + } +} |