Skip to content

Commit

Permalink
Merge pull request #6721 from Nyctus/master
Browse files Browse the repository at this point in the history
Updates to sigilharvest and common-items to fix some logic errors in the former and add compatibility to the latter
  • Loading branch information
MahtraDR authored Nov 3, 2023
2 parents 6672731 + cb09e2c commit 13d6983
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion common-items.lic
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ module DRCI
/There's (?:only )?(.+) parts? left/,
/The (?:.+) has (.+) uses remaining./,
/There are enough left to create (.+) more/,
/You count out (.+) pieces? of material there/
/You count out (.+) pieces? of material there/,
/There (?:is|are) (.+) scrolls? left for use with crafting/
]
count = 0
$ORDINALS.each do |ordinal|
Expand Down
24 changes: 16 additions & 8 deletions sigilharvest.lic
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class SigilHarvest
@action_difficulty = { "trivial" => 1, "straightforward" => 2, "challenging" => 3, "difficult" => 4, "formidable" => 5 }

@args = parse_args(arg_definitions)
@debug = @args.debug

# sigil harvesting uses the same sorts of buffs that other gathering skills use i.e. outdoorsmanship and perception
DRCA.do_buffs(@settings, 'outdoors')
Expand Down Expand Up @@ -338,6 +337,9 @@ class SigilHarvest

# check our stock of scrolls since we just used some
get_scrolls

# if roomcap was not specified, exit script once sigil-scrolls are harvested
exit unless @args.roomcap
end # scribe_sigils

# returns the current seasonw which determines what room list to pull from base-sigils
Expand All @@ -352,11 +354,9 @@ class SigilHarvest
@stock_scrolls ? target_scrolls = @stock_scrolls : target_scrolls = 25

# Count scrolls and store number in a variable, set variable to 0 if scrolls are not found
if /^There (?:are|is) (.*) scrolls? left for use with crafting\.$/ =~ DRC.bput("count my blank scrolls", 'I could not find', /^There (?:is|are) .* scrolls? left for use with crafting\.$/)
num_scrolls = DRC.text2num($1)
else
num_scrolls = 0
end
num_scrolls = DRCI.count_item_parts('blank scroll')
DRC.message("Scrolls Remaining: #{num_scrolls}") if @args.debug
DRC.message("Target Scrolls: #{target_scrolls}") if @args.debug

# if we have enough scrolls exit the function
return if num_scrolls >= target_scrolls
Expand All @@ -374,19 +374,27 @@ class SigilHarvest
scroll_price = 90 # dokora
end

DRC.message("Buying more scrolls from #{Room[scroll_room].title}") if @args.debug

# ensure hands are clear
DRCI.stow_hands

# blank scrolls come in a stack of 25, divide the difference by 25 and ceil to determine the number of times we need to order to meet or exceed stock target
num_to_order = ((target_scrolls - num_scrolls) / 25).ceil()
# blank scrolls come in a stack of 25, divide the difference by 25 and round to determine the number of times we need to order. (Changed to ROUND instead of CEIL. No longer tries to always meet or exceed value but instead gets close to target quantity.)
num_to_order = target_scrolls - num_scrolls
num_to_order = num_to_order / 25
num_to_order = num_to_order.round

# calculate the amount of money needed
coppers_needed = num_to_order * scroll_price

# go to bank if insufficient funds on hand
DRC.message("Getting #{coppers_needed} coppers to buy scrolls.") if @args.debug

# get money if needed
DRCM.ensure_copper_on_hand(coppers_needed, @settings)

# order repeatedly and combine
DRC.message("Ordering scrolls #{num_to_order} times.") if @args.debug
(1..num_to_order).each do
DRCT.order_item(scroll_room, 8)
DRC.bput('combine', /^You combine|^You must/)
Expand Down

0 comments on commit 13d6983

Please sign in to comment.