Sha256: 4e72212680ed9a130bfcf443db4879a59add975c839a6e3da415d6748d9c06d8

Contents?: true

Size: 850 Bytes

Versions: 1

Compression:

Stored size: 850 Bytes

Contents

require 'tarzan/games/rock_paper_scissors/game'
require 'tarzan/games/odds_and_evens/game'

module Tarzan
  module Interfaces
    module Base
      class Interface
        def play
          say %{Welcome to the Game Hall}

          say %{Pick [R]ockPaperScissors or [O]ddsAndEvens: }

          game = case prompt(['R', 'O'])
            when 'R' then Tarzan::Games::RockPaperScissors::Game.new interface: self
            when 'O' then Tarzan::Games::OddsAndEvens::Game.new interface: self
          end

          game.play

          say %{Goodbye, and come back to the Game Hall}
        end

        def say(message)
          # Subclasses are expected to define how to say messages
        end

        def prompt(valid_choices = [])
          # Subclasses are expected to define how to prompt messages
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tarzan-0.0.3 lib/tarzan/interfaces/base/interface.rb