' "Slot Machine"
define game <Slot Machine>
asl-version <350>
gametype singleplayer
start <Casino>
game author <Ste Edwards>
game version <1.0>
game copyright <© 2005 Ste Edwards.>
startscript {
msg <|bWelcome to Slot Machine.|xb|nType |cr/slotmachine play|cb to gamble.|nGood Luck!>
}
afterturn msg <|bYou have %credits% remaining credits.|xb>
define variable <credits>
type numeric
value <25>
display <Credits: !>
onchange if ( %credits% <= 0 ) then do <gameover>
end define
end define
define room <Casino>
prefix <the>
command </slotmachine play> {
dec <credits; 1>
set numeric <result1; $rand(1; 3)$>
set numeric <result2; $rand(1; 3)$>
set numeric <result3; $rand(1; 3)$>
if ( %result1% = 1 ) then set string <dice1; Orange> else {if ( %result1% = 2 ) then set string <dice1; Apple> else set string <dice1; Pear>}
if ( %result2% = 1 ) then set string <dice2; Orange> else {if ( %result2% = 2 ) then set string <dice2; Apple> else set string <dice2; Pear>}
if ( %result3% = 1 ) then set string <dice3; Orange> else {if ( %result3% = 2 ) then set string <dice3; Apple> else set string <dice3; Pear>}
if ( #dice1# = Orange ) and ( #dice2# = Orange ) and ( #dice3# = Orange ) then {
msg <|n|b|crYOU HAVE WON 5 CREDITS!|xb|cb>
inc <credits; 5>
}
else
msg <|b#dice1#, #dice2#, #dice3#|xb>
}
end define
define procedure <gameover>
playerlose
end define
define text <lose>
|b|crGAME OVER|cb|xb
end define
startscript {
msg <|bWelcome to Slot Machine.|xb|nType |cr/slotmachine play|cb to gamble.|nGood Luck!>
set string <result[1]; Orange>
set string <result[2]; Apple>
set string <result[3]; Pear>
}command </slotmachine play> {
dec <credits>
set numeric <result.1; $rand(1; 3)$ >
set numeric <result.2; $rand(1; 3)$ >
set numeric <result.3; $rand(1; 3)$ >
set string <dice.1; #result[result.1]# >
set string <dice.2; #result[result.2]# >
set string <dice.3; #result[result.3]# >
if ( #dice1# = Orange ) and ( #dice2# = Orange ) and ( #dice3# = Orange ) then {
msg <|n|b|crYOU HAVE WON 5 CREDITS!|xb|cb>
inc <credits; 5>
}
else msg <|b#dice1#, #dice2#, #dice3#|xb>
}