Sha256: 4856c447882cefbb2ed963f33fabe62ce008e74b9cb130ac5c10328db61c9d7a
Contents?: true
Size: 706 Bytes
Versions: 22
Compression:
Stored size: 706 Bytes
Contents
# encoding: utf-8 class SimonGame < Adhearsion::CallController attr_accessor :number, :attempt def run answer reset loop do update_number collect_attempt verify_attempt end end def random_number rand(10).to_s end def update_number @number << random_number end def collect_attempt result = ask @number, :limit => @number.length @attempt = result.response end def verify_attempt if attempt_correct? speak 'good' else speak "#{@number.length - 1} times wrong, try again smarty" reset end end def attempt_correct? @attempt == @number end def reset @attempt, @number = '', '' end end
Version data entries
22 entries across 22 versions & 2 rubygems