Class: Partyhat::Skill

Inherits:
Stat
  • Object
show all
Defined in:
lib/partyhat/skill.rb

Constant Summary

Constants inherited from Stat

Partyhat::Stat::ActivitiesList, Partyhat::Stat::CombatSkillsList, Partyhat::Stat::HumanNames, Partyhat::Stat::List, Partyhat::Stat::SkillsList

Instance Method Summary collapse

Methods inherited from Stat

human_name_for

Constructor Details

#initialize(name, level, experience, rank) ⇒ Skill

Returns a new instance of Skill.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
# File 'lib/partyhat/skill.rb', line 8

def initialize name, level, experience, rank
  raise ArgumentError, 'Invalid skill name "' + name.to_s + '"' unless (SkillsList+[:overall]).include? name
  @name       = name

  # Nilify negative values
  @level      = level < 0 ? nil : level
  @experience = experience < 0 ? nil : experience
  @rank       = rank < 0 ? nil : rank
end

Instance Method Details

#compare_to(another_skill) ⇒ Object



38
39
40
# File 'lib/partyhat/skill.rb', line 38

def compare_to another_skill
  Partyhat::SkillComparison.new(self, another_skill)
end

#experienceObject



30
31
32
# File 'lib/partyhat/skill.rb', line 30

def experience
  @experience
end

#human_nameObject



22
23
24
# File 'lib/partyhat/skill.rb', line 22

def human_name
  Partyhat::Stat.human_name_for @name
end

#levelObject



26
27
28
# File 'lib/partyhat/skill.rb', line 26

def level
  @level
end

#nameObject



18
19
20
# File 'lib/partyhat/skill.rb', line 18

def name
  @name
end

#rankObject



34
35
36
# File 'lib/partyhat/skill.rb', line 34

def rank
  @rank
end