Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
44
Task/21-game/AppleScript/21-game.applescript
Normal file
44
Task/21-game/AppleScript/21-game.applescript
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
repeat
|
||||
set pstart to some item of {true, false}
|
||||
if pstart then
|
||||
display alert "You go first!"
|
||||
set score to 0
|
||||
else
|
||||
display alert "The computer goes first!"
|
||||
log "The computer chose 1"
|
||||
log "The score is now 1"
|
||||
set score to 1
|
||||
end if
|
||||
repeat
|
||||
repeat
|
||||
set input to display alert "Choose a number:" buttons {1, 2, 3}
|
||||
set pmove to button returned of input
|
||||
set score to score + pmove
|
||||
if score > 21 then
|
||||
display alert "You can't go above 21! Try again."
|
||||
set score to score - pmove
|
||||
else
|
||||
exit repeat
|
||||
end if
|
||||
end repeat
|
||||
log "You chose " & pmove
|
||||
log "The score is now " & score
|
||||
if score = 21 then
|
||||
log "You win!"
|
||||
exit repeat
|
||||
else if score mod 4 is not 1 then
|
||||
set cmove to (5 - (score mod 4)) mod 4
|
||||
else
|
||||
set cmove to random number from 1 to 3
|
||||
end if
|
||||
set score to score + cmove
|
||||
log "The computer chose " & cmove
|
||||
log "The score is now " & score
|
||||
if score = 21 then
|
||||
log "Too bad! The computer wins."
|
||||
exit repeat
|
||||
end if
|
||||
end repeat
|
||||
set again to display alert "Play again?" buttons {"Yes", "No"}
|
||||
if button returned of again = "No" then exit repeat
|
||||
end repeat
|
||||
Loading…
Add table
Add a link
Reference in a new issue