Module: Lich::Gemstone::PSMS
- Defined in:
- lib/gemstone/psms.rb
Constant Summary collapse
- FAILURES_REGEXES =
Common failure messages potentially used across all PSMs.
Regexp.union( /^And give yourself away! Never!$/, /^You are unable to do that right now\.$/, /^You don't seem to be able to move to do that\.$/, /^Provoking a GameMaster is not such a good idea\.$/, /^You do not currently have a target\.$/, /^Your mind clouds with confusion and you glance around uncertainly\.$/, /^But your hands are full\!$/, /^You are still stunned\.$/ )
Class Method Summary collapse
-
.assess(name, type, costcheck = false) ⇒ Boolean, Object
Assesses the validity and cost of a specified name and type.
-
.find_name(name, type) ⇒ Hash?
Finds a name of a specified type in the PSMS.
-
.name_normal(name) ⇒ String
Normalizes the given name using the Lich::Util module.
Class Method Details
.assess(name, type, costcheck = false) ⇒ Boolean, Object
Assesses the validity and cost of a specified name and type.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/gemstone/psms.rb', line 50 def self.assess(name, type, costcheck = false) name = self.name_normal(name) seek_psm = self.find_name(name, type) # this logs then raises an exception to stop (kill) the offending script if seek_psm.nil? Lich.log("error: PSMS request: #{$!}\n\t") raise StandardError.new "Aborting script - The referenced #{type} skill #{name} is invalid.\r\nCheck your PSM category (Armor, CMan, Feat, Shield, Warcry, Weapon) and your spelling of #{name}." end # otherwise process request case costcheck when true seek_psm[:cost] < XMLData.stamina else Infomon.get("#{type.downcase}.#{seek_psm[:short_name]}") end end |
.find_name(name, type) ⇒ Hash?
Finds a name of a specified type in the PSMS.
34 35 36 37 |
# File 'lib/gemstone/psms.rb', line 34 def self.find_name(name, type) Object.const_get("Lich::Gemstone::#{type}").method("#{type.downcase}_lookups").call .find { |h| h[:long_name].eql?(name) || h[:short_name].eql?(name) } end |
.name_normal(name) ⇒ String
Normalizes the given name using the Lich::Util module.
22 23 24 |
# File 'lib/gemstone/psms.rb', line 22 def self.name_normal(name) Lich::Util.normalize_name(name) end |