Created
May 22, 2023 12:39
-
-
Save elderica/bab50e31ad0242fa866371621cbb82be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eux | |
player_hand=$( | |
zenity --list \ | |
--title "あなたの手は?" \ | |
--column="手" \ | |
"グー" \ | |
"チョキ" \ | |
"パー" | |
) | |
cpu_candidates=("グー" "チョキ" "パー") | |
h=$((RANDOM % 3)) | |
cpu_hand="${cpu_candidates[h]}" | |
if [[ "${player_hand}" = "${cpu_hand}" ]] | |
then | |
zenity --error --text="あいこです" | |
else | |
if [[ "${player_hand}" = "グー" && "${cpu_hand}" = "チョキ" ]] || [[ "${player_hand}" = "チョキ" && "${cpu_hand}" = "パー" ]] || [[ "${player_hand}" = "パー" && "${cpu_hand}" = "グー" ]] | |
then | |
zenity --info --text="あなたは${player_hand}、CPUは${cpu_hand}。あなたの勝ちです!" | |
else | |
zenity --warning --text="あなたは${player_hand}、CPUは${cpu_hand}。あなたの負けです..." | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment