Skip to content

Commit

Permalink
Merge pull request #6791 from vtcifer/tome_before_dying_bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtraDR authored Mar 31, 2024
2 parents 6a13991 + c14526d commit a1b333e
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions tome.lic
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
custom_require.call(%w[common common-items drinfomon events])

class Tome
@@tome = nil

def self.tome
@@tome
end

def initialize
arg_definitions = [
[
Expand All @@ -13,17 +20,17 @@ class Tome
@tome_settings = @settings.tome_settings
@debug = args.debug

@tome = @tome_settings['tome_name']
@@tome = @tome_settings['tome_name']
@quit_early = @tome_settings['quit_early']
@scholarship_limit = @tome_settings['scholarship_limit'] || 34
@passive_scripts = @tome_settings['passive_scripts']
@passive = args.active ? false : @tome_settings['passive']
@no_use_rooms = @settings.sanowret_no_use_rooms

# check to ensure tome is defined in gear, and warn user if not
if @settings.gear.find { |item| @tome =~ /#{item[:adjective]}\s*#{item[:name]}/i }.nil?
if @settings.gear.find { |item| @@tome =~ /#{item[:adjective]}\s*#{item[:name]}/i }.nil?
message = "To minimize the possibility that items that you hold in your hands could be lost they should be listed in your `gear:`. Your tome is not listed in your `gear:` settings:"
message += "\n - #{@tome}"
message += "\n - #{@@tome}"
message += "\nIf you need assistance with this, please ask in the lich discord (listed in #{$clean_lich_char}links) for help."
message += "\n\n---This check is *advisory* for now, but will become mandatory in the near future.---"
DRC.message(message)
Expand All @@ -42,7 +49,7 @@ class Tome
}

if @quit_early
Flags.add('study-complete', Regexp.new(@penultimate_pages[@tome]))
Flags.add('study-complete', Regexp.new(@penultimate_pages[@@tome]))
else
Flags.add('study-complete', /^Having finished your studies,/)
end
Expand All @@ -57,7 +64,7 @@ class Tome
return false if DRSkill.getxp('Scholarship') >= @scholarship_limit
return true unless @passive
return false if hiding? || invisible?
return false if DRC.left_hand && DRC.right_hand && !DRCI.in_hands?(@tome)
return false if DRC.left_hand && DRC.right_hand && !DRCI.in_hands?(@@tome)
return false if @no_use_rooms.any? { |name| /#{name}/ =~ DRRoom.title || name.to_s == Room.current.id.to_s }
if @passive_scripts.any? { |name|
echo "Passive script: #{name}" if Script.running?(name) && @debug
Expand All @@ -83,7 +90,7 @@ class Tome
while Time.now < end_time
if !should_train?
pause_scripts if @passive
DRCI.stow_item?(@tome)
DRCI.stow_item?(@@tome)
DRC.safe_unpause_list @scripts_to_unpause if @passive
return false
end
Expand All @@ -107,11 +114,11 @@ class Tome
next unless should_train?

pause_scripts if @passive
unless DRCI.get_item?(@tome)
unless DRCI.get_item?(@@tome)
DRC.safe_unpause_list @scripts_to_unpause if @passive
next
end
result = DRC.bput("study my #{@tome}",
result = DRC.bput("study my #{@@tome}",
/^You immerse yourself in the wisdom of your/,
/^You are unable to focus on studying your/,
/^You must complete or cancel your current magical research project/,
Expand All @@ -124,7 +131,7 @@ class Tome
/^Considering that you are in combat/,
/^However, you find that you lack the concentration to focus on your studies/
pause_scripts if @passive
DRCI.stow_item?(@tome)
DRCI.stow_item?(@@tome)
DRC.safe_unpause_list @scripts_to_unpause if @passive
pause 10
next
Expand All @@ -135,7 +142,7 @@ class Tome
# (which only will happen if we finished reading but somehow missed the completion flag - e.g., if another script stowed the book)
pause 1 until Flags['study-complete'] or !should_train? or DRStats.concentration == 100
pause_scripts if @passive
DRCI.stow_item?(@tome)
DRCI.stow_item?(@@tome)
DRC.safe_unpause_list @scripts_to_unpause if @passive
end
end
Expand All @@ -144,7 +151,7 @@ end
before_dying do
Flags.delete('study-complete')
DRC.fix_standing
DRCI.stow_item?(@tome) if DRCI.in_hands?(@tome)
DRCI.stow_item?(Tome.tome) if !Tome.tome.nil? && DRCI.in_hands?(Tome.tome)
end

Tome.new

0 comments on commit a1b333e

Please sign in to comment.