Sha256: 2d28c67ec5b1931e8dc8df3eb68badb95d49441723ebc7b0509daecfe4f26068

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

# lib/gemwarrior/creature.rb
# Creature base class

require_relative 'inventory'

module Gemwarrior
  class Creature
    # CONSTANTS
    CREATURE_NAME_DEFAULT          = 'Creature'
    CREATURE_DESCRIPTION_DEFAULT   = 'A creature of some sort.'
    CREATURE_FACE_DEFAULT          = 'calm'
    CREATURE_HANDS_DEFAULT         = 'smooth'
    CREATURE_MOOD_DEFAULT          = 'happy'

    attr_accessor :id, :name, :description, :face, :hands, :mood, 
                  :level, :hp_cur, :hp_max, :inventory
    
    def initialize(
      id, 
      name = CREATURE_NAME_DEFAULT,
      description = CREATURE_DESCRIPTION_DEFAULT, 
      face = CREATURE_FACE_DEFAULT, 
      hands = CREATURE_HANDS_DEFAULT, 
      mood = CREATURE_MOOD_DEFAULT, 
      level = 1, 
      hp_cur = 10, 
      hp_max = 10, 
      inventory = Inventory.new
    )
      self.id = id
      self.name = name
      self.description = description
      self.face = face
      self.hands = hands
      self.mood = mood

      self.level = level
      self.hp_cur = hp_cur
      self.hp_max = hp_max

      self.inventory = inventory
    end
    
    def describe
      self.description
    end
    
    def status
      status_text =  "[#{name}][LVL: #{level}][HP:#{hp_cur}|#{hp_max}]\n"
      status_text << "Its face is #{face}, hands are #{hands}, and general mood is #{mood}."
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gemwarrior-0.4.0 lib/gemwarrior/creature.rb
gemwarrior-0.3.3 lib/gemwarrior/creature.rb
gemwarrior-0.3.2 lib/gemwarrior/creature.rb