79 lines
1.8 KiB
Bash
Executable File
79 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Players Turn
|
|
read -p "Choose your weapon [rock, paper, scissors]: " wplay
|
|
if [[ $wplay == "rock" ]]
|
|
then
|
|
nplay="1"
|
|
echo "You chose rock."
|
|
elif [[ $wplay == "paper" ]]
|
|
then
|
|
nplay="2"
|
|
echo "You chose paper."
|
|
elif [[ $wplay == "scissors" ]]
|
|
then
|
|
nplay="3"
|
|
echo "You chose scissors."
|
|
fi
|
|
|
|
# Computers Turn
|
|
ncomp="$(shuf -n 1 -i 1-4)"
|
|
if [[ "$ncomp" == "1" ]]
|
|
then
|
|
wcomp="rock"
|
|
echo "Computer got rock."
|
|
elif [[ "$ncomp" == "2" ]]
|
|
then
|
|
wcomp="paper"
|
|
echo "Computer got paper."
|
|
elif [[ "$ncomp" == "3" ]]
|
|
then
|
|
wcomp="scissors"
|
|
echo "Computer got scissors."
|
|
elif [[ "$ncomp" == "4" ]]
|
|
then
|
|
wcomp="shotgun"
|
|
echo "Computer got shotgun."
|
|
else
|
|
echo "fail"
|
|
fi
|
|
|
|
# Fight
|
|
if [[ "$wcomp" == "shotgun" ]]
|
|
then
|
|
echo "Computer has shotgun, you lose"
|
|
beep -l 250 -f 69
|
|
elif [[ "$nplay" == "$ncomp" ]]
|
|
then
|
|
echo "Draw."
|
|
beep -l 250 -f 420 ; beep -l 250 -f 420
|
|
else
|
|
if [[ "$nplay" == 1 ]] && [[ "$ncomp" == 2 ]]
|
|
then
|
|
echo "Your rock loses against computers paper."
|
|
beep -l 250 -f 750 ; beep -l 500 -f 250
|
|
elif [[ "$nplay" == 1 ]] && [[ "$ncomp" == 3 ]]
|
|
then
|
|
echo "Your rock wins against computers scissors."
|
|
beep -l 100 -f 1250 ; beep -l 500 -f 1500
|
|
elif [[ "$nplay" == 2 ]] && [[ "$ncomp" == 1 ]]
|
|
then
|
|
echo "Your paper wins against computers rock."
|
|
beep -l 100 -f 1250 ; beep -l 500 -f 1500
|
|
elif [[ "$nplay" == 2 ]] && [[ "$ncomp" == 3 ]]
|
|
then
|
|
echo "Your paper loses against computers scissors."
|
|
beep -l 250 -f 750 ; beep -l 500 -f 250
|
|
elif [[ "$nplay" == 3 ]] && [[ "$ncomp" == 1 ]]
|
|
then
|
|
echo "Your scissors loses against computers rock."
|
|
beep -l 250 -f 750 ; beep -l 500 -f 250
|
|
elif [[ "$nplay" == 3 ]] && [[ "$ncomp" == 2 ]]
|
|
then
|
|
echo "Your scissors wins against computers paper."
|
|
beep -l 100 -f 1250 ; beep -l 500 -f 1500
|
|
else
|
|
echo "sum ting wong"
|
|
fi
|
|
fi
|