class WizardsCastle::RoomContent

Constants

ROOM_THINGS

Attributes

symbol[R]

Public Class Methods

new(intcode,curse_lethargy=false,curse_leech=false,curse_forget=false,monster_type=nil) click to toggle source
# File lib/wizards-castle/room_content.rb, line 72
def initialize(intcode,curse_lethargy=false,curse_leech=false,curse_forget=false,monster_type=nil)
  raise "Unrecognized intcode #{intcode}" unless RoomContent.valid_intcode?(intcode)
  @symbol = RoomContent.to_symbol(intcode)
  raise "Param monster_type is only valid on the runestaff room" if (monster_type && @symbol!=:runestaff_and_monster)
  @cursed_with_lethargy = curse_lethargy
  @cursed_with_leech = curse_leech
  @cursed_with_forgetfulness = curse_forget
  @monster_type = monster_type
end
to_intcode(symbol) click to toggle source
# File lib/wizards-castle/room_content.rb, line 63
def self.to_intcode(symbol)
  raise "Unrecognized symbol '#{symbol.inspect}'" unless ROOM_THINGS.has_key?(symbol)
  ROOM_THINGS[symbol][:intcode]
end
to_symbol(intcode) click to toggle source
# File lib/wizards-castle/room_content.rb, line 59
def self.to_symbol(intcode)
  @@intcode_to_symbol_map[intcode] or raise "Unrecognized intcode '#{intcode}'"
end
valid_intcode?(intcode) click to toggle source
# File lib/wizards-castle/room_content.rb, line 51
def self.valid_intcode?(intcode)
  @@intcode_to_symbol_map.has_key?(intcode)
end
valid_symbol?(symbol) click to toggle source
# File lib/wizards-castle/room_content.rb, line 55
def self.valid_symbol?(symbol)
  ROOM_THINGS.has_key?(symbol)
end

Public Instance Methods

cursed_with_forgetfulness?() click to toggle source
# File lib/wizards-castle/room_content.rb, line 94
def cursed_with_forgetfulness?
  @cursed_with_forgetfulness
end
cursed_with_leech?() click to toggle source
# File lib/wizards-castle/room_content.rb, line 90
def cursed_with_leech?
  @cursed_with_leech
end
cursed_with_lethargy?() click to toggle source
# File lib/wizards-castle/room_content.rb, line 86
def cursed_with_lethargy?
  @cursed_with_lethargy
end
display() click to toggle source
# File lib/wizards-castle/room_content.rb, line 82
def display
  ROOM_THINGS[@symbol][:mapchar]
end
monster?() click to toggle source
# File lib/wizards-castle/room_content.rb, line 103
def monster?
  ROOM_THINGS[@symbol][:mapchar]=='M'
end
monster_symbol() click to toggle source
# File lib/wizards-castle/room_content.rb, line 111
def monster_symbol
  raise "no monster in room (has #{symbol.to_s})" unless (self.monster? || @symbol==:vendor)
  (@symbol==:runestaff_and_monster && @monster_type) ? @monster_type : @symbol
end
text() click to toggle source
# File lib/wizards-castle/room_content.rb, line 98
def text
  sym = (@symbol==:runestaff_and_monster && @monster_type) ? @monster_type : @symbol
  ROOM_THINGS[sym][:text].dup
end
treasure?() click to toggle source
# File lib/wizards-castle/room_content.rb, line 107
def treasure?
  ROOM_THINGS[@symbol][:mapchar]=='T'
end