2016-09-03 02:24:14 -04:00
|
|
|
[ -f functions.sh ] && source functions.sh
|
|
|
|
cpu="$(shuf -n 1 -e PAPER ROCK SCISSORS)"
|
|
|
|
player="$3"
|
2013-07-18 12:40:25 -04:00
|
|
|
|
2016-09-03 02:24:14 -04:00
|
|
|
case "${player^^}" in
|
|
|
|
R|RO|ROC|ROCK)
|
|
|
|
player="ROCK"
|
2013-07-18 12:40:25 -04:00
|
|
|
;;
|
2016-09-03 02:24:14 -04:00
|
|
|
P|PA|PAP|PAPE|PAPER)
|
|
|
|
player="PAPER"
|
2013-07-18 12:40:25 -04:00
|
|
|
;;
|
2016-09-03 02:24:14 -04:00
|
|
|
S|SC|SCI|SCIS|SCISS|SCISSO|SCISSOR|SCISSORS)
|
|
|
|
player="SCISSORS"
|
2013-07-18 12:40:25 -04:00
|
|
|
;;
|
2016-09-03 02:24:14 -04:00
|
|
|
*)
|
|
|
|
player="INVALID"
|
2013-07-18 12:40:25 -04:00
|
|
|
esac
|
|
|
|
|
2016-09-03 10:25:55 -04:00
|
|
|
if [[ "$player" = "INVALID" ]]; then
|
2016-09-03 02:24:14 -04:00
|
|
|
msg "$2" "$1: Please select PAPER, ROCK, or SCISSORS."
|
2016-09-03 10:25:55 -04:00
|
|
|
elif [[ "$cpu" = "$player" ]]; then
|
2016-09-03 02:24:14 -04:00
|
|
|
msg "$2" "$1: You and I both selected $player, so we tied."
|
2016-09-03 10:25:55 -04:00
|
|
|
elif [[ "$cpu" = "PAPER" && "$player" != "SCISSORS" ]]; then
|
|
|
|
msg "$2" "$1: my $cpu beats your $player!"
|
|
|
|
elif [[ "$cpu" = "ROCK" && "$player" != "PAPER" ]]; then
|
|
|
|
msg "$2" "$1: my $cpu beats your $player!"
|
|
|
|
elif [[ "$cpu" = "SCISSORS" && "$player" != "ROCK" ]]; then
|
|
|
|
msg "$2" "$1: my $cpu beats your $player!"
|
|
|
|
elif [[ "$player" = "PAPER" && "$cpu" != "SCISSORS" ]]; then
|
2016-09-03 02:24:14 -04:00
|
|
|
msg "$2" "$1: your $player beats my $cpu!"
|
2016-09-03 10:25:55 -04:00
|
|
|
elif [[ "$player" = "ROCK" && "$cpu" != "PAPER" ]]; then
|
2016-09-03 02:24:14 -04:00
|
|
|
msg "$2" "$1: your $player beats my $cpu!"
|
2013-07-18 12:40:25 -04:00
|
|
|
else
|
2016-09-03 02:24:14 -04:00
|
|
|
msg "$2" "$1: your $player beats my $cpu!"
|
2013-07-18 12:40:25 -04:00
|
|
|
fi
|