Implemented config options

This commit is contained in:
Mysaa Java
2026-09-08 02:28:36 +02:00
parent 3b68f3f42f
commit 920e378dd5
11 changed files with 543 additions and 139 deletions
@@ -4,7 +4,6 @@ import java.util.List;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -47,58 +46,78 @@ public class Grid {
return this.getCards().length;
}
@EqualsAndHashCode
@AllArgsConstructor
@Getter
public static class Phase {
private boolean aHinting;
private boolean bHinting;
private boolean aGuessing;
private boolean bGuessing;
public enum Phase {
HINTING_A('A', ' ', false, false, false),
HINTING_B('B', ' ', false, false, false),
GUESSING_A(' ', 'A', false, false, false),
GUESSING_B(' ', 'B', false, false, false),
HINTING_BOTH('_', ' ', false, false, false),
SUDDEN_DEATH_BOTH(' ', '_', true, false, false),
SUDDEN_DEATH_A(' ', 'A', true, false, false),
SUDDEN_DEATH_B(' ', 'B', true, false, false),
GAME_ENDED(' ', ' ', false, true, false),
// We could go to sudden death OR wait for more hints
NEED_MORE_HINTS_A('A', ' ', false, false, false),
NEED_MORE_HINTS_B('B', ' ', false, false, false),
// We can wait for SUDDEN_DEATH to be unlocked, or wait for more hints
NEED_MORE_HINTS_OR_SUDDEN_DEATH_A('A', ' ', false, false, true),
NEED_MORE_HINTS_OR_SUDDEN_DEATH_B('B', ' ', false, false, true),
// We can only wait for suddenDeath to be unlocked
NEED_SUDDEN_DEATH(' ', ' ', true, false, true),
// We can either end guessing, or wait for possibility to do one more guess
WAITING_FOR_ONE_MORE_A(' ', 'A', false, false, false),
WAITING_FOR_ONE_MORE_B(' ', 'B', false, false, false),
// We should have lost the game, we win it if we unlock onlyOneGreenGreen
WIN_IF_GREEN_GREEN(' ', ' ', false, false, true);
// ' ' is none, 'A' is A, 'B' is B, '_' is both
private char hinting;
private char guessing;
private boolean suddenDeath;
boolean gameEnded;
private Phase(boolean aHinting,
boolean bHinting,
boolean aGuessing,
boolean bGuessing,
boolean suddenDeath,
boolean gameEnded) {
this.aHinting = aHinting;
this.bHinting = bHinting;
this.aGuessing = aGuessing;
this.bGuessing = bGuessing;
this.suddenDeath = suddenDeath;
this.gameEnded = gameEnded;
}
private boolean gameEnded;
private boolean locked;
public boolean isHinting(char player) {
return (player == 'A')?this.isAHinting():this.isBHinting();
return (this == HINTING_BOTH) || (this == ((player == 'A')?HINTING_A:HINTING_B));
}
public boolean isGuessing(char player) {
return (player == 'A')?this.isAGuessing():this.isBGuessing();
return (this == ((player == 'A')?GUESSING_A:GUESSING_B));
}
public boolean isAnyoneGuessing() {
return this.isAGuessing() || this.isBGuessing();
}
public static Phase bothHinting() {
return new Phase(true, true, false, false, false, false);
return isGuessing('A') || isGuessing('B');
}
public static Phase hinting(char player) {
return new Phase((player == 'A'), (player == 'B'), false, false, false, false);
return (player == '_')?HINTING_BOTH:((player == 'A')?HINTING_A:HINTING_B);
}
public static Phase guessing(char player) {
return new Phase(false, false, (player == 'A'), (player == 'B'), false, false);
}
public static Phase suddenDeathBoth() {
return new Phase(false, false, true, true, true, false);
return (player == 'A')?GUESSING_A:GUESSING_B;
}
public static Phase suddenDeathOnly(char player) {
return new Phase(false, false, player == 'A', player == 'B', true, false);
return (player == 'A')?SUDDEN_DEATH_A:SUDDEN_DEATH_B;
}
public static Phase gameEnded() {
return new Phase(false,false,false,false,false,true);
public static Phase needMoreHints(char player) {
return (player == 'A')?NEED_MORE_HINTS_A:NEED_MORE_HINTS_B;
}
public static Phase needMoreHintsOrSuddenDeath(char player) {
return (player == 'A')?NEED_MORE_HINTS_OR_SUDDEN_DEATH_A:NEED_MORE_HINTS_OR_SUDDEN_DEATH_B;
}
public static Phase waitingForOneMore(char player) {
return (player == 'A')?WAITING_FOR_ONE_MORE_A:WAITING_FOR_ONE_MORE_B;
}
public boolean isWaitingForOneMore() {
return this == WAITING_FOR_ONE_MORE_A || this == WAITING_FOR_ONE_MORE_B;
}
public boolean canPlay() {
return !this.isGameEnded() && !this.isLocked();
}
public boolean isNeedMoreHints() {
return this == NEED_MORE_HINTS_A || this == NEED_MORE_HINTS_B;
}
public boolean isNeedMoreHintsOrSuddenDeath() {
return this == NEED_MORE_HINTS_OR_SUDDEN_DEATH_A || this == NEED_MORE_HINTS_OR_SUDDEN_DEATH_B;
}
}