Skip to content

Commit cdd82ad

Browse files
fix(defect): Exception when taking out brew from cauldron when cook time 0
1 parent 9a15a9a commit cdd82ad

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/java/com/dre/brewery/BIngredients.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public BestRecipeResult getCookRecipeFull() {
361361
return result;
362362
} else {
363363
RecipeEvaluation eval = found.eval();
364-
eval.fatal(new BrewDefect.CookTimeMismatch(cookedTime, 0));
364+
eval.fatal(new BrewDefect.CookingNotNeeded());
365365
return new BestRecipeResult.Error(found.recipe(), eval);
366366
}
367367
}

src/main/java/com/dre/brewery/BrewDefect.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ public String toString() {
107107
}
108108
}
109109

110+
record CookingNotNeeded() implements BrewDefect {
111+
@Override
112+
public List<String> getMessages(Lang lang) {
113+
return lang.getEntries("Defect_Overcooked");
114+
}
115+
116+
@Override
117+
public String toString() {
118+
return "CookingNotNeeded{}";
119+
}
120+
}
121+
110122
record CookTimeMismatch(int actual, int needed) implements BrewDefect {
111123
public CookTimeMismatch {
112124
if (actual == needed) {

src/main/java/com/dre/brewery/commands/subcommands/SimulateCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public Status parse(String arg) {
271271

272272
case COOK -> {
273273
int cookedTime = BUtil.parseInt(arg).orElse(-1);
274-
if (cookedTime <= 0) {
274+
if (cookedTime < 0) {
275275
return new Status.Error(ErrorType.COOK, arg);
276276
}
277277
this.cookedTime = cookedTime;

src/main/resources/languages/en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ CMD_Distilled: '&aDistilled brew &v1 times'
4242
CMD_Aged: '&aAged brew for &v1 years'
4343
CMD_Invalid_Option: '&c"&v1" is not a valid option'
4444
CMD_Duplicate_Option: '&cDuplicate option "&v1"'
45-
CMD_Invalid_Cook_Time: '&cCook time "&v1" must be a positive integer'
45+
CMD_Invalid_Cook_Time: '&cCook time "&v1" must be a non-negative integer'
4646
CMD_Invalid_Distill_Runs: '&cDistill runs "&v1" must be a positive integer'
4747
CMD_Invalid_Wood_Type: '&cInvalid barrel type "&v1"'
4848
CMD_Invalid_Age_Time: '&cAge time "&v1" must be a positive number'

0 commit comments

Comments
 (0)