From 7cc2352b90bb768547ab09bb3b88b0e9b717d914 Mon Sep 17 00:00:00 2001 From: RaffaeleMorganti Date: Wed, 16 Nov 2022 17:35:32 +0100 Subject: [PATCH] command --- .../java/com/github/dtschust/zork/ZorkCommand.java | 6 +++++- .../com/github/dtschust/zork/parser/ZorkReader.java | 12 ++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/dtschust/zork/ZorkCommand.java b/src/main/java/com/github/dtschust/zork/ZorkCommand.java index 7321b59..c092c2a 100644 --- a/src/main/java/com/github/dtschust/zork/ZorkCommand.java +++ b/src/main/java/com/github/dtschust/zork/ZorkCommand.java @@ -2,7 +2,11 @@ package com.github.dtschust.zork; /* Special Command condition*/ public class ZorkCommand extends ZorkCondition { - public String command; + public final String command; + + public ZorkCommand(String command) { + this.command = command; + } public boolean evaluate(Zork zork) { return command.equals(zork.userInput); diff --git a/src/main/java/com/github/dtschust/zork/parser/ZorkReader.java b/src/main/java/com/github/dtschust/zork/parser/ZorkReader.java index 60815bf..987dfae 100644 --- a/src/main/java/com/github/dtschust/zork/parser/ZorkReader.java +++ b/src/main/java/com/github/dtschust/zork/parser/ZorkReader.java @@ -90,8 +90,7 @@ public class ZorkReader { NodeList commands = trigger.getElementsByTagName("command"); for (l = 0; l < commands.getLength(); l++) { Element command = (Element) commands.item(l); - ZorkCommand tempCommand = new ZorkCommand(); - tempCommand.command = getString(command); + ZorkCommand tempCommand = new ZorkCommand(getString(command)); tempTrigger.conditions.add(tempCommand); tempTrigger.hasCommand = true; } @@ -202,8 +201,7 @@ public class ZorkReader { NodeList commands = trigger.getElementsByTagName("command"); for (l = 0; l < commands.getLength(); l++) { Element command = (Element) commands.item(l); - ZorkCommand tempCommand = new ZorkCommand(); - tempCommand.command = getString(command); + ZorkCommand tempCommand = new ZorkCommand(getString(command)); tempTrigger.conditions.add(tempCommand); tempTrigger.hasCommand = true; } @@ -297,8 +295,7 @@ public class ZorkReader { NodeList commands = trigger.getElementsByTagName("command"); for (l = 0; l < commands.getLength(); l++) { Element command = (Element) commands.item(l); - ZorkCommand tempCommand = new ZorkCommand(); - tempCommand.command = getString(command); + ZorkCommand tempCommand = new ZorkCommand(getString(command)); tempTrigger.conditions.add(tempCommand); tempTrigger.hasCommand = true; } @@ -419,8 +416,7 @@ public class ZorkReader { NodeList commands = trigger.getElementsByTagName("command"); for (l = 0; l < commands.getLength(); l++) { Element command = (Element) commands.item(l); - ZorkCommand tempCommand = new ZorkCommand(); - tempCommand.command = getString(command); + ZorkCommand tempCommand = new ZorkCommand(getString(command)); tempTrigger.conditions.add(tempCommand); tempTrigger.hasCommand = true; }