class Core::Game::Character
Attributes
age[R]
agility[R]
charset[R]
const[R]
endurance[R]
equipment[R]
gender[R]
health[RW]
influences[R]
inventory[R]
magic[R]
mind[R]
name[R]
race[R]
skills[R]
spells[R]
state[R]
strength[R]
weight[R]
Public Instance Methods
calc_status()
click to toggle source
# File lib/game/character.rb, line 60 def calc_status if @endurance <= 25 @state = Core::Game::UNCONSCIOUS elsif @endurance <= 0 @state = Core::Game::DEAD end end
consume(item)
click to toggle source
# File lib/game/character.rb, line 57 def consume(item) end
rest(amount)
click to toggle source
# File lib/game/character.rb, line 75 def rest(amount) if @state != Core::Game::DEAD @endurance -= amount end end
setup()
click to toggle source
health is only used as a percentage for easier displaying, the real stuff is in @const
# File lib/game/character.rb, line 24 def setup @health = @endurance = 100 @inventory = Core::Game::Inventory.new(20, @strength) @skills = Core::Game::Skills.new @const = Core::Game::Constitution.new @mind = Core::Game::Mind.new @equipment = Core::Game::Equipment.new @magic = Core::Game::Magic.new(self) @state = Core::Game::NORMAL @spells = {} Core::Game.spells.each { |spell| @spells.store(spell, 0) } @charset = @file @file = Core.sprite(@file) @influences = [] setup_skills end
update()
click to toggle source
# File lib/game/character.rb, line 51 def update @influences.each { |inf| inf.update(self) } end
validate()
click to toggle source
# File lib/game/character.rb, line 43 def validate if @agility > 100 @agility = 0 elsif @agility < 0 @agility = 0 end end
wake()
click to toggle source
# File lib/game/character.rb, line 81 def wake if @state != Core::Game::DEAD @state = Core::Game::NORMAL calc_status end end
weaken(amount)
click to toggle source
# File lib/game/character.rb, line 68 def weaken(amount) if @state != Core::Game::DEAD @endurance -= amount calc_status end end
Private Instance Methods
setup_skills()
click to toggle source
# File lib/game/character.rb, line 90 def setup_skills @skills.list[Core::Game.find_skill(:healing)] = @healing @skills.list[Core::Game.find_skill(:crafting)] = @crafting @skills.list[Core::Game.find_skill(:botany)] = @botany @skills.list[Core::Game.find_skill(:healing_magic)] = @healing_magic @skills.list[Core::Game.find_skill(:mind)] = @mind @skills.list[Core::Game.find_skill(:elemental)] = @elemental @skills.list[Core::Game.find_skill(:ranged)] = @ranged @skills.list[Core::Game.find_skill(:melee)] = @melee end