Skip to content

Commit 9b3d06b

Browse files
committed
version 1.0.0
1 parent e36f897 commit 9b3d06b

3 files changed

Lines changed: 56 additions & 58 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.urfour.artemis</groupId>
77
<artifactId>ArtemisTheSpire</artifactId>
8-
<version>0.1</version>
8+
<version>1.0.0</version>
99
<packaging>jar</packaging>
1010
<name>ArtemisTheSpire</name>
1111
<description>Game State Integration for Artemis RGB</description>

src/main/java/com/urfour/artemis/GameStateConverter.java

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.megacrit.cardcrawl.cards.AbstractCard;
77
import com.megacrit.cardcrawl.characters.AbstractPlayer;
88
import com.megacrit.cardcrawl.core.AbstractCreature;
9+
import com.megacrit.cardcrawl.core.CardCrawlGame;
910
import com.megacrit.cardcrawl.core.Settings;
1011
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
1112
import com.megacrit.cardcrawl.events.AbstractEvent;
@@ -47,14 +48,7 @@ public class GameStateConverter {
4748
* @return A string containing the JSON representation of CommunicationMod's status
4849
*/
4950
public static String getCommunicationState() {
50-
HashMap<String, Object> response = new HashMap<>();
51-
response.put("AvailableCommands", CommandExecutor.getAvailableCommands());
52-
response.put("ReadyForCommand", GameStateListener.isWaitingForCommand());
53-
boolean isInGame = CommandExecutor.isInDungeon();
54-
response.put("InGame", isInGame);
55-
if(isInGame) {
56-
response.put("GameState", getGameState());
57-
}
51+
HashMap<String, Object> response = getGameState();
5852
Gson gson = new Gson();
5953
return gson.toJson(response);
6054
}
@@ -63,6 +57,7 @@ public static String getCommunicationState() {
6357
/**
6458
* Creates a JSON representation of the game state, which will be sent to the client.
6559
* Always present:
60+
* - "in_game" (boolean): True if in the main menu, False if the player is in the dungeon
6661
* - "screen_name" (string): The name of the Enum representing the current screen (defined by Mega Crit)
6762
* - "is_screen_up" (boolean): The game's isScreenUp variable
6863
* - "screen_type" (string): The type of screen (or decision) that the user if facing (defined by Communication Mod)
@@ -92,62 +87,64 @@ public static String getCommunicationState() {
9287
*/
9388
private static HashMap<String, Object> getGameState() {
9489
HashMap<String, Object> state = new HashMap<>();
90+
boolean inGame = CardCrawlGame.mode == CardCrawlGame.GameMode.GAMEPLAY && AbstractDungeon.isPlayerInDungeon() && AbstractDungeon.currMapNode != null;
91+
state.put("InGame", inGame);
92+
if (inGame) {
93+
state.put("ScreenName", AbstractDungeon.screen.name());
94+
state.put("IsScreenUp", AbstractDungeon.isScreenUp);
95+
state.put("ScreenType", ChoiceScreenUtils.getCurrentChoiceType());
96+
state.put("RoomPhase", AbstractDungeon.getCurrRoom().phase.toString());
97+
state.put("ActionPhase", AbstractDungeon.actionManager.phase.toString());
98+
if (AbstractDungeon.actionManager.currentAction != null) {
99+
state.put("CurrentAction", AbstractDungeon.actionManager.currentAction.getClass().getSimpleName());
100+
}
101+
state.put("RoomType", AbstractDungeon.getCurrRoom().getClass().getSimpleName());
102+
state.put("CurrentHP", AbstractDungeon.player.currentHealth);
103+
state.put("MaxHP", AbstractDungeon.player.maxHealth);
104+
state.put("Floor", AbstractDungeon.floorNum);
105+
state.put("Act", AbstractDungeon.actNum);
106+
state.put("ActBoss", AbstractDungeon.bossKey);
107+
state.put("Gold", AbstractDungeon.player.gold);
108+
state.put("Seed", Settings.seed);
109+
state.put("Class", AbstractDungeon.player.chosenClass.name());
110+
state.put("AscensionLevel", AbstractDungeon.ascensionLevel);
111+
112+
ArrayList<Object> relics = new ArrayList<>();
113+
for (AbstractRelic relic : AbstractDungeon.player.relics) {
114+
relics.add(convertRelicToJson(relic));
115+
}
95116

96-
state.put("ScreenName", AbstractDungeon.screen.name());
97-
state.put("IsScreenUp", AbstractDungeon.isScreenUp);
98-
state.put("ScreenType", ChoiceScreenUtils.getCurrentChoiceType());
99-
state.put("RoomPhase", AbstractDungeon.getCurrRoom().phase.toString());
100-
state.put("ActionPhase", AbstractDungeon.actionManager.phase.toString());
101-
if(AbstractDungeon.actionManager.currentAction != null) {
102-
state.put("CurrentAction", AbstractDungeon.actionManager.currentAction.getClass().getSimpleName());
103-
}
104-
state.put("RoomType", AbstractDungeon.getCurrRoom().getClass().getSimpleName());
105-
state.put("CurrentHP", AbstractDungeon.player.currentHealth);
106-
state.put("MaxHP", AbstractDungeon.player.maxHealth);
107-
state.put("Floor", AbstractDungeon.floorNum);
108-
state.put("Act", AbstractDungeon.actNum);
109-
state.put("ActBoss", AbstractDungeon.bossKey);
110-
state.put("Gold", AbstractDungeon.player.gold);
111-
state.put("Seed", Settings.seed);
112-
state.put("Class", AbstractDungeon.player.chosenClass.name());
113-
state.put("AscensionLevel", AbstractDungeon.ascensionLevel);
114-
115-
ArrayList<Object> relics = new ArrayList<>();
116-
for(AbstractRelic relic : AbstractDungeon.player.relics) {
117-
relics.add(convertRelicToJson(relic));
118-
}
117+
state.put("Relics", relics);
119118

120-
state.put("Relics", relics);
119+
ArrayList<Object> deck = new ArrayList<>();
120+
for (AbstractCard card : AbstractDungeon.player.masterDeck.group) {
121+
deck.add(convertCardToJson(card));
122+
}
121123

122-
ArrayList<Object> deck = new ArrayList<>();
123-
for(AbstractCard card : AbstractDungeon.player.masterDeck.group) {
124-
deck.add(convertCardToJson(card));
125-
}
124+
state.put("Deck", deck);
126125

127-
state.put("Deck", deck);
126+
ArrayList<Object> potions = new ArrayList<>();
127+
for (AbstractPotion potion : AbstractDungeon.player.potions) {
128+
potions.add(convertPotionToJson(potion));
129+
}
128130

129-
ArrayList<Object> potions = new ArrayList<>();
130-
for(AbstractPotion potion : AbstractDungeon.player.potions) {
131-
potions.add(convertPotionToJson(potion));
132-
}
131+
state.put("Potions", potions);
133132

134-
state.put("Potions", potions);
133+
state.put("Map", convertMapToJson());
134+
if (CommandExecutor.isChooseCommandAvailable()) {
135+
state.put("ChoiceList", ChoiceScreenUtils.getCurrentChoiceList());
136+
}
137+
if (AbstractDungeon.getCurrRoom().phase.equals(AbstractRoom.RoomPhase.COMBAT)) {
138+
state.put("CombatState", getCombatState());
139+
}
140+
state.put("ScreenState", getScreenState());
135141

136-
state.put("Map", convertMapToJson());
137-
if(CommandExecutor.isChooseCommandAvailable()) {
138-
state.put("ChoiceList", ChoiceScreenUtils.getCurrentChoiceList());
139-
}
140-
if(AbstractDungeon.getCurrRoom().phase.equals(AbstractRoom.RoomPhase.COMBAT)) {
141-
state.put("CombatState", getCombatState());
142+
HashMap<String, Boolean> keys = new HashMap<>();
143+
keys.put("Ruby", Settings.hasRubyKey);
144+
keys.put("Emerald", Settings.hasEmeraldKey);
145+
keys.put("Sapphire", Settings.hasSapphireKey);
146+
state.put("Keys", keys);
142147
}
143-
state.put("ScreenState", getScreenState());
144-
145-
HashMap<String, Boolean> keys = new HashMap<>();
146-
keys.put("Ruby", Settings.hasRubyKey);
147-
keys.put("Emerald", Settings.hasEmeraldKey);
148-
keys.put("Sapphire", Settings.hasSapphireKey);
149-
state.put("Keys", keys);
150-
151148
return state;
152149
}
153150

src/main/resources/ModTheSpire.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"modid": "${project.artifactId}",
33
"name": "${project.name}",
44
"author_list": ["urfour"],
5+
"credits": "ForgottenArbiter - Creator of CommunicationMod, inspiration for this mod",
56
"description": "${project.description}",
6-
"version": "0.1.0",
7+
"version": "${project.version}",
78
"sts_version": "12-18-2022",
89
"mts_version": "3.30.3",
910
"dependencies": ["basemod"]

0 commit comments

Comments
 (0)