Class: Tarzan::Games::Base::Game
- Inherits:
-
Object
- Object
- Tarzan::Games::Base::Game
- Defined in:
- lib/tarzan/games/base/game.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Game
constructor
A new instance of Game.
- #play ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Game
Returns a new instance of Game.
5 6 7 |
# File 'lib/tarzan/games/base/game.rb', line 5 def initialize( = {}) @interface = [:interface] end |
Instance Method Details
#play ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tarzan/games/base/game.rb', line 9 def play @interface.say %{Rules: #{rules}} move_p1 = prompt_move move_p2 = random_move @interface.say %{You played #{move_p1} - I played #{move_p2}} outcome = case move_p1 <=> move_p2 when 1 then %{You win!} when -1 then %{You lose!} when 0 then %{It’s a tie!} end @interface.say outcome end |