#!/bin/bash
echo "<<<<< GAME STARTS! >>>>>"
choice='Big'
balance=1000
testtimes=3
while [ $choice != 'exit' ]
do
echo -e "Please choice Big or Small:"
read choice

創(chuàng)新互聯(lián)主要從事成都做網(wǎng)站、網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)七星關(guān)區(qū),十年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專(zhuān)業(yè),歡迎來(lái)電咨詢(xún)建站服務(wù):13518219792
if [ $choice == 'exit' ]
then
exit 0
fi
echo -e "How much you wanna bet :"
read amout
while [ $balance -lt $amout ]
do
echo "Enter amout is bigger than balance , try again !"
read amout
testtimes=$[ $testtimes -1 ]
if [ $testtimes -eq 1 ]
then
exit -1
fi
done
function roll_dice()
{
echo "<<<<< ROLL THE DICE! >>>>>"
number=3
points=0
while (( number > 0 ))
do
point=$(($RANDOM%6+1))
echo $point
number=`expr $number-1`
let "points+=$point"
done
}
roll_dice
function caparoll_result()
{
if [ $points -le 18 ] && [ $points -ge 11 ]
then
result='Big'
elif [ $points -le 10 ] && [ $points -ge 3 ]
then
result='Small'
else
echo 'Error'
exit -1
fi
}
caparoll_result $points
if [ $choice == 'Big' ] || [ $choice == 'Small' ]
then
if [ $choice == $result ]
then
echo "The points are $points You win !"
let "balance+=amout"
echo "The gained $amout , You have $balance now !"
else
echo "The points are $points You lose !"
let "balance-=amout"
echo "The lost $amout , You have $balance now !"
fi
else
echo "Invalid Words"
fi
if [ $balance -eq 0 ]
then
echo "Game Over !"
exit 0
fi
done
本文名稱(chēng):bash小腳本色子游戲
網(wǎng)站路徑:http://chinadenli.net/article30/gsgcpo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、網(wǎng)站設(shè)計(jì)、App開(kāi)發(fā)、面包屑導(dǎo)航、網(wǎng)站制作、定制開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)