strict hard mode and help message

This commit is contained in:
adam committed 2025-01-27 09:20:10 +00:00
1 parent a179fed550
commit 8122eab5b4
1 file changed
+21 -3
+21 -3
View File
@@ -65,8 +65,9 @@ function select_random_word() {
function set_options() { function set_options() {
declare -g BORDER=1 declare -g BORDER=1
declare -g HARD_MODE=0 declare -g HARD_MODE=0
declare -g STRICT_HARD_MODE=0
while getopts "bw:Hh" OPT; do while getopts "bw:HSh" OPT; do
case "${OPT}" in case "${OPT}" in
b) b)
BORDER=0 BORDER=0
@@ -82,13 +83,28 @@ function set_options() {
H) H)
HARD_MODE=1 HARD_MODE=1
;; ;;
S)
HARD_MODE=1
STRICT_HARD_MODE=1
;;
h) h)
exit # add help message echo -e "Usage: <program_name> [OPTIONS]
Play a game for Wordle
Options:
-b Toggle borderless mode
-w Set target word
-H Enable hard mode
-S Enable strict hard mode (Cannot reuse grey letters)
-h Show this help message and exit"
exit
;; ;;
*) *)
;; ;;
esac esac
done done
shift $((OPTIND - 1))
} }
function init_board() { function init_board() {
@@ -161,7 +177,9 @@ function hard_mode_check() {
declare GUESS=$1 declare GUESS=$1
for (( i=0; i<WIDTH; i++ )); do for (( i=0; i<WIDTH; i++ )); do
[[ "${POOL}" == *${GUESS:i:1}* ]] || return 2 if [[ "${STRICT_HARD_MODE}" == 1 ]]; then
[[ "${POOL}" == *${GUESS:i:1}* ]] || return 2
fi
color_check "${GUESS:i:1}" $i && continue color_check "${GUESS:i:1}" $i && continue