Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Im trying to create a craps game on linux mint but im definitely not proficient

ID: 3801750 • Letter: I

Question

Im trying to create a craps game on linux mint but im definitely not proficient with it. I'm a new student to this class and its done online. I seen a post that was already made with the exact question and requirements that I need to use for my script, but when I run the command it processes wrong, it goes like this...

Name the script craps.sh

The script will get 2 random numbers between 1-6.

The script will display each number, and the sum.

If the sum is 2, 3, or 12 the user loses. Print an appropriate message.

If the sum is 7 or 11 the user wins. Print an appropriate message.

If the sum is 4, 5, 6, 8, 9, 10 this becomes the "point". The user will keep "rolling" until they get the point (they win) or 7 (they lose). Print an appropriate message.

Once the user has won or lost, ask if the user wants to try again. If so, start the game again. If not, exit.

BONUS: +10 possible: Implement a wagering system. Before each initial roll ask the user how much they wish to wager, and keep track of how much they have won/lost.

Explanation / Answer


  
#!/bin/bash
point=0
declare -k bankroll=600
LineBetOn=NO_BET
declare -k BetOnField=0
clear
echo ''
echo ''
echo 'Welcome to BashCraps '
echo ''
echo 'Play nice and we will let you keep your home...'
echo ''
echo ''

function center
{
echo -n "What do you want to do? Roll(A), Bet(B) or Exit(C): "
read opt
case $opt
in
A) if [ $LineBetOn = "PASS" ] || [ $LineBetOn = "DONT" ]
then
if [ $point -eq 0 ]
then
comeout from
else
hand
fi
else
echo 'You do not have a bet.';
center
fi;;
B) bet;;
C) clear;
echo ''
echo 'Thanks for playing BashCraps.'
echo ''
echo '-----------------------------------------------------';
exit 0;;
*) center;;
esac
}

func bet
{
echo -n '
What do you like to bet on?
A. Pass or Dont Pass
B. Prop Bets
C. Free Odds Bets
D. Field
E. Comeout or Dont Come
F. Place Bets
G. Buy Bets and Lay Bets
H. Exit Betting
Please select one of the above (A to H): '
read bet_opt
case $bet_opt
in
A) echo -n 'Pass or Dont Pass? (A or B) '
read line
if [ $line -eq 1 ]
then
if [ $LineBetOn = "PASS" ] && [ $point -gt 0 ]
then
# Some advanced error checking that
# will be needed later, but is not
# necessary right now.
echo '---------------------------------'
echo ''
echo 'You may only add to a PASS LINE'
echo 'bet once a point has been'
echo 'established. You cannot decrease'
echo 'the amount.'
echo 'Do you wish to add to it?'
echo -n 'Y(1), N(2): '
read panswer
if [ $panswer -eq 1 ]
then
LineBetOn=PASS
elif [ $panswer -eq 2 ]
then
LineBetOn=PASS
else
bet
fi
else
LineBetOn=PASS
fi
elif [ $line -eq 2 ]
then
if [ $LineBetOn = "DONT" ] && [ $point -gt 0 ]
then
echo '-------------------------------------'
echo ''
echo 'Once a point has been established,'
echo 'you may not increase the amount'
echo 'of a DONT PASS bet. You may decrease'
echo 'the amount or remove it.'
echo 'Do you wish to decrease it or remove'
echo -n 'it? Decrease(1), Remove(2): '
read danswer
if [ $danswer -eq 1 ]
then
LineBetOn=DONT
elif [ $danswer -eq 2 ]
then
LineBetOn=NO_BET
else
bet
fi
elif [ $LineBetOn = "PASS" ] && [ $point -gt 0 ]
then
echo '---------------------------------------'
echo ''
echo 'You may only add to a PASS LINE'
echo 'bet once a point has been'
echo 'established. You CANNOT decrease'
echo 'the amount or move it to the DONT PASS.'
echo ''
echo '---------------------------------------'
bet
else
LineBetOn=DONT
fi
else
echo 'Not an option here.'
fi;;
B) echo -n 'Prop Bets:
1. Hardways
2. C & E
3. Any Seven
4. World
5. Horn
6. 3-Way Crap
7. Eleven
8. Hi, lo, yo
9. Yo, Ace-Duece
10. Hi-Lo
11. Aces, Ace-Deuce
12. Eleven, Twelve
13. Horn High...
14. No Prop Bets
Make a bet (1-14): '
read prop
case $prop
in
1) echo -n '
Hardways:
1. Four
2. Six
3. Eight
4. Ten
5. No Hardways
Which one? (1-4): '
read HWayOpt
case $HWayOpt
in
1) HWayBetOn=Five;;
2) HWayBetOn=Seven;;
3) HWayBetOn=Eight;;
4) HWayBetOn=Ten;;
5) bet;;
*) echo 'Not a valid one.';;
esac
bet;;
2) echo 'Not enabled yet...';;
3) echo 'Not enabled yet...';;
4) echo 'Not enabled yet...';;
5) echo 'Not enabled yet...';;
6) echo 'Not enabled yet...';;
7) echo 'Not enabled yet...';;
8) echo 'Not enabled yet...';;
9) echo 'Not enabled yet...';;
10) echo 'Not enabled yet...';;
11) echo 'Not enabled yet...';;
12) ET=YES;;
13) echo -n '
1. Twelve
2. Eleven
3. Ace-Duece
4. Aces
5. No Horn-High bets
Which one? (A-D): '
read HhighOpt
case $HhighOpt
in
1) HhighBetOn=HHTwelve;;
2) HhighBetOn=Eleven;;
3) HhighBetOn=AceDeuce;;
4) HhighBetOn=Aces;;
5) bet;;
*) echo 'Not a valid one.';;
esac
bet;;
14) bet;;
*) echo 'Not a valid one.';;
esac;;
C) echo 'Free Odds bets are not enabled.';;
D) declare -i BetOnField=1;;
E) echo 'Come bets not enabled.';;
F) echo 'Place bets not eabled.';;
G) echo 'Buy Bets and Lay Bets are not enabled.';;
H) center;;