From 2b1dde22ebfb62612b597385e7a9f6e47146ee4f Mon Sep 17 00:00:00 2001 From: tzw0 Date: Thu, 31 Oct 2019 11:46:44 +0800 Subject: [PATCH] fix feedback --- src/main/java/commands/CommandChangeTask.java | 4 +- .../java/commands/CommandCheckObjectives.java | 2 +- src/main/java/commands/CommandMenu.java | 19 ------- src/main/java/commands/CommandShowList.java | 55 +------------------ src/main/java/commands/CommandTaskCreate.java | 3 +- src/main/java/commands/CommandTaskDelete.java | 3 +- .../java/commands/CommandTaskDeleteAll.java | 3 +- src/main/java/commands/CommandTaskEdit.java | 4 +- src/main/java/commands/CommandTaskInsert.java | 3 +- src/main/java/farmio/Level.java | 3 +- .../resources/asciiArt/ActionList/frame16.txt | 5 ++ .../resources/asciiArt/ActionList/frame21.txt | 5 ++ .../asciiArt/ConditionList/frame12.txt | 9 +++ .../asciiArt/ConditionList/frame13.txt | 9 +++ .../asciiArt/ConditionList/frame15.txt | 10 ++++ .../asciiArt/ConditionList/frame21.txt | 10 ++++ .../resources/asciiArt/MarketList/frame11.txt | 7 +++ .../resources/asciiArt/MarketList/frame12.txt | 7 +++ .../resources/asciiArt/MarketList/frame13.txt | 7 +++ .../resources/asciiArt/MarketList/frame14.txt | 7 +++ .../resources/asciiArt/MarketList/frame15.txt | 10 ++++ .../resources/asciiArt/MarketList/frame16.txt | 10 ++++ .../resources/asciiArt/MarketList/frame21.txt | 10 ++++ 23 files changed, 117 insertions(+), 88 deletions(-) delete mode 100644 src/main/java/commands/CommandMenu.java create mode 100644 src/main/resources/asciiArt/ActionList/frame16.txt create mode 100644 src/main/resources/asciiArt/ActionList/frame21.txt create mode 100644 src/main/resources/asciiArt/ConditionList/frame12.txt create mode 100644 src/main/resources/asciiArt/ConditionList/frame13.txt create mode 100644 src/main/resources/asciiArt/ConditionList/frame15.txt create mode 100644 src/main/resources/asciiArt/ConditionList/frame21.txt create mode 100644 src/main/resources/asciiArt/MarketList/frame11.txt create mode 100644 src/main/resources/asciiArt/MarketList/frame12.txt create mode 100644 src/main/resources/asciiArt/MarketList/frame13.txt create mode 100644 src/main/resources/asciiArt/MarketList/frame14.txt create mode 100644 src/main/resources/asciiArt/MarketList/frame15.txt create mode 100644 src/main/resources/asciiArt/MarketList/frame16.txt create mode 100644 src/main/resources/asciiArt/MarketList/frame21.txt diff --git a/src/main/java/commands/CommandChangeTask.java b/src/main/java/commands/CommandChangeTask.java index 287d1dafaf..46b4dfea7e 100644 --- a/src/main/java/commands/CommandChangeTask.java +++ b/src/main/java/commands/CommandChangeTask.java @@ -1,12 +1,14 @@ package commands; +import exceptions.FarmioFatalException; import farmio.Farmio; import farmio.Storage; public abstract class CommandChangeTask extends Command { - protected void saveTask(Farmio farmio) { + protected void saveTaskandResetScreen(Farmio farmio) throws FarmioFatalException { Storage storage = farmio.getStorage(); storage.storeFarmer(farmio.getFarmer()); + farmio.getSimulation().simulate(farmio.getLevel().getPath(), farmio.getLevel().getNarratives().size() - 1); } } diff --git a/src/main/java/commands/CommandCheckObjectives.java b/src/main/java/commands/CommandCheckObjectives.java index c54dfcdc2b..aa7574a3c6 100644 --- a/src/main/java/commands/CommandCheckObjectives.java +++ b/src/main/java/commands/CommandCheckObjectives.java @@ -18,7 +18,7 @@ public void execute(Farmio farmio) throws FarmioFatalException { Level.ObjectiveResult answer = farmio.getLevel().checkAnswer(farmio); //farmio.getUi().typeWriter(farmio.getLevel().getFeedback(farmio), false); // feedbacks - List feedback = farmio.getLevel().getFeedback(farmio); + List feedback = farmio.getLevel().getFeedback(farmio, answer); for (String i : feedback) { farmio.getUi().typeWriter(i,false); } diff --git a/src/main/java/commands/CommandMenu.java b/src/main/java/commands/CommandMenu.java deleted file mode 100644 index 3ae70d22f5..0000000000 --- a/src/main/java/commands/CommandMenu.java +++ /dev/null @@ -1,19 +0,0 @@ -//package commands; -// -//import exceptions.FarmioFatalException; -//import farmio.Farmio; -//import farmio.Menu; -// -//public class CommandBack extends Command { -// private String input; -// public CommandBack(String userInput) { -// input = userInput; -// } -// -// -// @Override -// public void execute(Farmio farmio) throws FarmioFatalException { -// Menu.show(farmio, true); -// // farmio.setStage(Farmio.Stage.MENU); -// } -//} diff --git a/src/main/java/commands/CommandShowList.java b/src/main/java/commands/CommandShowList.java index 0c42cb03e6..d43b8cbcfd 100644 --- a/src/main/java/commands/CommandShowList.java +++ b/src/main/java/commands/CommandShowList.java @@ -20,60 +20,7 @@ public CommandShowList(String listPath) { public void execute(Farmio farmio) throws FarmioFatalException { Ui ui = farmio.getUi(); double level = farmio.getFarmer().getLevel(); - - if(filePath.equals("ActionList")) { - if(level == 1.1) { - farmio.getSimulation().simulate(filePath, 11,false); - } - if(level == 1.2) { - farmio.getSimulation().simulate(filePath, 12,false); - } - if(level == 1.3) { - farmio.getSimulation().simulate(filePath, 13,false); - } - if(level == 1.4) { - farmio.getSimulation().simulate(filePath, 14,false); - } - if(level == 1.5) { - farmio.getSimulation().simulate(filePath, 15,false); - } - if(level == 1.6) { - farmio.getSimulation().simulate(filePath, 15,false); - } - } - - if(filePath.equals("ConditionList")) { - if(level == 1.1) { - farmio.getSimulation().simulate(filePath, 11,false); - } - if(level == 1.2) { - farmio.getSimulation().simulate(filePath, 11,false); - } - if(level == 1.3) { - farmio.getSimulation().simulate(filePath, 11,false); - } - if(level == 1.4) { - farmio.getSimulation().simulate(filePath, 14,false); - } - if(level == 1.5) { - farmio.getSimulation().simulate(filePath, 16,false); - } - if(level == 1.6) { - farmio.getSimulation().simulate(filePath, 16,false); - } - } - - if(filePath.equals("MarketList")) { - if(level < 1.5) { - farmio.getSimulation().simulate(filePath, 4,false); - } else if(level < 2) { - farmio.getSimulation().simulate(filePath, 1, false); - } else if(level < 3) { - farmio.getSimulation().simulate(filePath, 2,false); - } else if(level < 4) { - farmio.getSimulation().simulate(filePath, 3,false); - } - } + farmio.getSimulation().simulate(filePath, (int)(level * 10),false); ui.show("Press [Enter] to go back to game"); } diff --git a/src/main/java/commands/CommandTaskCreate.java b/src/main/java/commands/CommandTaskCreate.java index 242291751c..5f9967f3cc 100644 --- a/src/main/java/commands/CommandTaskCreate.java +++ b/src/main/java/commands/CommandTaskCreate.java @@ -27,8 +27,7 @@ public void execute(Farmio farmio) throws FarmioException, FarmioFatalException Storage storage = farmio.getStorage(); Farmer farmer = farmio.getFarmer(); farmer.getTasks().addTask(task); - farmio.getSimulation().simulate(farmio.getLevel().getPath(), farmio.getLevel().getNarratives().size() - 1); + super.saveTaskandResetScreen(farmio); ui.showInfo("Task [" + task.toString() + "] added! \nYou now have " + farmer.getTasks().size() + " tasks!"); - super.saveTask(farmio); } } diff --git a/src/main/java/commands/CommandTaskDelete.java b/src/main/java/commands/CommandTaskDelete.java index c2d64105ac..80515e90dc 100644 --- a/src/main/java/commands/CommandTaskDelete.java +++ b/src/main/java/commands/CommandTaskDelete.java @@ -24,9 +24,8 @@ public void execute(Farmio farmio) throws FarmioException, FarmioFatalException } try { String taskToString = farmio.getFarmer().getTasks().removeTask(taskID); - farmio.getSimulation().simulate(); + super.saveTaskandResetScreen(farmio); farmio.getUi().showInfo("You have deleted task: " + taskToString); - super.saveTask(farmio); } catch (Exception e) { throw new FarmioException("Error deleting task!"); } diff --git a/src/main/java/commands/CommandTaskDeleteAll.java b/src/main/java/commands/CommandTaskDeleteAll.java index ce47bc5360..03a0f7de6a 100644 --- a/src/main/java/commands/CommandTaskDeleteAll.java +++ b/src/main/java/commands/CommandTaskDeleteAll.java @@ -13,8 +13,7 @@ public class CommandTaskDeleteAll extends CommandChangeTask { @Override public void execute(Farmio farmio) throws FarmioFatalException { farmio.getFarmer().getTasks().clear(); - farmio.getSimulation().simulate(); + super.saveTaskandResetScreen(farmio); farmio.getUi().showInfo("You have deleted all tasks!"); - super.saveTask(farmio); } } diff --git a/src/main/java/commands/CommandTaskEdit.java b/src/main/java/commands/CommandTaskEdit.java index 997dd8e0b8..10728a421d 100644 --- a/src/main/java/commands/CommandTaskEdit.java +++ b/src/main/java/commands/CommandTaskEdit.java @@ -31,10 +31,8 @@ public void execute(Farmio farmio) throws FarmioException, FarmioFatalException throw new FarmioException("Invalid Task ID!"); } farmer.getTasks().editTask(taskID, task); - farmio.getSimulation().simulate(farmio.getLevel().getPath(), - farmio.getLevel().getNarratives().size() - 1); + super.saveTaskandResetScreen(farmio); Ui ui = farmio.getUi(); ui.showInfo("Successfully edited task!"); - super.saveTask(farmio); } } diff --git a/src/main/java/commands/CommandTaskInsert.java b/src/main/java/commands/CommandTaskInsert.java index fa4dfb90dd..093ca9c88c 100644 --- a/src/main/java/commands/CommandTaskInsert.java +++ b/src/main/java/commands/CommandTaskInsert.java @@ -24,8 +24,7 @@ public CommandTaskInsert(int taskID, Task task) { @Override public void execute(Farmio farmio) throws FarmioException, FarmioFatalException { farmio.getFarmer().getTasks().insertTask(taskID, task); - farmio.getSimulation().simulate(); + super.saveTaskandResetScreen(farmio); farmio.getUi().showInfo("You have added a new task: " + task.toString() + " at position " + taskID); - super.saveTask(farmio); } } diff --git a/src/main/java/farmio/Level.java b/src/main/java/farmio/Level.java index 99e84f5375..ef66792c0f 100644 --- a/src/main/java/farmio/Level.java +++ b/src/main/java/farmio/Level.java @@ -295,9 +295,8 @@ public List getSuccessfulFeedback() { * @return */ - public List getFeedback(Farmio farmio) { + public List getFeedback(Farmio farmio, ObjectiveResult currentLevelState) { Farmer farmer = farmio.getFarmer(); - ObjectiveResult currentLevelState = farmio.getLevel().getLevelState(); List output = new ArrayList(); if (currentLevelState == ObjectiveResult.DONE) { diff --git a/src/main/resources/asciiArt/ActionList/frame16.txt b/src/main/resources/asciiArt/ActionList/frame16.txt new file mode 100644 index 0000000000..6c338c8238 --- /dev/null +++ b/src/main/resources/asciiArt/ActionList/frame16.txt @@ -0,0 +1,5 @@ +Transport Market WheatFarm +______________________________________________________ + gotoMarket | buySeeds | plantSeeds + gotoWheatFarm | sellGrain | harvestWheat +___________________|________________|_________________ diff --git a/src/main/resources/asciiArt/ActionList/frame21.txt b/src/main/resources/asciiArt/ActionList/frame21.txt new file mode 100644 index 0000000000..6c338c8238 --- /dev/null +++ b/src/main/resources/asciiArt/ActionList/frame21.txt @@ -0,0 +1,5 @@ +Transport Market WheatFarm +______________________________________________________ + gotoMarket | buySeeds | plantSeeds + gotoWheatFarm | sellGrain | harvestWheat +___________________|________________|_________________ diff --git a/src/main/resources/asciiArt/ConditionList/frame12.txt b/src/main/resources/asciiArt/ConditionList/frame12.txt new file mode 100644 index 0000000000..c21c95e2df --- /dev/null +++ b/src/main/resources/asciiArt/ConditionList/frame12.txt @@ -0,0 +1,9 @@ + GOLD BOOLEAN +______________________________________________________ + greaterThanOrEquals | + greaterThan | + lessThan | + lessThanOrEquals | +_____________________|________________________________ + +Eg: [If gold greaterThanOrEquals 10 do buySeeds] diff --git a/src/main/resources/asciiArt/ConditionList/frame13.txt b/src/main/resources/asciiArt/ConditionList/frame13.txt new file mode 100644 index 0000000000..c21c95e2df --- /dev/null +++ b/src/main/resources/asciiArt/ConditionList/frame13.txt @@ -0,0 +1,9 @@ + GOLD BOOLEAN +______________________________________________________ + greaterThanOrEquals | + greaterThan | + lessThan | + lessThanOrEquals | +_____________________|________________________________ + +Eg: [If gold greaterThanOrEquals 10 do buySeeds] diff --git a/src/main/resources/asciiArt/ConditionList/frame15.txt b/src/main/resources/asciiArt/ConditionList/frame15.txt new file mode 100644 index 0000000000..c6e0763dbc --- /dev/null +++ b/src/main/resources/asciiArt/ConditionList/frame15.txt @@ -0,0 +1,10 @@ + GOLD BOOLEAN +______________________________________________________ + greaterThanOrEquals | hasSeeds + greaterThan | hasWheat + lessThan | hasGrain + lessThanOrEquals | +_____________________|________________________________ + +Eg: [If gold greaterThanOrEquals 10 do buySeeds] + diff --git a/src/main/resources/asciiArt/ConditionList/frame21.txt b/src/main/resources/asciiArt/ConditionList/frame21.txt new file mode 100644 index 0000000000..c6e0763dbc --- /dev/null +++ b/src/main/resources/asciiArt/ConditionList/frame21.txt @@ -0,0 +1,10 @@ + GOLD BOOLEAN +______________________________________________________ + greaterThanOrEquals | hasSeeds + greaterThan | hasWheat + lessThan | hasGrain + lessThanOrEquals | +_____________________|________________________________ + +Eg: [If gold greaterThanOrEquals 10 do buySeeds] + diff --git a/src/main/resources/asciiArt/MarketList/frame11.txt b/src/main/resources/asciiArt/MarketList/frame11.txt new file mode 100644 index 0000000000..c826ce8a7e --- /dev/null +++ b/src/main/resources/asciiArt/MarketList/frame11.txt @@ -0,0 +1,7 @@ + .______________________________________________. + | Market Rates | + |----------------------------------------------| + | Item | Selling or Buying Price | + |------------------|---------------------------| + | Seeds | 10 gold | + |__________________|___________________________| diff --git a/src/main/resources/asciiArt/MarketList/frame12.txt b/src/main/resources/asciiArt/MarketList/frame12.txt new file mode 100644 index 0000000000..c826ce8a7e --- /dev/null +++ b/src/main/resources/asciiArt/MarketList/frame12.txt @@ -0,0 +1,7 @@ + .______________________________________________. + | Market Rates | + |----------------------------------------------| + | Item | Selling or Buying Price | + |------------------|---------------------------| + | Seeds | 10 gold | + |__________________|___________________________| diff --git a/src/main/resources/asciiArt/MarketList/frame13.txt b/src/main/resources/asciiArt/MarketList/frame13.txt new file mode 100644 index 0000000000..c826ce8a7e --- /dev/null +++ b/src/main/resources/asciiArt/MarketList/frame13.txt @@ -0,0 +1,7 @@ + .______________________________________________. + | Market Rates | + |----------------------------------------------| + | Item | Selling or Buying Price | + |------------------|---------------------------| + | Seeds | 10 gold | + |__________________|___________________________| diff --git a/src/main/resources/asciiArt/MarketList/frame14.txt b/src/main/resources/asciiArt/MarketList/frame14.txt new file mode 100644 index 0000000000..c826ce8a7e --- /dev/null +++ b/src/main/resources/asciiArt/MarketList/frame14.txt @@ -0,0 +1,7 @@ + .______________________________________________. + | Market Rates | + |----------------------------------------------| + | Item | Selling or Buying Price | + |------------------|---------------------------| + | Seeds | 10 gold | + |__________________|___________________________| diff --git a/src/main/resources/asciiArt/MarketList/frame15.txt b/src/main/resources/asciiArt/MarketList/frame15.txt new file mode 100644 index 0000000000..1e34be2925 --- /dev/null +++ b/src/main/resources/asciiArt/MarketList/frame15.txt @@ -0,0 +1,10 @@ + .______________________________________________. + | Market Rates | + |----------------------------------------------| + | Item | Selling or Buying Price | + |------------------|---------------------------| + | Seeds | 10 gold | + | Grain | 15 gold | + |__________________|___________________________| + + diff --git a/src/main/resources/asciiArt/MarketList/frame16.txt b/src/main/resources/asciiArt/MarketList/frame16.txt new file mode 100644 index 0000000000..1e34be2925 --- /dev/null +++ b/src/main/resources/asciiArt/MarketList/frame16.txt @@ -0,0 +1,10 @@ + .______________________________________________. + | Market Rates | + |----------------------------------------------| + | Item | Selling or Buying Price | + |------------------|---------------------------| + | Seeds | 10 gold | + | Grain | 15 gold | + |__________________|___________________________| + + diff --git a/src/main/resources/asciiArt/MarketList/frame21.txt b/src/main/resources/asciiArt/MarketList/frame21.txt new file mode 100644 index 0000000000..03b27b478a --- /dev/null +++ b/src/main/resources/asciiArt/MarketList/frame21.txt @@ -0,0 +1,10 @@ + .______________________________________________. + | Market Rates | + |----------------------------------------------| + | Item | Selling or Buying Price | + |------------------|---------------------------| + | Seeds | 10 gold | + | Grain | 15 gold | + | Chicken | 25 gold | + | Eggs | 10 gold | + |__________________|___________________________| \ No newline at end of file