aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-15 01:23:36 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-15 01:23:36 +0900
commitc4448fea149d2638f126813deba6406a7a15d67d (patch)
tree7701c48f47dc95644acfae4756596b6b9a089dff /src/main/java/kr/syeyoung/dungeonsguide/dungeon
parent496efb764360cd26fa40982532048aa18ae4c6be (diff)
downloadSkyblock-Dungeons-Guide-c4448fea149d2638f126813deba6406a7a15d67d.tar.gz
Skyblock-Dungeons-Guide-c4448fea149d2638f126813deba6406a7a15d67d.tar.bz2
Skyblock-Dungeons-Guide-c4448fea149d2638f126813deba6406a7a15d67d.zip
predicate equals and more edits
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java21
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java3
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateBat.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateSuperBoom.java5
18 files changed, 51 insertions, 14 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java
index b17625d7..9aeac9e8 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java
@@ -1,5 +1,6 @@
package kr.syeyoung.dungeonsguide.dungeon.actions;
+import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import lombok.Data;
@@ -22,11 +23,13 @@ public class ActionChangeState implements Action{
public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) {
Set<Action> set = new HashSet<Action>();
set.addAll(preRequisite2);
- set.addAll(dungeonRoom.getDungeonRoomInfo().getMechanics().get(mechanicName).getAction(state, dungeonRoom));
+ DungeonMechanic mechanic = dungeonRoom.getDungeonRoomInfo().getMechanics().get(mechanicName);
+ if (mechanic!= null)
+ set.addAll(mechanic.getAction(state, dungeonRoom));
return set;
}
@Override
public String toString() {
- return "ChangeState\n\ttarget: "+mechanicName+"\n\tstate: "+state;
+ return "ChangeState\n- target: "+mechanicName+"\n- state: "+state;
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java
index 13e4ee76..b3a4cc92 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java
@@ -27,6 +27,6 @@ public class ActionClick implements Action {
@Override
public String toString() {
- return "Click\n\ttarget: "+target.toString()+"\n\tpredicate: "+predicate.getClass().getSimpleName();
+ return "Click\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName();
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
index 454bfad3..595e66c7 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
@@ -27,6 +27,6 @@ public class ActionClickSet implements Action {
@Override
public String toString() {
- return "ClickSet\n\ttargets size: "+target.getOffsetPointList().size()+"\n\tpredicate: "+predicate.getClass().getSimpleName();
+ return "ClickSet\n- targets size: "+target.getOffsetPointList().size()+"\n- predicate: "+predicate.getClass().getSimpleName();
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java
index ad2eb5e2..151fe96c 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java
@@ -27,6 +27,6 @@ public class ActionDropItem implements Action {
@Override
public String toString() {
- return "DropItem\n\ttarget: "+target.toString()+"\n\tpredicate: "+predicate.getClass().getSimpleName();
+ return "DropItem\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName();
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java
index 162d0345..e1eba8b7 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java
@@ -27,6 +27,6 @@ public class ActionKill implements Action {
@Override
public String toString() {
- return "KillEntity\n\ttarget: "+target.toString()+"\n\tradius: "+radius+"\n\tpredicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName());
+ return "KillEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName());
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java
index 15bc9814..a2aee8da 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java
@@ -24,6 +24,6 @@ public class ActionMove implements Action {
@Override
public String toString() {
- return "Move\n\ttarget: "+target.toString();
+ return "Move\n- target: "+target.toString();
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java
index 3e3f3016..91bd79e7 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java
@@ -23,6 +23,6 @@ public class ActionMoveNearestAir implements Action {
@Override
public String toString() {
- return "MoveNearestAir\n\ttarget: "+target.toString();
+ return "MoveNearestAir\n- target: "+target.toString();
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java
index 1db6767c..334f7c2b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java
@@ -4,6 +4,7 @@ import kr.syeyoung.dungeonsguide.dungeon.actions.Action;
import kr.syeyoung.dungeonsguide.dungeon.actions.ActionRoot;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import lombok.Data;
+import lombok.EqualsAndHashCode;
import java.util.HashMap;
import java.util.HashSet;
@@ -12,10 +13,14 @@ import java.util.Set;
@Data
public class ActionTree {
+ @EqualsAndHashCode.Exclude
private ActionTree parent;
private Action current;
private Set<ActionTree> children;
+ @Override
+ public int hashCode() { return current == null ? 0 : current.hashCode(); }
+
public static ActionTree buildActionTree(Set<Action> actions, DungeonRoom dungeonRoom) {
ActionRoot root = new ActionRoot();
@@ -31,6 +36,7 @@ public class ActionTree {
return tree;
}
+
private static ActionTree buildActionTree(ActionTree parent, Action action, DungeonRoom dungeonRoom, Map<Action, ActionTree> alreadyBuilt) {
if (action == null) return null;
if (alreadyBuilt.containsKey(action)) return alreadyBuilt.get(action);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java
index fe89b7cb..701f9a4a 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java
@@ -45,6 +45,7 @@ public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker {
}
{
for (String str : preRequisite) {
+ if (str.isEmpty()) continue;
ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
preRequisites.add(actionChangeState);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java
index cbf7520f..d496b450 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java
@@ -20,7 +20,8 @@ import java.util.*;
@Data
public class DungeonDoor implements DungeonMechanic, RouteBlocker {
private OffsetPointSet secretPoint = new OffsetPointSet();
- private List<String> preRequisite = new ArrayList<String>();
+ private List<String> openPreRequisite = new ArrayList<String>();
+ private List<String> closePreRequisite = new ArrayList<String>();
@Override
@@ -43,9 +44,18 @@ public class DungeonDoor implements DungeonMechanic, RouteBlocker {
preRequisites = actionMove.getPreRequisite();
}
{
- for (String str : preRequisite) {
- ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
- preRequisites.add(actionChangeState);
+ if (state.equalsIgnoreCase("open")) {
+ for (String str : openPreRequisite) {
+ if (str.isEmpty()) continue;
+ ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
+ preRequisites.add(actionChangeState);
+ }
+ } else {
+ for (String str : closePreRequisite) {
+ if (str.isEmpty()) continue;
+ ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
+ preRequisites.add(actionChangeState);
+ }
}
}
return base;
@@ -75,7 +85,8 @@ public class DungeonDoor implements DungeonMechanic, RouteBlocker {
public DungeonDoor clone() throws CloneNotSupportedException {
DungeonDoor dungeonSecret = new DungeonDoor();
dungeonSecret.secretPoint = (OffsetPointSet) secretPoint.clone();
- dungeonSecret.preRequisite = new ArrayList<String>(preRequisite);
+ dungeonSecret.openPreRequisite = new ArrayList<String>(openPreRequisite);
+ dungeonSecret.closePreRequisite = new ArrayList<String>(closePreRequisite);
return dungeonSecret;
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java
index 9fe0165f..01b3323e 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java
@@ -37,6 +37,7 @@ public class DungeonLever implements DungeonMechanic {
}
{
for (String str : preRequisite) {
+ if (str.isEmpty()) continue;
ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
preRequisites.add(actionChangeState);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java
index 3ee41f1b..9027f0dc 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java
@@ -44,6 +44,7 @@ public class DungeonOnewayDoor implements DungeonMechanic, RouteBlocker {
}
{
for (String str : preRequisite) {
+ if (str.isEmpty()) continue;
ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
preRequisites.add(actionChangeState);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java
index d9b396f0..a1500fa7 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java
@@ -22,7 +22,7 @@ public class DungeonOnewayLever implements DungeonMechanic {
@Override
public Set<Action> getAction(String state, DungeonRoom dungeonRoom) {
- if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret");
+ if (!("triggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret");
Set<Action> base;
Set<Action> preRequisites = base = new HashSet<Action>();
{
@@ -37,6 +37,7 @@ public class DungeonOnewayLever implements DungeonMechanic {
}
{
for (String str : preRequisite) {
+ if (str.isEmpty()) continue;
ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
preRequisites.add(actionChangeState);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java
index da126215..ab33a5db 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java
@@ -39,6 +39,7 @@ public class DungeonPressurePlate implements DungeonMechanic {
}
{
for (String str : preRequisite) {
+ if (str.isEmpty()) continue;
ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
preRequisites.add(actionChangeState);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java
index e5b8d54a..91ede235 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java
@@ -64,6 +64,7 @@ public class DungeonSecret implements DungeonMechanic {
}
{
for (String str : preRequisite) {
+ if (str.isEmpty()) continue;
ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
preRequisites.add(actionChangeState);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java
index ce74e955..86c6a818 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java
@@ -45,6 +45,7 @@ public class DungeonTomb implements DungeonMechanic, RouteBlocker {
}
{
for (String str : preRequisite) {
+ if (str.isEmpty()) continue;
ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
preRequisites.add(actionChangeState);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateBat.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateBat.java
index 136efd0e..5eb38597 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateBat.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateBat.java
@@ -14,4 +14,9 @@ public class PredicateBat implements Predicate<Entity> {
public boolean apply(@Nullable Entity input) {
return input instanceof EntityBat;
}
+
+ @Override
+ public boolean equals(Object o) {
+ return o == this || o != null && (o.getClass() == this.getClass());
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateSuperBoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateSuperBoom.java
index ccc1b017..6054c268 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateSuperBoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateSuperBoom.java
@@ -12,4 +12,9 @@ public class PredicateSuperBoom implements Predicate<ItemStack> {
public boolean apply(@Nullable ItemStack input) {
return false;
}
+
+ @Override
+ public boolean equals(Object o) {
+ return o == this || o != null && (o.getClass() == this.getClass());
+ }
}