From a2721f422aeef1052471578144a603862888ce41 Mon Sep 17 00:00:00 2001 From: JoeStrout Date: Tue, 31 Jan 2023 21:46:09 -0700 Subject: [PATCH] Added MiniScript port of 29_Craps. --- .../29_Craps/MiniScript/README.md | 3 + .../29_Craps/MiniScript/craps.ms | 87 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 00_Alternate_Languages/29_Craps/MiniScript/README.md create mode 100644 00_Alternate_Languages/29_Craps/MiniScript/craps.ms diff --git a/00_Alternate_Languages/29_Craps/MiniScript/README.md b/00_Alternate_Languages/29_Craps/MiniScript/README.md new file mode 100644 index 00000000..f52e8746 --- /dev/null +++ b/00_Alternate_Languages/29_Craps/MiniScript/README.md @@ -0,0 +1,3 @@ +Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html). + +Conversion to [MiniScript](https://miniscript.org). diff --git a/00_Alternate_Languages/29_Craps/MiniScript/craps.ms b/00_Alternate_Languages/29_Craps/MiniScript/craps.ms new file mode 100644 index 00000000..900ba5d4 --- /dev/null +++ b/00_Alternate_Languages/29_Craps/MiniScript/craps.ms @@ -0,0 +1,87 @@ +// Craps +// Ported from BASIC to MiniScript by Joe Strout (2023) + +print " "*33 + "CRAPS" +print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" +print; print; print + +print "2,3,12 are losers; 4,5,6,8,9,10 are points; 7,11 are natural winners." +winnings = 0 + +rollDice = function + wait 0.5 // (a small delay makes the game more dramatic) + return ceil(rnd*6) + ceil(rnd*6) +end function + +doOneBet = function + while true + wager = input("Input the amount of your wager: ").val + if wager > 0 then break + end while + print "I will now throw the dice." + result = 0 // 1 if we win, 2 if win double, -1 if we lose + roll = rollDice + if roll == 7 or roll == 11 then + print roll + "- natural....a winner!!!!" + print roll + " pays even money, you win " + wager + " dollars" + result = 1 + else if roll == 2 then + print "2- snake eyes....you lose." + print "You lose " + wager + " dollars." + result = -1 + else if roll == 3 or roll == 12 then + print roll + " - craps...you lose." + print "You lose " + wager + " dollars." + result = -1 + else + point = roll + print point + " is the point. I will roll again" + while true + roll = rollDice + if roll == 7 then + print "7 - craps. You lose." + print "You lose $" + wager + result = -1 + break + else if roll == point then + print roll + "- a winner.........CONGRATS!!!!!!!!" + print roll + " at 2 to 1 odds pays you...let me see..." + + (2*wager) + " dollars" + result = 2 + break + else + print roll + " - no point. I will roll again" + end if + end while + end if + globals.winnings += wager * result +end function + +// Main loop. +while true + doOneBet + + while true + // Why you have to enter 5 to continue is anyone's guess, + // but that's what the original program did. + again = input(" If you want to play again print 5 if not print 2: ") + if again == "5" or again == "2" then break + end while + + if winnings < 0 then + print "You are now under $" + (-winnings) + else if winnings > 0 then + print "You are now ahead $" + winnings + else + print "You are now even at 0" + end if + if again != "5" then break +end while + +if winnings < 0 then + print "Too bad, you are in the hole. Come again." +else if winnings > 0 then + print "Congratulations---You came out a winner. Come again!" +else + print "Congrtulations---You came out even, not bad for an amateur" +end if