Skip to content

Instantly share code, notes, and snippets.

@tobeportable
Last active December 16, 2015 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobeportable/5389213 to your computer and use it in GitHub Desktop.
Save tobeportable/5389213 to your computer and use it in GitHub Desktop.
cf. description.md
# encoding: utf-8
class SimonGame < Adhearsion::CallController
attr_accessor :number, :attempt
def run
answer
while true
reset
play_simon
end
end
def play_simon
speak "New Game"
while true
@number << rand(2).to_s
@guess = get_guess
while @guess != @number
@errors += 1
if @errors >= 3
speak "<emphasis>Game Over.</emphasis> Your high score is <interpret-as='ordinal'>#{@number.length - 1}</interpret-as>"
return
end
speak "#{@errors} times wrong, try again smarty"
@guess = get_guess
end
speak 'good'
end
end
def get_guess
question = "<prosody rate='+25%'>#{@number.split('').join(' ')}}</prosody>"
result = ask question, :limit => @number.length
result.response
end
def reset
@errors = 0
@guess , @number = '', ''
end
end
# other SSML strings to test
# <say-as interpret-as="characters" format="characters">W3C</say-as>
# <say-as interpret-as='characters'>1 2 3 4 5 6</say-as>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment