Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from BEAN-Tastic/Sam/fix
Browse files Browse the repository at this point in the history
fix double double toil and trouble
  • Loading branch information
SamanthaVS-BBD authored Mar 15, 2024
2 parents 2899e93 + 58be25f commit becd75c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/beantastic/player/PlayerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class PlayerManager {
private final List<PlayerClass> classList;
private final Scanner scanner;

private boolean canChooseCoffee;

public static Player getPlayer() { // TODO remove dummy once static migration is done
return null;
}
Expand All @@ -20,6 +22,7 @@ public PlayerManager (Logger logger, Scanner scanner, List<PlayerClass> classLis
this.logger = logger;
this.scanner = scanner;
this.classList = classList;
this.canChooseCoffee = false;
}

public Player createPlayer(){
Expand Down Expand Up @@ -53,16 +56,19 @@ private PlayerClass pickClass() {
%1$s
Description: %2$s"""
.formatted(playerClass.getName(), playerClass.getDescription()), () -> playerClass)).toList());
if(playerClassUserChoice.getChoice().outcome().get() == classList.get(1)){
PlayerClass playerClass = playerClassUserChoice.getChoice().outcome().get();
if(playerClass == classList.get(1) && !this.canChooseCoffee){
this.canChooseCoffee = true;
String message = "418 I'm a teapot - refused to brew coffee";
int length = message.length();
String border = "+" + "-".repeat(length + 2) + "+";

logger.writeln(border);
logger.writeln("| " + message + " |");
logger.writeln(border);
return pickClass();
}
return playerClassUserChoice.getChoice().outcome().get();
return playerClass;
}

private void displayCharacter(Player player){
Expand Down

0 comments on commit becd75c

Please sign in to comment.