Class: Core::Game::Character

Inherits:
Object
  • Object
show all
Defined in:
lib/game/character.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ageObject (readonly)

Returns the value of attribute age.



18
19
20
# File 'lib/game/character.rb', line 18

def age
  @age
end

#agilityObject (readonly)

Returns the value of attribute agility.



20
21
22
# File 'lib/game/character.rb', line 20

def agility
  @agility
end

#charsetObject (readonly)

Returns the value of attribute charset.



18
19
20
# File 'lib/game/character.rb', line 18

def charset
  @charset
end

#constObject (readonly)

Returns the value of attribute const.



19
20
21
# File 'lib/game/character.rb', line 19

def const
  @const
end

#enduranceObject (readonly)

Returns the value of attribute endurance.



20
21
22
# File 'lib/game/character.rb', line 20

def endurance
  @endurance
end

#equipmentObject (readonly)

Returns the value of attribute equipment.



19
20
21
# File 'lib/game/character.rb', line 19

def equipment
  @equipment
end

#genderObject (readonly)

Returns the value of attribute gender.



18
19
20
# File 'lib/game/character.rb', line 18

def gender
  @gender
end

#healthObject

Returns the value of attribute health.



21
22
23
# File 'lib/game/character.rb', line 21

def health
  @health
end

#influencesObject (readonly)

Returns the value of attribute influences.



20
21
22
# File 'lib/game/character.rb', line 20

def influences
  @influences
end

#inventoryObject (readonly)

Returns the value of attribute inventory.



19
20
21
# File 'lib/game/character.rb', line 19

def inventory
  @inventory
end

#magicObject (readonly)

Returns the value of attribute magic.



19
20
21
# File 'lib/game/character.rb', line 19

def magic
  @magic
end

#mindObject (readonly)

Returns the value of attribute mind.



19
20
21
# File 'lib/game/character.rb', line 19

def mind
  @mind
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/game/character.rb', line 18

def name
  @name
end

#raceObject (readonly)

Returns the value of attribute race.



19
20
21
# File 'lib/game/character.rb', line 19

def race
  @race
end

#skillsObject (readonly)

Returns the value of attribute skills.



19
20
21
# File 'lib/game/character.rb', line 19

def skills
  @skills
end

#spellsObject (readonly)

Returns the value of attribute spells.



20
21
22
# File 'lib/game/character.rb', line 20

def spells
  @spells
end

#stateObject (readonly)

Returns the value of attribute state.



20
21
22
# File 'lib/game/character.rb', line 20

def state
  @state
end

#strengthObject (readonly)

Returns the value of attribute strength.



18
19
20
# File 'lib/game/character.rb', line 18

def strength
  @strength
end

#weightObject (readonly)

Returns the value of attribute weight.



18
19
20
# File 'lib/game/character.rb', line 18

def weight
  @weight
end

Instance Method Details

#calc_statusObject



60
61
62
63
64
65
66
# 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) ⇒ Object



57
58
# File 'lib/game/character.rb', line 57

def consume(item)
end

#rest(amount) ⇒ Object



75
76
77
78
79
# File 'lib/game/character.rb', line 75

def rest(amount)
  if @state != Core::Game::DEAD
    @endurance -= amount
  end
end

#setupObject

health is only used as a percentage for easier displaying, the real stuff is in @const



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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

#updateObject



51
52
53
54
55
# File 'lib/game/character.rb', line 51

def update
  @influences.each { |inf|
    inf.update(self)
  }
end

#validateObject



43
44
45
46
47
48
49
# File 'lib/game/character.rb', line 43

def validate
  if @agility > 100
    @agility = 0
  elsif @agility < 0
    @agility = 0
  end
end

#wakeObject



81
82
83
84
85
86
# File 'lib/game/character.rb', line 81

def wake
  if @state != Core::Game::DEAD
    @state = Core::Game::NORMAL
    calc_status
  end
end

#weaken(amount) ⇒ Object



68
69
70
71
72
73
# File 'lib/game/character.rb', line 68

def weaken(amount)
  if @state != Core::Game::DEAD
    @endurance -= amount
    calc_status
  end
end