Skip to content

Commit

Permalink
Condition haswheat and hasgrian updated
Browse files Browse the repository at this point in the history
Condition haswheat and hasgrian updated
  • Loading branch information
JohnTYH authored Oct 24, 2019
2 parents 221cf95 + fa0f4c8 commit 7856efd
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 8 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified build/classes/java/main/UserCode/Conditions/ConditionChecker.class
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/Commands/CommandDayEnd.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void execute(Farmio farmio) throws FarmioException, FarmioFatalException
Farmer farmer = farmio.getFarmer();
farmio.getSimulation().animate("DayEnd", 0, true);
farmio.getUi().show("Press ENTER to start your next day!");
farmer.nextDay(farmio);
farmer.nextDay();
farmio.setStage(Farmio.Stage.DAY_START);
}
}
7 changes: 4 additions & 3 deletions src/main/java/Farmio/Farmer.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class Farmer {
private ArrayList<Double> levelList = new ArrayList<Double>(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();
Expand Down Expand Up @@ -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;
}


Expand Down
6 changes: 3 additions & 3 deletions src/main/java/Places/WheatFarm.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/UserCode/Actions/SellWheatAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/UserCode/Conditions/BooleanConditionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

public enum BooleanConditionType {
hasSeeds,
hasWheat,
hasGrain,
wheatRipened,
wheatHarvested,
TRUE
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/UserCode/Conditions/ConditionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7856efd

Please sign in to comment.