From 2e3d5d2020a988adf41420985f617116d74e4176 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 20 Jun 2024 13:14:51 -0700 Subject: [PATCH] Vaguer potions info for Dyeworks in Item Getting Guide --- app/helpers/items_helper.rb | 46 +++++-------------------------- app/views/items/sources.html.haml | 19 ++++++------- 2 files changed, 16 insertions(+), 49 deletions(-) diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb index b92b5ad6..f25d3144 100644 --- a/app/helpers/items_helper.rb +++ b/app/helpers/items_helper.rb @@ -194,50 +194,18 @@ module ItemsHelper end 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) end - def dyeworks_potions_nc_total(num_items) - dyeworks_potions_nc_breakdown(num_items)[:nc_total] + def dyeworks_average_num_potions_for(items) + # 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 - def dyeworks_potions_nc_summary(num_items) - dyeworks_potions_nc_breakdown(num_items)[:summary] - end - - 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:} + def dyeworks_estimated_potions_cost_for(items) + # NOTE: You could do bundles too, but let's just keep it simple. + dyeworks_average_num_potions_for(items) * 125 end def probability(p) diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index 4b2a56b3..d3ca9c30 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -49,16 +49,15 @@ alt: "Dyeworks Hue Brew Potion" %th 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{ - title: dyeworks_potions_nc_summary(@items_needed[:dyeworks].size) - }< - #{pluralize @items_needed[:dyeworks].size, "potion"} + + + %span.price-breakdown{ + title: "At least #{pluralize @items_needed[:dyeworks].size, 'potion'}, " + + "average " + + "#{dyeworks_average_num_potions_for @items_needed[:dyeworks]}, " + + "could be more" + } + ?? potions + (~#{dyeworks_estimated_potions_cost_for @items_needed[:dyeworks]} NC) %td.actions-cell - if @items_needed[:dyeworks].present? %button{onclick: "alert('Todo!')"}