Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to sigilharvest and common-items to fix some logic errors in the former and add compatibility to the latter #6721

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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