Sha256: 4d166a303e832c42da459dacf2274744f00b39727f9048e8537e9e66f52d4b3e

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

# lib/gemwarrior/game.rb
# Main launching point for Gem Warrior

require_relative 'world'
require_relative 'player'

require_relative 'repl'
require_relative 'evaluator'

module Gemwarrior
  class Game
    # CONSTANTS
    ## PLAYER DEFAULTS
    PLYR_LEVEL_DEFAULT = 1
    PLYR_XP_DEFAULT = 0
    PLYR_HP_CUR_DEFAULT = 10
    PLYR_HP_MAX_DEFAULT = 10
    PLYR_STAM_CUR_DEFAULT = 20
    PLYR_STAM_MAX_DEFAULT = 20
    PLYR_ATK_LO_DEFAULT = 1
    PLYR_ATK_HI_DEFAULT = 2
    PLYR_ROX_DEFAULT = 0

    attr_accessor :world, :eval, :repl
    
    def initialize
      # create new world and player
      self.world = World.new
      world.player = Player.new(
        PLYR_LEVEL_DEFAULT,
        PLYR_XP_DEFAULT,
        PLYR_HP_CUR_DEFAULT,
        PLYR_HP_MAX_DEFAULT,
        PLYR_STAM_CUR_DEFAULT,
        PLYR_STAM_MAX_DEFAULT,
        PLYR_ATK_LO_DEFAULT,
        PLYR_ATK_HI_DEFAULT,
        Inventory.new,
        PLYR_ROX_DEFAULT,
        world.loc_by_id(0)
      )

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

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gemwarrior-0.3.3 lib/gemwarrior/game.rb
gemwarrior-0.3.2 lib/gemwarrior/game.rb