Class: Gemwarrior::Game
- Inherits:
-
Object
- Object
- Gemwarrior::Game
- Defined in:
- lib/gemwarrior/game.rb
Constant Summary collapse
- INVENTORY_DEFAULT =
CONSTANTS
Inventory.new
- INVENTORY_DEBUG =
Inventory.new([Herb.new, Herb.new, Herb.new])
- ROX_DEFAULT =
0
- ROX_DEBUG =
300
Instance Attribute Summary collapse
-
#evaluator ⇒ Object
Returns the value of attribute evaluator.
-
#monsters ⇒ Object
Returns the value of attribute monsters.
-
#repl ⇒ Object
Returns the value of attribute repl.
-
#weapons ⇒ Object
Returns the value of attribute weapons.
-
#world ⇒ Object
Returns the value of attribute world.
Instance Method Summary collapse
-
#initialize(options) ⇒ Game
constructor
A new instance of Game.
- #update_options_file ⇒ Object
Constructor Details
#initialize(options) ⇒ Game
Returns a new instance of Game.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/gemwarrior/game.rb', line 35 def initialize() # set game options GameOptions.add 'beast_mode', .fetch(:beast_mode) GameOptions.add 'debug_mode', .fetch(:debug_mode) GameOptions.add 'god_mode', .fetch(:god_mode) GameOptions.add 'sound_enabled', .fetch(:sound_enabled) GameOptions.add 'sound_system', .fetch(:sound_system) GameOptions.add 'sound_volume', .fetch(:sound_volume) GameOptions.add 'use_wordnik', .fetch(:use_wordnik) GameOptions.add 'fight_completion', .fetch(:fight_completion) # add classes for creatures, monsters, people, items, weapons, and armor to game # also add them to the global GameAssets init_creatures init_monsters init_people init_items init_weapons init_armor # create new world based on default template self.world = init_world # update some player aspects to make more dynamic world.player.name = world.player.generate_name world.player.face = world.player.generate_face world.player.hands = world.player.generate_hands world.player.mood = world.player.generate_mood world.player.inventory = GameOptions.data['debug_mode'] ? INVENTORY_DEBUG : INVENTORY_DEFAULT world.player.rox = GameOptions.data['debug_mode'] ? ROX_DEBUG : ROX_DEFAULT # set some global variables world.duration = { mins: 0, secs: 0, ms: 0 } world.emerald_beaten = false world.shifty_to_jewel = false world.shifty_has_jeweled = false # spawn bosses ## Pain Quarry world.location_by_name('pain_quarry-southeast').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new) world.location_by_name('pain_quarry-east').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new) world.location_by_name('pain_quarry-central').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new) world.location_by_name('pain_quarry-south').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new) world.location_by_name('pain_quarry-west').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new) world.location_by_name('pain_quarry-northwest').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new) world.location_by_name('pain_quarry-north').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new) ## River Bridge world.location_by_name('river_bridge').bosses_abounding.push(Gemwarrior.const_get('Jaspern').new) ## Throne Room world.location_by_name('sky_tower-throne_room').bosses_abounding.push(Gemwarrior.const_get('Emerald').new) # mark home as visited world.location_by_name('home').visited = true # create options file if not existing # require needed files for selected sound_system if sound_enabled if GameOptions.data['sound_enabled'] Audio.init end # create the console self.evaluator = Evaluator.new(world) self.repl = Repl.new(self, world, evaluator) # enter Jool! repl.start('look', .fetch(:extra_command), .fetch(:new_skip), .fetch(:resume_skip)) end |
Instance Attribute Details
#evaluator ⇒ Object
Returns the value of attribute evaluator.
29 30 31 |
# File 'lib/gemwarrior/game.rb', line 29 def evaluator @evaluator end |
#monsters ⇒ Object
Returns the value of attribute monsters.
29 30 31 |
# File 'lib/gemwarrior/game.rb', line 29 def monsters @monsters end |
#repl ⇒ Object
Returns the value of attribute repl.
29 30 31 |
# File 'lib/gemwarrior/game.rb', line 29 def repl @repl end |
#weapons ⇒ Object
Returns the value of attribute weapons.
29 30 31 |
# File 'lib/gemwarrior/game.rb', line 29 def weapons @weapons end |
#world ⇒ Object
Returns the value of attribute world.
29 30 31 |
# File 'lib/gemwarrior/game.rb', line 29 def world @world end |
Instance Method Details
#update_options_file ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/gemwarrior/game.rb', line 105 def File.open(GameOptions.data['options_file_path'], 'w') do |f| f.puts "sound_enabled:#{GameOptions.data['sound_enabled']}" f.puts "sound_system:#{GameOptions.data['sound_system']}" f.puts "sound_volume:#{GameOptions.data['sound_volume']}" f.puts "use_wordnik:#{GameOptions.data['use_wordnik']}" f.puts "fight_completion:#{GameOptions.data['fight_completion']}" end end |