Class: Radventure::Game
- Inherits:
-
Object
- Object
- Radventure::Game
- Defined in:
- lib/radventure.rb
Overview
Main class to run the game
Instance Method Summary collapse
-
#initialize(meta, player_level, initial_room) ⇒ Game
constructor
Constructor method.
Constructor Details
#initialize(meta, player_level, initial_room) ⇒ Game
Constructor method.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/radventure.rb', line 17 def initialize(, player_level, initial_room) # `meta` **MUST** be an instance of Meta raise 'meta must be an instance of Meta' unless .instance_of? Radventure::Meta # `initial_room` **MUST** be an instance of Room raise 'initial_room must be an instance of Room' unless initial_room.instance_of? Radventure::Room # Get game data @meta = @current_room = initial_room @status = :explore # Show initial info Texts.clear Texts.intro(@meta) Texts.prelude(@meta) # Create Player object @player = Radventure::Player.new(player_level) # Begins game loop loop do case @status when :quitting puts 'Are you sure you want to quit?' break unless get_cmd(pre: '(y/N)') != 'y' else Texts.show_room(@current_room) end cmd = get_cmd parse_command cmd end end |