diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-15 01:23:36 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-15 01:23:36 +0900 |
commit | c4448fea149d2638f126813deba6406a7a15d67d (patch) | |
tree | 7701c48f47dc95644acfae4756596b6b9a089dff /src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions | |
parent | 496efb764360cd26fa40982532048aa18ae4c6be (diff) | |
download | Skyblock-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/actions')
8 files changed, 17 insertions, 8 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); |