From fca73c9338a0db2d4f3de2c6a946f559e22f868d Mon Sep 17 00:00:00 2001 From: Notahotdog-Umar Moiz Date: Tue, 15 Oct 2019 11:02:55 +0800 Subject: [PATCH 1/4] some --- src/main/java/Storage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index 6705b3141d..c59c36e7ed 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -51,8 +51,8 @@ public String getAsciiArt(String name) throws IOException { return art.toString(); } - public String getLevel(int level) throws IOException{ + public String getLevel(int level) throws IOException{ //runs level - + return "tbc"; } } From 27eb5c8beed3560b16b1bb2d7050f71d7328ced8 Mon Sep 17 00:00:00 2001 From: Notahotdog-Umar Moiz Date: Wed, 23 Oct 2019 23:53:25 +0800 Subject: [PATCH 2/4] modified Level --- src/main/java/Farmio/Level.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/Farmio/Level.java b/src/main/java/Farmio/Level.java index dbc1feb263..8194ebb65d 100644 --- a/src/main/java/Farmio/Level.java +++ b/src/main/java/Farmio/Level.java @@ -63,6 +63,11 @@ public objectiveResult checkAnswer(Farmio farmio){ return objectiveResult.DONE; } + + + + + public Map getGoals() { Map goals = new HashMap< String,Integer>(); goals.put("Gold", endMoney); From 01fe7596ce4c7fd9e4c6895226731de3f2686878 Mon Sep 17 00:00:00 2001 From: Notahotdog-Umar Moiz Date: Thu, 24 Oct 2019 00:07:15 +0800 Subject: [PATCH 3/4] added objectiveResult --- .../classes/java/main/Commands/Command.class | Bin 397 -> 397 bytes .../java/main/Commands/CommandDayNew.class | Bin 1671 -> 1671 bytes .../java/main/Commands/CommandGameQuit.class | Bin 706 -> 706 bytes .../java/main/Commands/CommandMenuStart.class | Bin 764 -> 764 bytes .../java/main/Commands/CommandWelcome.class | Bin 848 -> 848 bytes .../main/Exceptions/FarmioException.class | Bin 357 -> 357 bytes .../Exceptions/FarmioFatalException.class | Bin 374 -> 374 bytes .../java/main/Farmio/Farmio$Stage.class | Bin 1480 -> 1480 bytes build/classes/java/main/Farmio/Farmio.class | Bin 2933 -> 2933 bytes .../java/main/FrontEnd/AsciiColours.class | Bin 4377 -> 4377 bytes .../java/main/Places/ChickenFarm.class | Bin 647 -> 647 bytes build/classes/java/main/Places/CowFarm.class | Bin 654 -> 654 bytes build/classes/java/main/Places/Farm.class | Bin 342 -> 342 bytes build/classes/java/main/Places/Market.class | Bin 1105 -> 1105 bytes .../Conditions/BooleanConditionType.class | Bin 1190 -> 1190 bytes .../main/UserCode/Conditions/Comparator.class | Bin 1136 -> 1136 bytes .../Conditions/ConditionChecker$1.class | Bin 1146 -> 1146 bytes .../Conditions/ConditionChecker.class | Bin 2485 -> 2485 bytes .../Conditions/ValueConditionType.class | Bin 1002 -> 1002 bytes src/main/java/Farmio/Level.java | 37 ++++++++++++++++-- 20 files changed, 33 insertions(+), 4 deletions(-) diff --git a/build/classes/java/main/Commands/Command.class b/build/classes/java/main/Commands/Command.class index 911fbd43658d9c1f75d0177ab4ad6ff701d81667..eb0f41e5dc4fd41e8faa756c1f85a81e57b202e5 100644 GIT binary patch delta 17 YcmeBW?q%jU^>5cc1_lO;jU26v06E45-~a#s delta 17 YcmeBW?q%jU^>5cc1_lQ6jU26v06D=0-v9sr diff --git a/build/classes/java/main/Commands/CommandDayNew.class b/build/classes/java/main/Commands/CommandDayNew.class index 803e444a2013b28785f52164cd553e03d6dafcb8..7d1a779370e651107d66f1a0fdacede923a04516 100644 GIT binary patch delta 17 YcmZqYZRh1U^>5cc1_lO;jU4rC06HrL=Kufz delta 17 YcmZqYZRh1U^>5cc1_lQ6jU4rC06HcG<^TWy diff --git a/build/classes/java/main/Commands/CommandGameQuit.class b/build/classes/java/main/Commands/CommandGameQuit.class index 307f41e51cb1d1abe872f5fde0fcd1ed04904089..115195f5ce634fb438f94173ef6908feda3806f9 100644 GIT binary patch delta 17 ZcmX@adWe27>?q diff --git a/build/classes/java/main/Commands/CommandMenuStart.class b/build/classes/java/main/Commands/CommandMenuStart.class index 1a5d3b0b2f79e3d34ff906dfd802bfdfde7881cc..3b190463c3576b2d7ff6a85b4b788dac56d6b15c 100644 GIT binary patch delta 17 Zcmeyv`iGU{)W2Q(7#J8VHgbGn0su(C2QmNv delta 17 Zcmeyv`iGU{)W2Q(7#JALH*$Po0su(72QdHu diff --git a/build/classes/java/main/Commands/CommandWelcome.class b/build/classes/java/main/Commands/CommandWelcome.class index 862a90a623ea034f6a009eff952c1652745b8c78..c4e93d5ee1a8fc6c21fe4bbbb14d9a026ecf291c 100644 GIT binary patch delta 17 Zcmcb>c7cuK)W2Q(7#J8VHgb3{0{}t@1~C8t delta 17 Zcmcb>c7cuK)W2Q(7#JALH*$C|0{}t;1~32s diff --git a/build/classes/java/main/Exceptions/FarmioException.class b/build/classes/java/main/Exceptions/FarmioException.class index 9e2f4091c8199c853caf4c8c9abd827dd2f34746..a6657863c5a756cdfb9af3fad44e5b4536710902 100644 GIT binary patch delta 17 ZcmaFL^puI?)W2Q(7#J8VHgd!=0sur<24(;N delta 17 ZcmaFL^puI?)W2Q(7#JALH*&->0sur)24w&M diff --git a/build/classes/java/main/Exceptions/FarmioFatalException.class b/build/classes/java/main/Exceptions/FarmioFatalException.class index b0a63b0357a7b2d95d7d7cb512248cadf0cb17ea..111d39608cfca3898a2a55dbe2eb6822e73d4aba 100644 GIT binary patch delta 17 Zcmeyy^o@z*)W2Q(7#J8VHge=K0suyu2AKc= delta 17 Zcmeyy^o@z*)W2Q(7#JALH*(}L0suyp2ABW< diff --git a/build/classes/java/main/Farmio/Farmio$Stage.class b/build/classes/java/main/Farmio/Farmio$Stage.class index c3caf9d06c881f3d39b179ff845737349ccf0c8a..1c7a846976d4a2529c3e8a83afaf3250408b07ff 100644 GIT binary patch delta 17 ZcmX@XeS(|g)W2Q(7#J8VHgX(b1pq>j2BiQ1 delta 17 ZcmX@XeS(|g)W2Q(7#JALH*y?c1pq>e2BZK0 diff --git a/build/classes/java/main/Farmio/Farmio.class b/build/classes/java/main/Farmio/Farmio.class index f52a401e9cfe871c7e73dfa5e09127c2eb0397ca..858d8210ac166697db2d44341b406f308624650c 100644 GIT binary patch delta 17 Zcmew=_En7I)W2Q(7#J8VHge>00{}?c2FL&a delta 17 Zcmew=_En7I)W2Q(7#JALH*(~10{}?X2FCyZ diff --git a/build/classes/java/main/FrontEnd/AsciiColours.class b/build/classes/java/main/FrontEnd/AsciiColours.class index 33e599dcb188694008a828ac03bb0a628dcdaf1f..ac9a48fe76c655c989c1031397c4f321fc656123 100644 GIT binary patch delta 17 ZcmbQKG*gM=)W2Q(7#J8VHgX6G0suY`1=0Wj delta 17 ZcmbQKG*gM=)W2Q(7#JALH*yFH0suY>15cc1_lO;jU4q%068}W(*OVf delta 17 YcmZo?ZD-{;^>5cc1_lQ6jU4q%068)R(f|Me diff --git a/build/classes/java/main/Places/CowFarm.class b/build/classes/java/main/Places/CowFarm.class index 27ffd91ac1770f89e89a2dfef4ce133da2891b63..e5f371d65a8df89b6e82394dc46182b631636817 100644 GIT binary patch delta 17 YcmeBU?PKLQ^>5cc1_lO;jT~)E06HZF=l}o! delta 17 YcmeBU?PKLQ^>5cc1_lQ6jT~)E06HKA=Kufz diff --git a/build/classes/java/main/Places/Farm.class b/build/classes/java/main/Places/Farm.class index 48f1e8b27d47191e0f1e046670ff96bc0ab6eb4b..9198cf9af5c84d37473fad255a4c62ebb6b5174d 100644 GIT binary patch delta 17 Zcmcb{bd8DQ)W2Q(7#J8VHgfne0sul<1~~u# delta 17 Zcmcb{bd8DQ)W2Q(7#JALH*)wf0sul)1~>o! diff --git a/build/classes/java/main/Places/Market.class b/build/classes/java/main/Places/Market.class index d9244f79320785bfcebad73e68cf3f9b8d7472f4..b09293b13b1b95b1fb681c10bf11a1066e8f332a 100644 GIT binary patch delta 17 Zcmcb}agl@L)W2Q(7#J8VHgb5f002T~1~~u# delta 17 Zcmcb}agl@L)W2Q(7#JALH*$Eg002T_1~>o! diff --git a/build/classes/java/main/UserCode/Conditions/BooleanConditionType.class b/build/classes/java/main/UserCode/Conditions/BooleanConditionType.class index cd59b11f14ad8f8e3ce548c03b4f0da3458f530c..737759bb0e381e2bf61a2f436ea2e213e13312ae 100644 GIT binary patch delta 17 ZcmZ3+xr~$J)W2Q(7#J8VHge2k0RTPE208!$ delta 17 ZcmZ3+xr~$J)W2Q(7#JALH*(Bl0RTP91~~u# diff --git a/build/classes/java/main/UserCode/Conditions/Comparator.class b/build/classes/java/main/UserCode/Conditions/Comparator.class index b14e8050b49b692b294eeb36b90241db74c6fb0b..f5162527923127c4e4ac4ecb1431466ea395bc96 100644 GIT binary patch delta 17 Zcmeys@qvTm)W2Q(7#J8VHgaUJ002gX29^K- delta 17 Zcmeys@qvTm)W2Q(7#JALH*#dK002gS29*E+ diff --git a/build/classes/java/main/UserCode/Conditions/ConditionChecker$1.class b/build/classes/java/main/UserCode/Conditions/ConditionChecker$1.class index 772397d287183500bc9a807616ee7d89520cec09..7164b4422545f24b43814f8b936c8ac30535d860 100644 GIT binary patch delta 17 Zcmeyx@r#4w)W2Q(7#J8VHgXiP002kX2DAVG delta 17 Zcmeyx@r#4w)W2Q(7#JALH*yrQ002kS2D1PF diff --git a/build/classes/java/main/UserCode/Conditions/ConditionChecker.class b/build/classes/java/main/UserCode/Conditions/ConditionChecker.class index 2a40ad92938e4ecd6e74ecdf4ce627fc5d8f4cae..cd2cbf87edd6db3e9be1a71ace31c5b23d6231d5 100644 GIT binary patch delta 17 Zcmdlgyj7Uv)W2Q(7#J8VHgc@x1OPz(27mwn delta 17 Zcmdlgyj7Uv)W2Q(7#JALH*&1y1OPz!27dqm diff --git a/build/classes/java/main/UserCode/Conditions/ValueConditionType.class b/build/classes/java/main/UserCode/Conditions/ValueConditionType.class index 78f38b64979e6206337435e08fa0f077a553e593..263ab4beca86ed81f4cd750706a28c2569478085 100644 GIT binary patch delta 17 ZcmaFG{)(OB)W2Q(7#J8VHgY^-1^`By2LS*8 delta 17 ZcmaFG{)(OB)W2Q(7#JALH*!2;1^`Bt2LJ#7 diff --git a/src/main/java/Farmio/Level.java b/src/main/java/Farmio/Level.java index 8194ebb65d..f4c281dae7 100644 --- a/src/main/java/Farmio/Level.java +++ b/src/main/java/Farmio/Level.java @@ -29,7 +29,7 @@ public Level(JSONObject object, Farmer farmer) { narratives.add((String) i); } filePath = (String) object.get("file_path"); - endMoney = Math.toIntExact((Long) object.get("money")); + gold = Math.toIntExact((Long) object.get("money")); endWheatSeed = Math.toIntExact((Long) object.get("wheat_seed")); endWheatGreen = Math.toIntExact((Long) object.get("wheat_green")); endWheatRipe = Math.toIntExact((Long) object.get("wheat_ripe")); @@ -37,6 +37,8 @@ public Level(JSONObject object, Farmer farmer) { endChickenEggs = 0; endCow = 0; endCowMilk = 0; + + // location = Math.toIntExact((Long) object.get("location")); } @@ -55,14 +57,41 @@ public enum objectiveResult { INVALID } + public boolean checkDeadlineExceeded(int currentDay){ + return deadline <= currentDay; + } + + public boolean allDone(Farmer farmer){ + int gold = farmer.getMoney(); + + //Wheat Farm + int WheatSeed = farmer.wheatFarm.getSeeds(); + int WheatGreen = farmer.wheatFarm.getGreenWheat(); + int WheatRipe = farmer.wheatFarm.getRipeWheat(); + + return (gold == endMoney ) && (WheatGreen == endWheatGreen) && (WheatRipe == endWheatRipe) && (endWheatSeed == WheatSeed); + } + public objectiveResult checkAnswer(Farmio farmio){ if (farmio.getFarmer().isHasfailedCurrentTask()) { return objectiveResult.INVALID; } - //TODO if (...) to return NOT_DONE, DONE, FAILED - return objectiveResult.DONE; + int day = farmer.getDay(); + objectiveResult currentLevelState; + if(checkDeadlineExceeded(day)){ + currentLevelState = levelState.FAILED; + } + else { + if (allDone(farmer)) { + currentLevelState = levelState.ALLDONE; + } + else{ + currentLevelState = levelState.NOTDONE; + } + } + return currentLevelState; } - + From e12c6a786949cd74df172464dc9cc1fce270459c Mon Sep 17 00:00:00 2001 From: Notahotdog-Umar Moiz Date: Thu, 24 Oct 2019 12:29:17 +0800 Subject: [PATCH 4/4] added Feedback --- src/main/java/Farmio/Level.java | 72 ++++++++++++++++++++++++++---- src/main/resources/levels/1.1.json | 3 +- src/main/resources/levels/1.2.json | 3 +- src/main/resources/levels/1.3.json | 3 +- src/main/resources/levels/1.4.json | 1 + src/main/resources/levels/1.5.json | 1 + src/main/resources/levels/1.6.json | 1 + 7 files changed, 73 insertions(+), 11 deletions(-) diff --git a/src/main/java/Farmio/Level.java b/src/main/java/Farmio/Level.java index f4c281dae7..8c2fa9a2dd 100644 --- a/src/main/java/Farmio/Level.java +++ b/src/main/java/Farmio/Level.java @@ -1,6 +1,7 @@ package Farmio; import Places.Farm; +import Places.WheatFarm; import UserCode.Conditions.BooleanCondition; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -12,7 +13,6 @@ public class Level { ArrayList narratives; String filePath; - int endMoney; int endWheatSeed; int endWheatGreen; int endWheatRipe; @@ -21,6 +21,8 @@ public class Level { int endCow; int endCowMilk; int location; + int gold; + int deadline; public Level(JSONObject object, Farmer farmer) { JSONArray array = (JSONArray) object.get("narratives"); @@ -37,6 +39,7 @@ public Level(JSONObject object, Farmer farmer) { endChickenEggs = 0; endCow = 0; endCowMilk = 0; + deadline = Math.toIntExact((Long) object.get("deadline")); // location = Math.toIntExact((Long) object.get("location")); @@ -62,38 +65,91 @@ public boolean checkDeadlineExceeded(int currentDay){ } public boolean allDone(Farmer farmer){ - int gold = farmer.getMoney(); //Wheat Farm int WheatSeed = farmer.wheatFarm.getSeeds(); int WheatGreen = farmer.wheatFarm.getGreenWheat(); - int WheatRipe = farmer.wheatFarm.getRipeWheat(); + int WheatRipe = farmer.wheatFarm.getWheat(); + return (WheatGreen == endWheatGreen) && (WheatRipe == endWheatRipe) && (endWheatSeed == WheatSeed); - return (gold == endMoney ) && (WheatGreen == endWheatGreen) && (WheatRipe == endWheatRipe) && (endWheatSeed == WheatSeed); + + //Cow Farm } public objectiveResult checkAnswer(Farmio farmio){ if (farmio.getFarmer().isHasfailedCurrentTask()) { return objectiveResult.INVALID; } + + Farmer farmer = farmio.getFarmer(); int day = farmer.getDay(); objectiveResult currentLevelState; if(checkDeadlineExceeded(day)){ - currentLevelState = levelState.FAILED; + currentLevelState = objectiveResult.FAILED; + getFeedback(farmer, currentLevelState); } else { if (allDone(farmer)) { - currentLevelState = levelState.ALLDONE; + currentLevelState = objectiveResult.DONE; } else{ - currentLevelState = levelState.NOTDONE; + currentLevelState = objectiveResult.NOT_DONE; } } + getFeedback(farmer, currentLevelState); return currentLevelState; } - + public String checkIncompleteObjectives (Farmer farmer){ + //compare the differences + //check the level types + String output = ""; + int WheatSeed = farmer.wheatFarm.getSeeds(); + int WheatGreen = farmer.wheatFarm.getGreenWheat(); + int WheatRipe = farmer.wheatFarm.getWheat(); + if(WheatSeed != endWheatSeed){ + int balancedWheatSeed = endWheatSeed - WheatSeed; + output += "\nWheatSeed left :" + balancedWheatSeed; + } + else { + output += "\nWheatSeed Completed"; + } + if(WheatGreen != endWheatGreen){ + int balancedWheatGreen = endWheatGreen - WheatGreen; + output += "\n WheatGreen left :" + balancedWheatGreen; + } + else { + output += "\nWheatGreen Completed"; + } + if(WheatRipe != endWheatRipe){ + int balancedWheatRipe = endWheatRipe - WheatRipe; + output += "\nWheatRipe left :" + balancedWheatRipe; + } + else { + output += "\nWheatRipe Completed"; + } + + return output; + } + + + public String getFeedback( Farmer farmer, objectiveResult currentLevelState ){ + //get Feedback on whats not completed + //need to complete. + if(currentLevelState == objectiveResult.DONE){ + return "all tasks has been completed"; + } + + else if(currentLevelState == objectiveResult.NOT_DONE){ + return checkIncompleteObjectives(farmer); + } + + else if (currentLevelState == objectiveResult.FAILED){ + return "level failed"; + } + return ""; + } diff --git a/src/main/resources/levels/1.1.json b/src/main/resources/levels/1.1.json index 453e089f1f..964b440f97 100644 --- a/src/main/resources/levels/1.1.json +++ b/src/main/resources/levels/1.1.json @@ -16,5 +16,6 @@ "wheat_seed": 0, "wheat_green": 0, "wheat_ripe": 0, - "file_path": "Level1.1" + "file_path": "Level1.1", + "deadline" : 5; } \ No newline at end of file diff --git a/src/main/resources/levels/1.2.json b/src/main/resources/levels/1.2.json index 9cb29ec659..38b4c43330 100644 --- a/src/main/resources/levels/1.2.json +++ b/src/main/resources/levels/1.2.json @@ -9,5 +9,6 @@ "wheat_seed": 1, "wheat_green": 0, "wheat_ripe": 0, - "file_path": "Level1.2" + "file_path": "Level1.2", + "deadline" : 5, } \ No newline at end of file diff --git a/src/main/resources/levels/1.3.json b/src/main/resources/levels/1.3.json index 4a26cd2b34..2f2ad85b67 100644 --- a/src/main/resources/levels/1.3.json +++ b/src/main/resources/levels/1.3.json @@ -8,5 +8,6 @@ "wheat_seed": 0, "wheat_green": 1, "wheat_ripe": 0, - "file_path": "Level1.3" + "deadline" : 5, + "file_path": "Level1.3", } \ No newline at end of file diff --git a/src/main/resources/levels/1.4.json b/src/main/resources/levels/1.4.json index 951ca8c39a..68b4496280 100644 --- a/src/main/resources/levels/1.4.json +++ b/src/main/resources/levels/1.4.json @@ -12,5 +12,6 @@ "wheat_seed": 0, "wheat_green": 0, "wheat_ripe": 1, + "deadline" : 5, "file_path": "Level1.4" } diff --git a/src/main/resources/levels/1.5.json b/src/main/resources/levels/1.5.json index 400bc57f00..3014b5c824 100644 --- a/src/main/resources/levels/1.5.json +++ b/src/main/resources/levels/1.5.json @@ -7,5 +7,6 @@ "wheat_seed": 0, "wheat_green": 0, "wheat_ripe": 0, + "deadline" : 5, "file_path": "Level1.5" } diff --git a/src/main/resources/levels/1.6.json b/src/main/resources/levels/1.6.json index 947c4777df..00c9aa3726 100644 --- a/src/main/resources/levels/1.6.json +++ b/src/main/resources/levels/1.6.json @@ -9,5 +9,6 @@ "wheat_seed": 0, "wheat_green": 0, "wheat_ripe": 0, + "deadline" : 5, "file_path": "Level1.6" } \ No newline at end of file