Skip to content

Commit

Permalink
[sk.lic] v1.2.2 refactor for Lich 5.11 namespace change
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhoribu authored Jan 27, 2025
1 parent cb2782d commit 5e2857c
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions scripts/sk.lic
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
game: Gemstone
tags: sk, self knowledge
requires: Lich >= 4.6.0
version: 1.2.1
version: 1.2.2
v1.2.2(2025-01-26)
- Refactored for non-breaking inclusion for Lich 5.11+
v1.2.1 (2024-08-24)
- Fix to use old time_per calc if exists and < 10mins
v1.2.0 (2024-02-22)
Expand All @@ -22,27 +24,29 @@
- initial release
=end

module Games
module Gemstone
class Spell
OLD_KNOWN_METHOD ||= Spell.instance_method(:known?)
def known?
SK.known?(self) or OLD_KNOWN_METHOD.bind(self).call()
end
class Spell
if defined?(Games::Gemstone::Spell)
OLD_KNOWN_METHOD ||= Games::Gemstone::Spell.instance_method(:known?)
OLD_TIME_PER_METHOD ||= Games::Gemstone::Spell.instance_method(:time_per)
elsif defined?(Lich::Common::Spell)
OLD_KNOWN_METHOD ||= Spell.instance_method(:known?)
OLD_TIME_PER_METHOD ||= Spell.instance_method(:time_per)
else
fail("sk.lic not currently equipped to handle your version of Lich, exiting!")
end
def known?
SK.known?(self) or OLD_KNOWN_METHOD.bind(self).call()
end

OLD_TIME_PER_METHOD ||= Spell.instance_method(:time_per)
def time_per(arg = nil)
# dumb time per of 10m because lots of things break otherwise
return 10.0 if SK.known?(self) && (OLD_TIME_PER_METHOD.bind(self).call(arg).nil? || OLD_TIME_PER_METHOD.bind(self).call(arg) < 10)
return OLD_TIME_PER_METHOD.bind(self).call(arg)
end
end
def time_per(arg = nil)
# dumb time per of 10m because lots of things break otherwise
return 10.0 if SK.known?(self) && (OLD_TIME_PER_METHOD.bind(self).call(arg).nil? || OLD_TIME_PER_METHOD.bind(self).call(arg) < 10)
return OLD_TIME_PER_METHOD.bind(self).call(arg)
end
end

module SK
NAMESPACE = "sk/known"

Vars[NAMESPACE] ||= []

def self.known?(spell)
Expand Down

0 comments on commit 5e2857c

Please sign in to comment.