From fa0f4c8e7a1504201142681491efca08d75f63df Mon Sep 17 00:00:00 2001 From: JohnTYH Date: Thu, 24 Oct 2019 12:03:03 +0800 Subject: [PATCH 1/2] Condition haswheat and hasgrain updated --- .../Conditions/BooleanConditionType.class | Bin 1190 -> 1301 bytes .../Conditions/ConditionChecker$1.class | Bin 1146 -> 1146 bytes .../Conditions/ConditionChecker.class | Bin 2485 -> 2601 bytes src/main/java/Commands/CommandDayEnd.java | 2 +- src/main/java/Farmio/Farmer.java | 7 ++++--- src/main/java/Places/WheatFarm.java | 6 +++--- .../UserCode/Actions/SellWheatAction.java | 2 +- .../Conditions/BooleanConditionType.java | 2 ++ .../UserCode/Conditions/ConditionChecker.java | 7 +++++++ 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/build/classes/java/main/UserCode/Conditions/BooleanConditionType.class b/build/classes/java/main/UserCode/Conditions/BooleanConditionType.class index cd59b11f14ad8f8e3ce548c03b4f0da3458f530c..cfabc9eaab7a5e8cebd093a6cd2b5381b610f110 100644 GIT binary patch delta 527 zcmZvYJ5Lm07=@p?u-~`C5Ej^ly$CGGMY)5EC>LESLSk&DFcWCDFu_DEz>b23j*3k9 z3p7*=Atn<10Ve(g|BCT_zgSQ(#W{24ocDXrHV(3>#iV zlxZofS}Kv4tD1Oe8B$)eRFz*@YRa!Ib>($SLwUondH!y_Y!5m|9}YftzIo{D&SB@% z*Xz?iUiTASG90tTo9wecKQ+$Vm}#EHR2YmIQm87_6zU2M2D4lL%Whc;n|4iuAS_wO z5_c>Uj%CQP%t5J+tdz-+A|s6A(aiROMrBOC6+}TG&Nxq@gFD*I?w?Sh{%ZuaFG#k05}3M z*P!@cML@s=-SvO>^mNUA@aSK@f4{x~Q%-ywwgYz9b!ofo1w`yC3_WUrh(mQ8cr=tp z9!=##k68K0WqfyiHh=mwi!Ht14moCG$cvGc_d|M2LsnS}sZkGUC^Qvf>cy8eJB_49 z<)W)H2#cd+F_kPnh!P}SoDM!6x)_q;!A|2;b_+6rElQ82Qu(mc?61-nJuF=T%dE&` zX(z#?s5+hV|Gh5j`ZgP-e}Km(1I?HDR+{L!DsG&yaf@dsoxEV?vNC8~i;AE_RXCA~ R8S+z7()x|d$VIo<`T@r=A&vk5 diff --git a/build/classes/java/main/UserCode/Conditions/ConditionChecker$1.class b/build/classes/java/main/UserCode/Conditions/ConditionChecker$1.class index 772397d287183500bc9a807616ee7d89520cec09..d20d5e4c615b25d6bcdc4972ce71f52272c5daef 100644 GIT binary patch delta 17 Ycmeyx@rz@F0t>4OgDZpFWL1_>05RkQb^rhX delta 17 Ycmeyx@rz@F0t>4wgDZphWL1_>05O6DXaE2J diff --git a/build/classes/java/main/UserCode/Conditions/ConditionChecker.class b/build/classes/java/main/UserCode/Conditions/ConditionChecker.class index 2a40ad92938e4ecd6e74ecdf4ce627fc5d8f4cae..e0914b0ec999c61b3f97fc7decead32f3bf4c485 100644 GIT binary patch delta 892 zcmYk3$xl;J6vltA@3n96F|?L4)tRCc!3m2K0xIHwf;eCm(TZRZK?M{?iW+yiFfU>6 zhQ!DQj3r^Ad-wh;u8i^AS3-Qrz4trcJ@=gNJMY{2&(Yk^zboH?X5Khdu-_&{v%>)n zIvnD#!x35(cT}NPh1wKqSLm2cCC433(4mq~+H`Wt;WTF=Qt`Y)H$5ulg5o+%dMz$G zM7d;g+2o2zpT^>7S74x;xXD$QGzpVyF4yTdx#2RvO_N)S&$!$sp*BH-3JofBN1-8x zP42p68F9JCh{>qSea1}2T^{hz)AU&Ek;R0|BvU4jU7j%Q@|0n(L2uEknf^MaS7}iz zo0;s(4rQh^6zrVHjEsBljNke*o_jOFU!fPO!i<*=)oHWd+t9r6S|j0o3?;l?vnE$A z^HZOWhB%UagGBq})Z`2%m(dml1lTCMBPUoG*lZHy7LwS^7Kv=OvTe1%C&^T~?a3tq z^Ay+T(eoI2f(ycg)|i}7rlPDhN*G%)&OAY5L0^z6y5GH4I;fr|MMNl(e^g41pnCZ` zDPpuxPOGp=S**}q?h_J;4rl*mDp%?Ij0jgL45bz?$?-~}vl3eJs!P_nf5yso A!vFvP delta 770 zcmXYvT~8BH5Qd-aZuji2i>(C;Vo_15Qv3$NFGNB72Ju@IK?JmjScIzF82kZVm~2x2 z0f|Xt0>+XMqw&HU6Qf@EPrNk7Ia^M$b7tP1dFP$Ud0X|Na^l;+l}|uBa~@UfbJ~n>yifcaCxuLkJ@d2M(H2ByMdZI`|m2?ZF32; zgjFJ16vSR2Y8A~Qj7ek7oFp3ZDJn=16A^LgkO;dZ%S>#hL2`tXEo_xOjpAEG5>D7T zEm levelList = new ArrayList(Arrays.asList(1.1,1.2,1.3,1.4,1.5,1.6,2.1,2.2)); public Farmer() { - this.money = 10; - this.level = 1.1; + this.money = 95; + this.level = 1.6; this.day = 1; this.location = "WheatFarm"; this.wheatFarm = new WheatFarm(); @@ -177,8 +177,9 @@ public void startDay(Farmio farmio) throws FarmioException, FarmioFatalException } } - public void nextDay(Farmio farmio) throws FarmioException, FarmioFatalException { + public void nextDay() throws FarmioException, FarmioFatalException { wheatFarm.growSeedlings(); + day += 1; } diff --git a/src/main/java/Places/WheatFarm.java b/src/main/java/Places/WheatFarm.java index fdd5f486aa..3253fea8cf 100644 --- a/src/main/java/Places/WheatFarm.java +++ b/src/main/java/Places/WheatFarm.java @@ -20,11 +20,11 @@ public boolean hasSeeds() { } public boolean hasWheat() { - return grain > 0; + return wheat > 0; } - public boolean hasRipened() { - return wheat > 0; + public boolean hasGrain() { + return grain > 0; } public WheatFarm() { diff --git a/src/main/java/UserCode/Actions/SellWheatAction.java b/src/main/java/UserCode/Actions/SellWheatAction.java index dbf4c25c5b..9b05d8a237 100644 --- a/src/main/java/UserCode/Actions/SellWheatAction.java +++ b/src/main/java/UserCode/Actions/SellWheatAction.java @@ -15,7 +15,7 @@ public SellWheatAction() { @Override public void execute(Ui ui, Storage storage, Farmer farmer, Simulation simulation) throws FarmioFatalException, FarmioException { - if (!farmer.getWheatFarm().hasRipened() || !farmer.getLocation().equals("Market")) { + if (!farmer.getWheatFarm().hasWheat() || !farmer.getLocation().equals("Market")) { farmer.setTaskFailed(); simulation.animate("ErrorInExecution", 0); if (!farmer.getWheatFarm().hasWheat()) { diff --git a/src/main/java/UserCode/Conditions/BooleanConditionType.java b/src/main/java/UserCode/Conditions/BooleanConditionType.java index ee13bfb8c0..b1a8094049 100644 --- a/src/main/java/UserCode/Conditions/BooleanConditionType.java +++ b/src/main/java/UserCode/Conditions/BooleanConditionType.java @@ -2,6 +2,8 @@ public enum BooleanConditionType { hasSeeds, + hasWheat, + hasGrain, wheatRipened, wheatHarvested, TRUE diff --git a/src/main/java/UserCode/Conditions/ConditionChecker.java b/src/main/java/UserCode/Conditions/ConditionChecker.java index 60617adbad..f4822ecc38 100644 --- a/src/main/java/UserCode/Conditions/ConditionChecker.java +++ b/src/main/java/UserCode/Conditions/ConditionChecker.java @@ -12,6 +12,13 @@ public static boolean check(BooleanConditionType condition, Farmio farmio) { if (condition == BooleanConditionType.hasSeeds) { return farmio.getFarmer().getWheatFarm().hasSeeds(); } + if (condition == BooleanConditionType.hasWheat) { + return farmio.getFarmer().getWheatFarm().hasWheat() ; + } + if (condition == BooleanConditionType.hasGrain) + { + return farmio.getFarmer().getWheatFarm().hasGrain(); + } if (condition == BooleanConditionType.TRUE) { return true; } From 6de1e3cd7c840bce14485cd3664a9a5b51c3aeee Mon Sep 17 00:00:00 2001 From: JohnTYH Date: Thu, 24 Oct 2019 12:11:49 +0800 Subject: [PATCH 2/2] updated check condition and error for harvestwheat and sellwheat --- src/main/java/UserCode/Actions/HarvestWheatAction.java | 2 +- src/main/java/UserCode/Actions/SellWheatAction.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/UserCode/Actions/HarvestWheatAction.java b/src/main/java/UserCode/Actions/HarvestWheatAction.java index 6db5b5f5a8..a37f67d89d 100644 --- a/src/main/java/UserCode/Actions/HarvestWheatAction.java +++ b/src/main/java/UserCode/Actions/HarvestWheatAction.java @@ -23,7 +23,7 @@ public void execute(Ui ui, Storage storage, Farmer farmer, Simulation simulation farmer.setTaskFailed(); simulation.animate("ErrorInExecution", 0); if (!farmer.getWheatFarm().hasWheat()) { - ui.typeWriter("Error! you have attempted to harvest wheat despite not having any seedlings/\n"); + ui.typeWriter("Error! you have attempted to harvest wheat despite not having any wheat/\n"); } else { ui.typeWriter("Error! you have attempted to harvest wheat despite not being at the Wheatfarm/\n"); } diff --git a/src/main/java/UserCode/Actions/SellWheatAction.java b/src/main/java/UserCode/Actions/SellWheatAction.java index 9b05d8a237..4dde92099b 100644 --- a/src/main/java/UserCode/Actions/SellWheatAction.java +++ b/src/main/java/UserCode/Actions/SellWheatAction.java @@ -15,19 +15,19 @@ public SellWheatAction() { @Override public void execute(Ui ui, Storage storage, Farmer farmer, Simulation simulation) throws FarmioFatalException, FarmioException { - if (!farmer.getWheatFarm().hasWheat() || !farmer.getLocation().equals("Market")) { + if (!farmer.getWheatFarm().hasGrain() || !farmer.getLocation().equals("Market")) { farmer.setTaskFailed(); simulation.animate("ErrorInExecution", 0); - if (!farmer.getWheatFarm().hasWheat()) { - ui.typeWriter("Error! you have attempted to sell wheat despite not having any wheat/\n"); + if (!farmer.getWheatFarm().hasGrain()) { + ui.typeWriter("Error! you have attempted to sell grain despite not having any grain/\n"); } else { - ui.typeWriter("Error! you have attempted to sell wheat despite not being at the market/\n"); + ui.typeWriter("Error! you have attempted to sell grain despite not being at the market/\n"); } throw new FarmioException("Task Error!"); } try { simulation.animate("SellWheatSimulation", 0, 6); - ui.show("Selling wheat!"); + ui.show("Selling grain!"); farmer.earnMoney(farmer.getWheatFarm().sell()); simulation.animate(1000, "SellWheatSimulation", 7); } catch (Exception e) {