From d83205ee2bf37e51927fc9b29c3dceda4a887532 Mon Sep 17 00:00:00 2001 From: OutOfBrain Date: Sun, 29 Sep 2024 15:34:53 +0200 Subject: [PATCH] add emerald key node information to map state screen This way we can react on the flame-elite to chase the emerald key --- .../communicationmod/ChoiceScreenUtils.java | 18 ++++++++++++++++++ .../communicationmod/GameStateConverter.java | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/communicationmod/ChoiceScreenUtils.java b/src/main/java/communicationmod/ChoiceScreenUtils.java index f323320..f9a648d 100644 --- a/src/main/java/communicationmod/ChoiceScreenUtils.java +++ b/src/main/java/communicationmod/ChoiceScreenUtils.java @@ -683,6 +683,24 @@ public static boolean bossNodeAvailable() { return (currMapNode.y == 14 || (AbstractDungeon.id.equals(TheEnding.ID) && currMapNode.y == 2)); } + /** + * Return the room with the emeraldKey containing a "flame elite". + * @return MapRoomNode|null The map screen state object + */ + public static MapRoomNode findEmeraldKeyNode() { + ArrayList> map = AbstractDungeon.map; + + for (ArrayList layer : map) { + for (MapRoomNode node : layer) { + if (node.hasEmeraldKey) { + return node; + } + } + } + + return null; + } + public static ArrayList getMapScreenChoices() { ArrayList choices = new ArrayList<>(); MapRoomNode currMapNode = AbstractDungeon.getCurrMapNode(); diff --git a/src/main/java/communicationmod/GameStateConverter.java b/src/main/java/communicationmod/GameStateConverter.java index 87ccdca..d152662 100644 --- a/src/main/java/communicationmod/GameStateConverter.java +++ b/src/main/java/communicationmod/GameStateConverter.java @@ -299,6 +299,7 @@ private static HashMap getCombatRewardState() { /** * The map screen state object contains: * "current_node" (object): The node object for the currently selected node, if applicable + * "emerald_key_node" (object): The node object for the emerald key node, if available * "next_nodes" (list): A list of nodes that can be chosen next * "first_node_chosen" (boolean): Whether the first node in the act has already been chosen * "boss_available" (boolean): Whether the next node choice is a boss @@ -309,6 +310,10 @@ private static HashMap getMapScreenState() { if (AbstractDungeon.getCurrMapNode() != null) { state.put("current_node", convertMapRoomNodeToJson(AbstractDungeon.getCurrMapNode())); } + final MapRoomNode emeraldKeyNode = ChoiceScreenUtils.findEmeraldKeyNode(); + if (emeraldKeyNode != null) { + state.put("emerald_key_node", convertMapRoomNodeToJson(emeraldKeyNode)); + } ArrayList nextNodesJson = new ArrayList<>(); for(MapRoomNode node : ChoiceScreenUtils.getMapScreenNodeChoices()) { nextNodesJson.add(convertMapRoomNodeToJson(node));