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
+22 -4
+22 -4
View File
@@ -65,8 +65,9 @@ function select_random_word() {
function set_options() {
declare -g BORDER=1
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
b)
BORDER=0
@@ -80,15 +81,30 @@ function set_options() {
fi
;;
H)
HARD_MODE=1
HARD_MODE=1
;;
S)
HARD_MODE=1
STRICT_HARD_MODE=1
;;
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
done
shift $((OPTIND - 1))
}
function init_board() {
@@ -161,7 +177,9 @@ function hard_mode_check() {
declare GUESS=$1
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