Sha256: 4572731c2dff423401ca8edd081d14b469ed9dc6a513ee44a9ee43f4d1c4f3c8

Contents?: true

Size: 1.79 KB

Versions: 41

Compression:

Stored size: 1.79 KB

Contents

# lib/gemwarrior/entities/monster.rb
# Entity::Creature::Monster

require_relative 'creature'
require_relative 'items/herb'
require_relative 'items/bullet'

module Gemwarrior
  class Monster < Creature
    ITEM_POOL = [Herb.new, Bullet.new]

    attr_accessor :battlecry,
                  :is_boss,
                  :is_dead

    def initialize
      super

      self.inventory  = Inventory.new
      self.useable    = true
      self.talkable   = true
      self.is_dead    = false
      3.times do
        if [true, false].sample
          self.inventory.add_item(ITEM_POOL[rand(0..ITEM_POOL.length-1)])
        end
      end  
    end

    def describe_detailed
      desc_text =  "\"#{name_display}\"".colorize(:yellow)
      desc_text << '(BOSS)'.ljust(13).colorize(:yellow) if is_boss
      desc_text << "\n"
      desc_text << "(#{name})\n".colorize(:green)
      desc_text << "#{description}\n".colorize(:white)
      desc_text << "FACE : #{face}\n".colorize(:white)
      desc_text << "HANDS: #{hands}\n".colorize(:white)
      desc_text << "MOOD : #{mood}\n".colorize(:white)
      desc_text << "LVL  : #{level}\n".colorize(:white)
      desc_text << "HP   : #{hp_cur}/#{hp_max}\n".colorize(:white)
      desc_text << "ATK  : #{atk_lo}-#{atk_hi}\n".colorize(:white)
      desc_text << "DEF  : #{defense}\n".colorize(:white)
      desc_text << "DEX  : #{dexterity}\n".colorize(:white)
      desc_text << "ROX  : #{rox}\n".colorize(:white)
      desc_text << "XP   : #{xp}\n".colorize(:white)
      desc_text << "INV  : #{inventory.contents}\n".colorize(:white)
      desc_text << "DEAD?  #{is_dead}\n".colorize(:white)
      desc_text << "TALK?  #{talkable}\n".colorize(:white)
      desc_text << "USE?   #{useable}\n".colorize(:white)
      desc_text
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
gemwarrior-0.15.20 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.19 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.18 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.17 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.16 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.15 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.14 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.13 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.12 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.11 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.10 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.9 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.8 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.7 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.6 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.5 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.4 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.3 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.2 lib/gemwarrior/entities/monster.rb
gemwarrior-0.15.1 lib/gemwarrior/entities/monster.rb