Module: Lich::Gemstone::PSMS
- Defined in:
- documented/gemstone/psms.rb
Overview
Provides a unified interface for interacting with Player System Manager (PSM) skills in GemStone IV.
This module includes methods for normalizing names, finding skills, assessing their availability, and checking for special conditions related to skills.
Constant Summary collapse
- FAILURES_REGEXES =
A regular expression pattern that matches various failure messages.
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\.$/, /^You lack the momentum to attempt another skill\.$/, /^You can't reach .+!$/, / attempting to .+ would be a rather awkward proposition\.$/, )
Class Method Summary collapse
-
.assess(name, type, costcheck = false, forcert_count: 0) ⇒ Boolean
Assesses the availability of a skill based on its name and type.
-
.available?(name, ignore_cooldown = false) ⇒ Boolean
Checks if a skill is available for use.
-
.can_forcert?(times) ⇒ Boolean
Checks if a specified number of forcerts can be used.
-
.find_name(name, type) ⇒ Hash?
Finds a skill by its name and type.
-
.max_forcert_count ⇒ Integer
Determines the maximum number of forcerts that can be used based on multi-opponent combat skills.
-
.name_normal(name) ⇒ String
Normalizes the given skill name.
Class Method Details
.assess(name, type, costcheck = false, forcert_count: 0) ⇒ Boolean
Assesses the availability of a skill based on its name and type.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'documented/gemstone/psms.rb', line 53 def self.assess(name, type, costcheck = false, forcert_count: 0) return false unless forcert_count <= max_forcert_count 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 ArgumentError, "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}.", (caller.find { |call| call =~ /^#{Script.current.name}/ }) end # otherwise process request case costcheck when true base_cost = seek_psm[:cost] base_cost.each do |cost_type, cost_amount| if forcert_count > 0 return false unless (cost_amount + (cost_amount * ((25 + (10.0 * forcert_count)) / 100))).truncate < XMLData.public_send(cost_type) else return false unless cost_amount < XMLData.public_send(cost_type) end end return true else Infomon.get("#{type.downcase}.#{seek_psm[:short_name]}") end end |
.available?(name, ignore_cooldown = false) ⇒ Boolean
Checks if a skill is available for use.
84 85 86 87 88 |
# File 'documented/gemstone/psms.rb', line 84 def self.available?(name, ignore_cooldown = false) return false if Lich::Util.normalize_lookup('Debuffs', 'Overexerted') return false if Lich::Util.normalize_lookup('Cooldowns', name) unless ignore_cooldown return true end |
.can_forcert?(times) ⇒ Boolean
Checks if a specified number of forcerts can be used.
94 95 96 |
# File 'documented/gemstone/psms.rb', line 94 def self.can_forcert?(times) max_forcert_count >= times end |
.find_name(name, type) ⇒ Hash?
Finds a skill by its name and type.
39 40 41 42 43 |
# File 'documented/gemstone/psms.rb', line 39 def self.find_name(name, type) name = self.name_normal(name) Object.const_get("Lich::Gemstone::#{type}").method("#{type.downcase}_lookups").call .find { |h| h[:long_name].eql?(name) || h[:short_name].eql?(name) } end |
.max_forcert_count ⇒ Integer
Determines the maximum number of forcerts that can be used based on multi-opponent combat skills.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'documented/gemstone/psms.rb', line 101 def self.max_forcert_count case Skills.multi_opponent_combat when 0..9 0 when 10..34 1 when 35..74 2 when 75..124 3 else # 125+ 4 end end |
.name_normal(name) ⇒ String
Normalizes the given skill name.
30 31 32 |
# File 'documented/gemstone/psms.rb', line 30 def self.name_normal(name) Lich::Util.normalize_name(name) end |