1
0
Fork 0
forked from OpenNeo/impress

Vaguer potions info for Dyeworks in Item Getting Guide

This commit is contained in:
Emi Matchu 2024-06-20 13:14:51 -07:00
parent 97abd6e438
commit 2e3d5d2020
2 changed files with 16 additions and 49 deletions

View file

@ -194,50 +194,18 @@ module ItemsHelper
end end
def dyeworks_nc_total_for(items) def dyeworks_nc_total_for(items)
dyeworks_items_nc_total_for(items) + dyeworks_potions_nc_total(items.size)
end
def dyeworks_items_nc_total_for(items)
nc_total_for items.map(&:dyeworks_base_item) nc_total_for items.map(&:dyeworks_base_item)
end end
def dyeworks_potions_nc_total(num_items) def dyeworks_average_num_potions_for(items)
dyeworks_potions_nc_breakdown(num_items)[:nc_total] # Compute the number of expected potions for each (inverse of the odds),
# sum them, then round up.
items.map { |i| 1 / i.dyeworks_odds }.sum.ceil
end end
def dyeworks_potions_nc_summary(num_items) def dyeworks_estimated_potions_cost_for(items)
dyeworks_potions_nc_breakdown(num_items)[:summary] # NOTE: You could do bundles too, but let's just keep it simple.
end dyeworks_average_num_potions_for(items) * 125
def dyeworks_potions_nc_breakdown(num_items)
nc_total = 0
summaries = []
# For every 10 potions, buy a 10-Bundle for 900 NC.
while num_items >= 10
nc_total += 900
summaries << "10-Bundle (900 NC)"
num_items -= 10
end
# For every remaining 5 potions, buy a 5-Bundle for 500 NC.
while num_items >= 5
nc_total += 500
summaries << "5-Bundle (500 NC)"
num_items -= 5
end
# For every remaining potion, buy each directly for 125 NC.
if num_items >= 1
nc_total += num_items * 125
summaries << "#{pluralize num_items, "potion"} (#{num_items * 125} NC)"
num_items = 0
end
summaries << "0 NC" if summaries.empty?
summary = summaries.join(", ")
{nc_total:, summary:}
end end
def probability(p) def probability(p)

View file

@ -49,16 +49,15 @@
alt: "Dyeworks Hue Brew Potion" alt: "Dyeworks Hue Brew Potion"
%th %th
Total: #{dyeworks_nc_total_for @items_needed[:dyeworks]} NC Total: #{dyeworks_nc_total_for @items_needed[:dyeworks]} NC
= surround "(", ")" do
%span.price-breakdown{
title: "#{dyeworks_items_nc_total_for(@items_needed[:dyeworks])} NC"
}<
#{pluralize @items_needed[:dyeworks].size, "item"}
+ +
%span.price-breakdown{ %span.price-breakdown{
title: dyeworks_potions_nc_summary(@items_needed[:dyeworks].size) title: "At least #{pluralize @items_needed[:dyeworks].size, 'potion'}, " +
}< "average " +
#{pluralize @items_needed[:dyeworks].size, "potion"} "#{dyeworks_average_num_potions_for @items_needed[:dyeworks]}, " +
"could be more"
}
?? potions
(~#{dyeworks_estimated_potions_cost_for @items_needed[:dyeworks]} NC)
%td.actions-cell %td.actions-cell
- if @items_needed[:dyeworks].present? - if @items_needed[:dyeworks].present?
%button{onclick: "alert('Todo!')"} %button{onclick: "alert('Todo!')"}