Skip to content

Commit

Permalink
Merge pull request #217 from notahotdog/master
Browse files Browse the repository at this point in the history
checkstyle fix - Condition and Level
  • Loading branch information
notahotdog authored Oct 30, 2019
2 parents 3c29509 + 8fd30d2 commit 6900694
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 130 deletions.
6 changes: 2 additions & 4 deletions src/main/java/commands/CommandAddName.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public void execute(Farmio farmio) throws FarmioException, FarmioFatalException
if (name.equals("MENU")) {
ui.typeWriter("Keywords cannot be used as a character name.", false);
ui.typeWriter("Enter your name:", false);
}
else if (name.length() <= 15 && name.length() > 0 && (name.matches("[a-zA-Z0-9]+") || name.contains("_"))) {
} else if (name.length() <= 15 && name.length() > 0 && (name.matches("[a-zA-Z0-9]+") || name.contains("_"))) {
farmio.getFarmer().inputName(name);
ui.typeWriter("Welcome Farmer "
+ name
Expand All @@ -34,8 +33,7 @@ else if (name.length() <= 15 && name.length() > 0 && (name.matches("[a-zA-Z0-9]+
} else if (name.length() > 15) {
ui.typeWriter("Your name can have a maximum of 15 characters.", false);
ui.typeWriter("Enter your name:", false);
}
else {
} else {
ui.typeWriter("Special Characters are not allowed", false);
ui.typeWriter("Enter your name:", false);
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/commands/CommandCheckObjectives.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ public class CommandCheckObjectives extends Command {
*/
@Override
public void execute(Farmio farmio) throws FarmioFatalException {
Level.objectiveResult answer = farmio.getLevel().checkAnswer(farmio);
Level.ObjectiveResult answer = farmio.getLevel().checkAnswer(farmio);
farmio.getSimulation().simulate();
//farmio.getUi().typeWriter(farmio.getLevel().getFeedback(farmio), false); // feedbacks

List<String> feedback = farmio.getLevel().getFeedback(farmio);
for(String i : feedback){
for (String i : feedback) {
farmio.getUi().typeWriter(i,false);
}

if (answer == Level.objectiveResult.NOT_DONE) {
if (answer == Level.ObjectiveResult.NOT_DONE) {
farmio.setStage(Farmio.Stage.DAY_END);
} else if (answer == Level.objectiveResult.DONE) {
} else if (answer == Level.ObjectiveResult.DONE) {
farmio.setStage(Farmio.Stage.LEVEL_END);
} else if (answer == Level.objectiveResult.FAILED) {
} else if (answer == Level.ObjectiveResult.FAILED) {
farmio.setStage(Farmio.Stage.LEVEL_FAILED);
} else if (answer == Level.objectiveResult.INVALID) {
} else if (answer == Level.ObjectiveResult.INVALID) {
farmio.setStage(Farmio.Stage.LEVEL_FAILED);
}
}
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/commands/CommandMenuInGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,59 +23,59 @@ public void execute(Farmio farmio) throws FarmioFatalException {
double level = farmio.getFarmer().getLevel();
Ui ui = farmio.getUi();

if(input.equals("actions")) {
if(level == 1.1) {
if (input.equals("actions")) {
if (level == 1.1) {
farmio.getSimulation().simulate("ActionList", 11,true);
}
if(level == 1.2) {
if (level == 1.2) {
farmio.getSimulation().simulate("ActionList", 12,true);
}
if(level == 1.3) {
if (level == 1.3) {
farmio.getSimulation().simulate("ActionList", 13,true);
}
if(level == 1.4) {
if (level == 1.4) {
farmio.getSimulation().simulate("ActionList", 14,true);
}
if(level == 1.5) {
if (level == 1.5) {
farmio.getSimulation().simulate("ActionList", 15,true);
}
if(level == 1.6) {
if (level == 1.6) {
farmio.getSimulation().simulate("ActionList", 15,true);
}
}
if(input.equals("conditions")) {
if(level == 1.1) {
if (input.equals("conditions")) {
if (level == 1.1) {
farmio.getSimulation().simulate("ConditionList", 11,true);
}
if(level == 1.2) {
if (level == 1.2) {
farmio.getSimulation().simulate("ConditionList", 11,true);
}
if(level == 1.3) {
if (level == 1.3) {
farmio.getSimulation().simulate("ConditionList", 11,true);
}
if(level == 1.4) {
if (level == 1.4) {
farmio.getSimulation().simulate("ConditionList", 14,true);
}
if(level == 1.5) {
if (level == 1.5) {
farmio.getSimulation().simulate("ConditionList", 16,true);
}
if(level == 1.6) {
if (level == 1.6) {
farmio.getSimulation().simulate("ConditionList", 16,true);
}
}

if(input.equals("market")) {
if(level < 1.5) {
if (input.equals("market")) {
if (level < 1.5) {
farmio.getSimulation().simulate("MarketList", 4,true);
} else if(level < 2) {
} else if (level < 2) {
farmio.getSimulation().simulate("MarketList", 1, true);
} else if(level < 3) {
} else if (level < 3) {
farmio.getSimulation().simulate("MarketList", 2,true);
} else if(level < 4) {
} else if (level < 4) {
farmio.getSimulation().simulate("MarketList", 3,true);
}
}
if(input.equals("")) {
if (input.equals("")) {
Menu.show(farmio, true);
}
farmio.setStage(Farmio.Stage.MENU);
Expand Down
Loading

0 comments on commit 6900694

Please sign in to comment.