Class: Gemwarrior::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/gemwarrior/game.rb

Constant Summary collapse

PLAYER_DESC_DEFAULT =

CONSTANTS PLAYER DEFAULTS

'Picked to do battle against a wizened madman for a shiny something or other for world-saving purposes.'
PLAYER_LEVEL_DEFAULT =
1
PLAYER_XP_DEFAULT =
0
PLAYER_HP_CUR_DEFAULT =
30
PLAYER_HP_MAX_DEFAULT =
30
PLAYER_STAM_CUR_DEFAULT =
20
PLAYER_STAM_MAX_DEFAULT =
20
PLAYER_ATK_LO_DEFAULT =
1
PLAYER_ATK_HI_DEFAULT =
2
PLAYER_DEFENSE_DEFAULT =
5
PLAYER_DEXTERITY_DEFAULT =
5
PLAYER_INVENTORY_DEFAULT =
Inventory.new
PLAYER_ROX_DEFAULT =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Game

Returns a new instance of Game.



33
34
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
# File 'lib/gemwarrior/game.rb', line 33

def initialize(options)
  # create new world and player
  self.world = World.new

  world.player = Player.new({
    :description        => PLAYER_DESC_DEFAULT,
    :level              => PLAYER_LEVEL_DEFAULT,
    :xp                 => PLAYER_XP_DEFAULT,
    :hp_cur             => PLAYER_HP_CUR_DEFAULT,
    :hp_max             => PLAYER_HP_MAX_DEFAULT,
    :stam_cur           => PLAYER_STAM_CUR_DEFAULT,
    :stam_max           => PLAYER_STAM_MAX_DEFAULT,
    :atk_lo             => PLAYER_ATK_LO_DEFAULT,
    :atk_hi             => PLAYER_ATK_HI_DEFAULT,
    :defense            => PLAYER_DEFENSE_DEFAULT,
    :dexterity          => PLAYER_DEXTERITY_DEFAULT,
    :inventory          => PLAYER_INVENTORY_DEFAULT,
    :rox                => PLAYER_ROX_DEFAULT,
    :cur_coords         => world.location_coords_by_name('Home'),
    :god_mode           => options.fetch(:god_mode),
    :beast_mode         => options.fetch(:beast_mode)
  })

  # create the console
  self.eval = Evaluator.new(world)
  self.repl = Repl.new(world, eval)

  # enter Jool!
  repl.start('look')
end

Instance Attribute Details

#evalObject

Returns the value of attribute eval.



31
32
33
# File 'lib/gemwarrior/game.rb', line 31

def eval
  @eval
end

#replObject

Returns the value of attribute repl.



31
32
33
# File 'lib/gemwarrior/game.rb', line 31

def repl
  @repl
end

#worldObject

Returns the value of attribute world.



31
32
33
# File 'lib/gemwarrior/game.rb', line 31

def world
  @world
end