diff --git a/src/main/java/commands/CommandMenu.java b/src/main/java/commands/CommandMenu.java index 15c4eb9e87..3ae70d22f5 100644 --- a/src/main/java/commands/CommandMenu.java +++ b/src/main/java/commands/CommandMenu.java @@ -1,19 +1,19 @@ -package commands; - -import exceptions.FarmioFatalException; -import farmio.Farmio; -import farmio.Menu; - -public class CommandMenu extends Command { - - /** - * Shows the menu. - * @param farmio the game which stage is set as MENU. - * @throws FarmioFatalException if simulation file is missing. - */ - @Override - public void execute(Farmio farmio) throws FarmioFatalException { - Menu.show(farmio, true); - farmio.setStage(Farmio.Stage.MENU); - } -} +//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/CommandMenuInGame.java b/src/main/java/commands/CommandMenuInGame.java index e25d78ee34..a2ced8d0b1 100644 --- a/src/main/java/commands/CommandMenuInGame.java +++ b/src/main/java/commands/CommandMenuInGame.java @@ -3,15 +3,8 @@ import exceptions.FarmioFatalException; import farmio.Farmio; import farmio.Menu; -import frontend.Ui; public class CommandMenuInGame extends Command { - private String input; - - public CommandMenuInGame(String userInput) { - this.input = userInput; - } - /** * Shows the menu. @@ -20,64 +13,6 @@ public CommandMenuInGame(String userInput) { */ @Override public void execute(Farmio farmio) throws FarmioFatalException { - double level = farmio.getFarmer().getLevel(); - Ui ui = farmio.getUi(); - - if (input.equals("actions")) { - if (level == 1.1) { - farmio.getSimulation().simulate("ActionList", 11,true); - } - if (level == 1.2) { - farmio.getSimulation().simulate("ActionList", 12,true); - } - if (level == 1.3) { - farmio.getSimulation().simulate("ActionList", 13,true); - } - if (level == 1.4) { - farmio.getSimulation().simulate("ActionList", 14,true); - } - if (level == 1.5) { - farmio.getSimulation().simulate("ActionList", 15,true); - } - if (level == 1.6) { - farmio.getSimulation().simulate("ActionList", 15,true); - } - } - if (input.equals("conditions")) { - if (level == 1.1) { - farmio.getSimulation().simulate("ConditionList", 11,true); - } - if (level == 1.2) { - farmio.getSimulation().simulate("ConditionList", 11,true); - } - if (level == 1.3) { - farmio.getSimulation().simulate("ConditionList", 11,true); - } - if (level == 1.4) { - farmio.getSimulation().simulate("ConditionList", 14,true); - } - if (level == 1.5) { - farmio.getSimulation().simulate("ConditionList", 16,true); - } - if (level == 1.6) { - farmio.getSimulation().simulate("ConditionList", 16,true); - } - } - - if (input.equals("market")) { - if (level < 1.5) { - farmio.getSimulation().simulate("MarketList", 4,true); - } else if (level < 2) { - farmio.getSimulation().simulate("MarketList", 1, true); - } else if (level < 3) { - farmio.getSimulation().simulate("MarketList", 2,true); - } else if (level < 4) { - farmio.getSimulation().simulate("MarketList", 3,true); - } - } - if (input.equals("")) { - Menu.show(farmio, true); - } - farmio.setStage(Farmio.Stage.MENU); + Menu.show(farmio, true); } -} \ No newline at end of file +} diff --git a/src/main/java/commands/CommandShowList.java b/src/main/java/commands/CommandShowList.java index 4894019cb9..0c42cb03e6 100644 --- a/src/main/java/commands/CommandShowList.java +++ b/src/main/java/commands/CommandShowList.java @@ -2,11 +2,11 @@ import exceptions.FarmioFatalException; import farmio.Farmio; +import farmio.Menu; import frontend.Ui; public class CommandShowList extends Command { private String filePath; - public CommandShowList(String listPath) { filePath = listPath; } @@ -19,7 +19,63 @@ public CommandShowList(String listPath) { @Override public void execute(Farmio farmio) throws FarmioFatalException { Ui ui = farmio.getUi(); - farmio.getSimulation().simulate(filePath, (int)farmio.getFarmer().getLevel()); - ui.show("Press [Enter] to go back"); + 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); + } + } + + ui.show("Press [Enter] to go back to game"); } + } \ No newline at end of file diff --git a/src/main/java/farmio/Menu.java b/src/main/java/farmio/Menu.java index a41ea47373..9b9f62c400 100644 --- a/src/main/java/farmio/Menu.java +++ b/src/main/java/farmio/Menu.java @@ -7,23 +7,31 @@ public class Menu { private static final String ART_NAME = "menu"; private static final String BULLET = "\t\u2022 "; + public static void show(Farmio farmio, boolean resume) throws FarmioFatalException { Storage storage = farmio.getStorage(); Ui ui = farmio.getUi(); Simulation simulation =farmio.getSimulation(); if(resume && storage.getSaveExist()) { //resume, save and load - simulation.simulate("Menu", 2, true); + simulation.simulate("Menu", 2, false); + ui.typeWriter("Enter the option of your choice\nPress [Enter] to resume game", false); } else if(resume){ //resume and save - simulation.simulate("Menu", 4, true); + simulation.simulate("Menu", 4, false); + ui.typeWriter("Enter the option of your choice\nPress [Enter] to resume game", false); + } else if(storage.getSaveExist()){ //load simulation.simulate("Menu", 3, true); + ui.typeWriter("Enter the option of your choice\nFor example, if you want to create a new game," + + " Enter [New Game]", false); } else { simulation.simulate("Menu", 0, true); //only new and quit + ui.typeWriter("Enter the option of your choice\nFor example, if you want to create a new game," + + " Enter [New Game]", false); } - ui.typeWriter("Enter the option of your choice\nFor example, if you want to create a new game," + - " Enter [New Game]", false); + } + } diff --git a/src/main/java/farmio/Parser.java b/src/main/java/farmio/Parser.java index a84808a152..03d056640c 100644 --- a/src/main/java/farmio/Parser.java +++ b/src/main/java/farmio/Parser.java @@ -45,8 +45,8 @@ public static Command parse(String userInput, Farmio.Stage stage) throws FarmioE return new CommandMenuStart(); case LEVEL_START: return new CommandLevelStart(); - case MENU: - return parseMenu(userInput); +// case MENU: +// return parseMenu(userInput); case RUNNING_DAY: return new CommandTasksRun(); case CHECK_OBJECTIVES: @@ -75,15 +75,15 @@ public static Command parse(String userInput, Farmio.Stage stage) throws FarmioE * @return Command that corresponds to the user's actions * @throws FarmioException if user input is invalid */ - private static Command parseMenu(String userInput) throws FarmioException { - if (userInput.equals("resume game")) { - return new CommandLevelStart(); - } else if (userInput.equals("actions") || userInput.equals("conditions") || userInput.equals("market") || userInput.equals("")) { - return new CommandMenuInGame(userInput); - } else { - throw new FarmioException("Invalid command!"); - } - } +// private static Command parseMenu(String userInput) throws FarmioException { +// if (userInput.equals("resume game")) { +// return new CommandLevelStart(); +// } else if (userInput.equals("actions") || userInput.equals("conditions") || userInput.equals("market") || userInput.equals("")) { +// return new CommandMenuInGame(userInput); +// } else { +// throw new FarmioException("Invalid command!"); +// } +// } /** * Used to parse the user input during the DAY_END stage. User can choose to either reset the level, @@ -113,7 +113,7 @@ private static Command parseDayEnd(String userInput) throws FarmioException { */ private static Command parseTaskAdd(String userInput) throws FarmioException { if (userInput.equals("menu")) { - return new CommandMenu(); + return new CommandMenuInGame(); } if (userInput.equals("deleteall") || userInput.equals("delete all")) { return new CommandTaskDeleteAll(); diff --git a/src/main/resources/asciiArt/ActionList/frame1.txt b/src/main/resources/asciiArt/ActionList/frame1.txt index 0da18e0891..a53885be66 100644 --- a/src/main/resources/asciiArt/ActionList/frame1.txt +++ b/src/main/resources/asciiArt/ActionList/frame1.txt @@ -9,9 +9,3 @@ ___________________|________________|_________________ - - - - - - [PRESS 'ENTER' TO GO BACK] \ No newline at end of file diff --git a/src/main/resources/asciiArt/ActionList/frame11.txt b/src/main/resources/asciiArt/ActionList/frame11.txt index c0fca72a49..1a9b480b1d 100644 --- a/src/main/resources/asciiArt/ActionList/frame11.txt +++ b/src/main/resources/asciiArt/ActionList/frame11.txt @@ -2,5 +2,3 @@ Transport Market WheatFarm ______________________________________________________ gotoMarket | | ___________________|________________|_________________ - -[PRESS 'ENTER' TO GO BACK TO MENU] \ No newline at end of file diff --git a/src/main/resources/asciiArt/ActionList/frame12.txt b/src/main/resources/asciiArt/ActionList/frame12.txt index 53333638b5..02d575b678 100644 --- a/src/main/resources/asciiArt/ActionList/frame12.txt +++ b/src/main/resources/asciiArt/ActionList/frame12.txt @@ -2,5 +2,3 @@ Transport Market WheatFarm ______________________________________________________ gotoMarket | buySeeds | ___________________|________________|_________________ - -[PRESS 'ENTER' TO GO BACK TO MENU] \ No newline at end of file diff --git a/src/main/resources/asciiArt/ActionList/frame13.txt b/src/main/resources/asciiArt/ActionList/frame13.txt index c757af5f3e..4bb340848c 100644 --- a/src/main/resources/asciiArt/ActionList/frame13.txt +++ b/src/main/resources/asciiArt/ActionList/frame13.txt @@ -3,5 +3,3 @@ ______________________________________________________ gotoMarket | buySeeds | plantSeeds gotoWheatFarm | | ___________________|________________|_________________ - -[PRESS 'ENTER' TO GO BACK TO MENU] \ No newline at end of file diff --git a/src/main/resources/asciiArt/ActionList/frame14.txt b/src/main/resources/asciiArt/ActionList/frame14.txt index 8842996b8d..1093dd4c94 100644 --- a/src/main/resources/asciiArt/ActionList/frame14.txt +++ b/src/main/resources/asciiArt/ActionList/frame14.txt @@ -3,5 +3,3 @@ ______________________________________________________ gotoMarket | buySeeds | plantSeeds gotoWheatFarm | | harvestWheat ___________________|________________|_________________ - -[PRESS 'ENTER' TO GO BACK TO MENU] \ No newline at end of file diff --git a/src/main/resources/asciiArt/ActionList/frame15.txt b/src/main/resources/asciiArt/ActionList/frame15.txt index df6710f3c6..6c338c8238 100644 --- a/src/main/resources/asciiArt/ActionList/frame15.txt +++ b/src/main/resources/asciiArt/ActionList/frame15.txt @@ -3,5 +3,3 @@ ______________________________________________________ gotoMarket | buySeeds | plantSeeds gotoWheatFarm | sellGrain | harvestWheat ___________________|________________|_________________ - -[PRESS 'ENTER' TO GO BACK TO MENU] \ No newline at end of file diff --git a/src/main/resources/asciiArt/ConditionList/frame1.txt b/src/main/resources/asciiArt/ConditionList/frame1.txt index b2f273aa68..836eb7af01 100644 --- a/src/main/resources/asciiArt/ConditionList/frame1.txt +++ b/src/main/resources/asciiArt/ConditionList/frame1.txt @@ -8,10 +8,3 @@ _____________________|________________________________ Eg: [If gold greaterThanOrEquals 10 do buySeeds] - - - - - - - [PRESS 'ENTER' TO GO BACK] \ No newline at end of file diff --git a/src/main/resources/asciiArt/ConditionList/frame11.txt b/src/main/resources/asciiArt/ConditionList/frame11.txt index 02c7dc028b..c21c95e2df 100644 --- a/src/main/resources/asciiArt/ConditionList/frame11.txt +++ b/src/main/resources/asciiArt/ConditionList/frame11.txt @@ -7,5 +7,3 @@ ______________________________________________________ _____________________|________________________________ Eg: [If gold greaterThanOrEquals 10 do buySeeds] - -[PRESS 'ENTER' TO GO BACK TO MENU] diff --git a/src/main/resources/asciiArt/ConditionList/frame14.txt b/src/main/resources/asciiArt/ConditionList/frame14.txt index 8ab49daaef..3829608daa 100644 --- a/src/main/resources/asciiArt/ConditionList/frame14.txt +++ b/src/main/resources/asciiArt/ConditionList/frame14.txt @@ -7,5 +7,3 @@ ______________________________________________________ _____________________|________________________________ Eg: [If gold greaterThanOrEquals 10 do buySeeds] - -[PRESS 'ENTER' TO GO BACK TO MENU] diff --git a/src/main/resources/asciiArt/ConditionList/frame16.txt b/src/main/resources/asciiArt/ConditionList/frame16.txt index 3ba7c7600e..c6e0763dbc 100644 --- a/src/main/resources/asciiArt/ConditionList/frame16.txt +++ b/src/main/resources/asciiArt/ConditionList/frame16.txt @@ -8,4 +8,3 @@ _____________________|________________________________ Eg: [If gold greaterThanOrEquals 10 do buySeeds] -[PRESS 'ENTER' TO GO BACK TO MENU] diff --git a/src/main/resources/asciiArt/MarketList/frame1.txt b/src/main/resources/asciiArt/MarketList/frame1.txt index 04e4c6a81e..697d7d23ee 100644 --- a/src/main/resources/asciiArt/MarketList/frame1.txt +++ b/src/main/resources/asciiArt/MarketList/frame1.txt @@ -8,10 +8,3 @@ |__________________|___________________________|' - - - - - - - [PRESS 'ENTER' TO GO BACK] \ No newline at end of file diff --git a/src/main/resources/asciiArt/MarketList/frame4.txt b/src/main/resources/asciiArt/MarketList/frame4.txt index 6daba42282..c826ce8a7e 100644 --- a/src/main/resources/asciiArt/MarketList/frame4.txt +++ b/src/main/resources/asciiArt/MarketList/frame4.txt @@ -5,5 +5,3 @@ |------------------|---------------------------| | Seeds | 10 gold | |__________________|___________________________| - - [PRESS 'ENTER' TO GO BACK TO MENU] \ No newline at end of file diff --git a/src/main/resources/asciiArt/Menu/frame2.txt b/src/main/resources/asciiArt/Menu/frame2.txt index a2c6478fbc..c3d0744f5b 100644 --- a/src/main/resources/asciiArt/Menu/frame2.txt +++ b/src/main/resources/asciiArt/Menu/frame2.txt @@ -2,8 +2,8 @@ _______________________________________________________ __________ _.-"` `"-._ .'_ _ _ _ _ _ _'. - / |_ |_||_|| | | | | | \ MENU: - / | | || \| | | |_| \ Resume Game + / |_ |_||_|| | | | | | \ + / | | || \| | | |_| \ MENU: ; \ Save Game | | Load Game | _. | Quit Game