RosettaCodeData/Task/Rock-paper-scissors/Yabasic/rock-paper-scissors.basic
2023-07-01 13:44:08 -04:00

78 lines
2 KiB
Text

REM Yabasic 2.763 version
WINNER = 1 : ACTION = 2 : LOSSER = 3
dim word$(10, 3)
for n = 0 to 9
read word$(n, WINNER), word$(n, ACTION), word$(n, LOSSER)
next n
repeat
clear screen
computerChoice$ = word$(ran(10), WINNER)
print "'Rock, Paper, Scissors, Lizard, Spock!' rules are:\n"
for n = 0 to 9
SimonSay(n)
next n
print "\nType your choice letter:"
print "(R)ock, (P)aper, (S)cissors, (L)izard, Spoc(K), (Q)uit\n"
k$ = upper$(inkey$)
if k$ = "Q" break
switch k$
case "R": humanChoice$ = "Rock" : break
case "P": humanChoice$ = "Paper" : break
case "S": humanChoice$ = "Scissors" : break
case "L": humanChoice$ = "Lizard" : break
case "K": humanChoice$ = "Spock" : break
end switch
print "Player chose ", humanChoice$, " and Computer chose ", computerChoice$
for n = 0 to 9
if word$(n, WINNER) = humanChoice$ and word$(n, LOSSER) = computerChoice$ then
SimonSay(n)
print "Winner was Player"
wp = wp + 1
break
elseif word$(n, WINNER) = computerChoice$ and word$(n, LOSSER) = humanChoice$ then
SimonSay(n)
print "Winner was Computer"
wc = wc + 1
break
end if
next n
if n = 10 then
print "Ouch!"
end if
punctuation()
print "\nPress any key to continue"
inkey$
until(k$ = "Q")
punctuation()
if wp > wc then
print "Player win"
elseif wc > wp then
print "Computer win"
else
print "Tie"
end if
end
sub SimonSay(n)
print word$(n, WINNER), " ", word$(n, ACTION), " ", word$(n, LOSSER)
end sub
sub punctuation()
print "\nPlayer = ", wp, "\tComputer = ", wc, "\n"
end sub
data "Scissors","cuts","Paper"
data "Paper","covers","Rock"
data "Rock","crushes","Lizard"
data "Lizard","poisons","Spock"
data "Spock","smashes","Scissors"
data "Scissors","decapites","Lizard"
data "Lizard","eats","Paper"
data "Paper","disproves","Spock"
data "Spock","vaporizes","Rock"
data "Rock","blunts","Scissors"