#!/bin/bash if [ $# != 1 ]; then echo "Wrong parameter count!" exit 1 fi #the string comparison doesn't work function testExit { if [ $1 == "exit" ]; then exit 0 fi } cash=$1 while [ $cash != 0 ]; do read -p "Choose your bet (1: color, 2: dosen, 3: number): " choice testExit choice while [ $choice -lt 1 -o $choice -gt 3 ]; do clear read -p "Choose your bet (1: color, 2: dosen, 3: number): " choice testExit choice done if [ $choice == 1 ]; then read -p "Choose a color (1: red, 2: black): " color testExit color while [ $color -lt 1 -o $color -gt 2 ]; do clear read -p "Choose a color (1: red, 2: black): " color testExit color done elif [ $choice == 2 ]; then read -p "Choose a dosen (1: 1-12, 2: 13-24, 3: 25-36): " dosen testExit dosen while [ $dosen -lt 1 -o $dosen -gt 3 ]; do clear read -p "Choose a dosen (1: 1-12, 2: 13-24, 3: 25-36): " dosen testExit dosen done elif [ $choice == 3 ]; then read -p "Choose a number (0-36): " number testExit number while [ $number -lt 0 -o $number -gt 36 ]; do clear read -p "Choose a number (0-36): " number testExit number done fi read -p "Make your bet: " bet testExit bet while [ $bet -lt 0 -o $bet -gt $cash ]; do clear if [ $bet -gt $cash ]; then echo "You don't have enough cash! Your current balance: " $cash fi read -p "Make your bet: " bet testExit bet done cash=$((cash-bet)) randNum=$(($RANDOM % 36)) colours="zpfpfpfpfpffpfpfpfppfpfpfpfpffpfpfpfp" randColor="0" if [ ${colours:$randNum:1} == "p" ]; then randColor="1" elif [ ${colours:$randNum:1} == "f" ]; then randColor="2" fi clear echo "The result is " $randColor $randNum if [ $choice == 1 ]; then if [ $color == $randColor ]; then echo "You won!" echo "Your winning is " $((bet*2)) cash=$((cash+(bet*2))) else echo "You lost!" fi elif [ $choice == 2 ]; then min=$(((dosen-1)*12+1)) max=$(((dosen-1)*12+12)) if [ $randNum -gt $min -a $randNum -lt $max ]; then echo "You won!" echo "Your winning is " $((bet*3)) cash=$((cash+(bet*3))) else echo "You lost!" fi elif [ $choice == 3 ]; then if [ $randNum == $number ]; then echo "You won!" echo "Your winning is " $((bet*35)) cash=$((cash+(bet*35))) else echo "You lost!" fi fi if [ $cash == 0 ]; then echo "You lost all your money!" fi done