remove duplicate operation on trigger
This commit is contained in:
parent
5d098bf32d
commit
2e12ab7f1f
1 changed files with 13 additions and 83 deletions
|
@ -430,22 +430,7 @@ public class Zork {
|
|||
private boolean doTriggersContainersInRoom() {
|
||||
boolean skip = false;
|
||||
for (String key : game.Rooms.get(currentRoom).container.keySet()) {
|
||||
ZorkContainer tempContainer = game.Containers.get(key);
|
||||
for (int x = 0; x < tempContainer.trigger.size(); x++) {
|
||||
ZorkTrigger tempTrigger = tempContainer.trigger.get(x);
|
||||
if (tempTrigger.evaluate(this)) {
|
||||
for (String print: tempTrigger.print) {
|
||||
System.out.println(print);
|
||||
}
|
||||
for (String action: tempTrigger.action) {
|
||||
executeAction(action);
|
||||
}
|
||||
skip = skip || tempTrigger.hasCommand;
|
||||
if (tempTrigger.type.equals("single")) {
|
||||
tempContainer.trigger.remove(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
skip = skip || doZorkTriggers(game.Containers.get(key));
|
||||
}
|
||||
return skip;
|
||||
}
|
||||
|
@ -455,22 +440,7 @@ public class Zork {
|
|||
for (String key : game.Rooms.get(currentRoom).container.keySet()) {
|
||||
ZorkContainer tempContainer = game.Containers.get(key);
|
||||
for (String key2 : tempContainer.item.keySet()) {
|
||||
ZorkItem tempItem = game.Items.get(key2);
|
||||
for (int x = 0; x < tempItem.trigger.size(); x++) {
|
||||
ZorkTrigger tempTrigger = tempItem.trigger.get(x);
|
||||
if (tempTrigger.evaluate(this)) {
|
||||
for (String print : tempTrigger.print) {
|
||||
System.out.println(print);
|
||||
}
|
||||
for (String action : tempTrigger.action) {
|
||||
executeAction(action);
|
||||
}
|
||||
skip = skip || tempTrigger.hasCommand;
|
||||
if (tempTrigger.type.equals("single")) {
|
||||
tempItem.trigger.remove(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
skip = skip || doZorkTriggers(game.Items.get(key2));
|
||||
}
|
||||
}
|
||||
return skip;
|
||||
|
@ -479,22 +449,7 @@ public class Zork {
|
|||
private boolean doTriggersItemsInRoom() {
|
||||
boolean skip = false;
|
||||
for (String key : game.Rooms.get(currentRoom).item.keySet()) {
|
||||
ZorkItem tempItem = game.Items.get(key);
|
||||
for (int x = 0; x < tempItem.trigger.size(); x++) {
|
||||
ZorkTrigger tempTrigger = tempItem.trigger.get(x);
|
||||
if (tempTrigger.evaluate(this)) {
|
||||
for (String print: tempTrigger.print) {
|
||||
System.out.println(print);
|
||||
}
|
||||
for (String action: tempTrigger.action) {
|
||||
executeAction(action);
|
||||
}
|
||||
skip = skip || tempTrigger.hasCommand;
|
||||
if (tempTrigger.type.equals("single")) {
|
||||
tempItem.trigger.remove(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
skip = skip || doZorkTriggers(game.Items.get(key));
|
||||
}
|
||||
return skip;
|
||||
}
|
||||
|
@ -502,22 +457,7 @@ public class Zork {
|
|||
private boolean doTriggersItemsInInventory() {
|
||||
boolean skip = false;
|
||||
for (String key : game.Inventory.keySet()) {
|
||||
ZorkItem tempItem = game.Items.get(key);
|
||||
for (int x = 0; x < tempItem.trigger.size(); x++) {
|
||||
ZorkTrigger tempTrigger = tempItem.trigger.get(x);
|
||||
if (tempTrigger.evaluate(this)) {
|
||||
for (String print: tempTrigger.print) {
|
||||
System.out.println(print);
|
||||
}
|
||||
for (String action: tempTrigger.action) {
|
||||
executeAction(action);
|
||||
}
|
||||
skip = skip || tempTrigger.hasCommand;
|
||||
if (tempTrigger.type.equals("single")) {
|
||||
tempItem.trigger.remove(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
skip = skip || doZorkTriggers(game.Items.get(key));
|
||||
}
|
||||
return skip;
|
||||
}
|
||||
|
@ -525,30 +465,20 @@ public class Zork {
|
|||
private boolean doTriggersCreaturesInRoom() {
|
||||
boolean skip = false;
|
||||
for (String key : game.Rooms.get(currentRoom).creature.keySet()) {
|
||||
ZorkCreature tempCreature = game.Creatures.get(key);
|
||||
for (int x = 0; x < tempCreature.trigger.size(); x++) {
|
||||
ZorkTrigger tempTrigger = tempCreature.trigger.get(x);
|
||||
if (tempTrigger.evaluate(this)) {
|
||||
for (String print: tempTrigger.print) {
|
||||
System.out.println(print);
|
||||
}
|
||||
for (String action: tempTrigger.action) {
|
||||
executeAction(action);
|
||||
}
|
||||
skip = skip || tempTrigger.hasCommand;
|
||||
if (tempTrigger.type.equals("single")) {
|
||||
tempCreature.trigger.remove(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
skip = skip || doZorkTriggers(game.Creatures.get(key));
|
||||
}
|
||||
return skip;
|
||||
}
|
||||
|
||||
private boolean doTriggersRoom() {
|
||||
return doZorkTriggers(game.Rooms.get(currentRoom));
|
||||
}
|
||||
|
||||
|
||||
private boolean doZorkTriggers(ZorkObject zorkObject) {
|
||||
boolean skip = false;
|
||||
for (int x = 0; x < game.Rooms.get(currentRoom).trigger.size(); x++) {
|
||||
ZorkTrigger tempTrigger = game.Rooms.get(currentRoom).trigger.get(x);
|
||||
for (int x = 0; x < zorkObject.trigger.size(); x++) {
|
||||
ZorkTrigger tempTrigger = zorkObject.trigger.get(x);
|
||||
if (tempTrigger.evaluate(this)) {
|
||||
for (String print: tempTrigger.print) {
|
||||
System.out.println(print);
|
||||
|
@ -558,7 +488,7 @@ public class Zork {
|
|||
}
|
||||
skip = skip || tempTrigger.hasCommand;
|
||||
if (tempTrigger.type.equals("single")) {
|
||||
game.Rooms.get(currentRoom).trigger.remove(x);
|
||||
zorkObject.trigger.remove(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue