Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #59 from mtricht/add-map-mods
Browse files Browse the repository at this point in the history
Add elemental ailment and posion, blind & bleeding map mods.
  • Loading branch information
mtricht authored Mar 7, 2020
2 parents 834627e + e0c5552 commit 9a111ff
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class MapInfoListener implements GameListener {
private Pattern elementalAffix = Pattern.compile("(?i:Monsters reflect .*% of Elemental Damage)");
private Pattern physicalAffix = Pattern.compile("(?i:Monsters reflect .*% of Physical Damage)");
private Pattern recoveryAffix = Pattern.compile("(?i:Players have .*% less Recovery Rate of Life and Energy Shield)");
private Pattern ailmentAffix = Pattern.compile("(?i:Monsters have .*% chance to Avoid Elemental Ailments)");
private Pattern poisonAffix = Pattern.compile("(?i:Monsters have .*% chance to avoid Poison, Blind, and Bleeding)");

public MapInfoListener() {
this.mapInfoResolver = new MapInfoResolver();
Expand Down Expand Up @@ -108,6 +110,12 @@ private List<String> getMapModWarnings(Item item) {
if (recoveryAffix.matcher(affix).matches() && isModWarningEnabled("low_recovery")) {
warnings.add("Less recovery of Life and ES");
}
if (ailmentAffix.matcher(affix).matches() && isModWarningEnabled("avoidElementalAilments")) {
warnings.add("Avoid elemental ailments");
}
if (poisonAffix.matcher(affix).matches() && isModWarningEnabled("avoidPoisonBlindAndBleeding")) {
warnings.add("Avoid poison, blind and bleeding");
}
}
if (damageMods >= 2 && isModWarningEnabled("multi_dmg")) {
warnings.add(String.format("Multi (%d) extra damage", damageMods));
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/dev/tricht/lunaris/settings/game/MapModsGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class MapModsGUI implements Initializable {
private CheckBox multiDmgModWarning;
@FXML
private CheckBox tempChainsModWarning;
@FXML
private CheckBox avoidElementalAilments;
@FXML
private CheckBox avoidPoisonBlindAndBleeding;

private HashMap<CheckBox, String> propertyMap;

Expand Down Expand Up @@ -58,6 +62,12 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
if (!PropertiesManager.containsKey("map_mod_warnings.low_recovery")) {
PropertiesManager.writeProperty("map_mod_warnings.low_recovery", "1");
}
if (!PropertiesManager.containsKey("map_mod_warnings.avoid_elemental_ailments")) {
PropertiesManager.writeProperty("map_mod_warnings.avoid_elemental_ailments", "0");
}
if (!PropertiesManager.containsKey("map_mod_warnings.avoid_poison_blind_and_bleed")) {
PropertiesManager.writeProperty("map_mod_warnings.avoid_poison_blind_and_bleed", "0");
}

propertyMap.put(eleReflModWarning, "map_mod_warnings.ele_refl");
propertyMap.put(physReflModWarning, "map_mod_warnings.phys_refl");
Expand All @@ -66,6 +76,8 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
propertyMap.put(multiDmgModWarning, "map_mod_warnings.multi_dmg");
propertyMap.put(tempChainsModWarning, "map_mod_warnings.tmp_chains");
propertyMap.put(lowRecoveryModWarning, "map_mod_warnings.low_recovery");
propertyMap.put(avoidElementalAilments, "map_mod_warnings.avoid_elemental_ailments");
propertyMap.put(avoidPoisonBlindAndBleeding, "map_mod_warnings.avoid_poison_blind_and_bleed");


for (Map.Entry<CheckBox, String> entry :propertyMap.entrySet()) {
Expand All @@ -76,7 +88,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {

public void toggleCheckbox(ActionEvent actionEvent) {
CheckBox source = (CheckBox) actionEvent.getSource();
if(!propertyMap.containsKey(source)) {
if (!propertyMap.containsKey(source)) {
return;
}
PropertiesManager.writeProperty(propertyMap.get(source), source.isSelected() ? "1" : "0");
Expand Down
17 changes: 11 additions & 6 deletions src/main/resources/settings/game/map_mods.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<CheckBox fx:id="eleReflModWarning" mnemonicParsing="false" onAction="#toggleCheckbox" text="Elemental reflect" GridPane.rowIndex="0" />
Expand All @@ -36,6 +39,8 @@
<CheckBox fx:id="multiDmgModWarning" mnemonicParsing="false" onAction="#toggleCheckbox" text="Multi damage" GridPane.rowIndex="4" />
<CheckBox fx:id="tempChainsModWarning" mnemonicParsing="false" onAction="#toggleCheckbox" text="Temporal Chains" GridPane.rowIndex="5" />
<CheckBox fx:id="lowRecoveryModWarning" mnemonicParsing="false" onAction="#toggleCheckbox" text="Low recovery" GridPane.rowIndex="6" />
<CheckBox fx:id="avoidElementalAilments" mnemonicParsing="false" onAction="#toggleCheckbox" text="Avoid elemental ailments" GridPane.rowIndex="7" />
<CheckBox fx:id="avoidPoisonBlindAndBleeding" mnemonicParsing="false" onAction="#toggleCheckbox" text="Avoid Poison, blind and bleeding" GridPane.rowIndex="8" />
</children>
</GridPane>
</children>
Expand Down

0 comments on commit 9a111ff

Please sign in to comment.