Add Dyeworks section to Item Getting Guide (but it's currently wrong!)

I started writing this up, then sent a preview to a friend, and he was
like "oh cool, but also this is not correct?"

I didn't realize Dyeworks has limited-time support to be *able* to dye
certain items. Hey, glad we're writing this guide for people like me,
then! lol

I wonder if we can lean on Owls for this. It seems like they already
list "Permanent Dyeworks" for some items, I wonder if they say
something special for active limited-edition Dyeworks items!
This commit is contained in:
Emi Matchu 2024-06-09 13:25:59 -07:00
parent 857cb547ed
commit 5de9e2a27b
5 changed files with 126 additions and 9 deletions

View file

@ -26,8 +26,8 @@
img
display: block
width: 100%
height: 100%
width: 2.5em
height: 2.5em
.name-cell a
text-decoration: none
@ -62,6 +62,11 @@
/* Bootstrap's Purple 600 */
+awesome-button-color(#59359a)
.price-breakdown
text-decoration-line: underline
text-decoration-style: dotted
cursor: help
.special-color-explanation
text-wrap: balance
font-style: italic
@ -70,9 +75,13 @@
font-size: 85%
opacity: .85
a
color: inherit
a[title]
text-decoration-line: underline
text-decoration-style: dotted
cursor: help
&:hover, &:focus
text-decoration-style: solid

View file

@ -114,8 +114,8 @@ class ItemsController < ApplicationController
def sources
item_ids = params[:ids].split(",")
@items = Item.where(id: item_ids).includes(:nc_mall_record).order(:name).
limit(50)
@items = Item.where(id: item_ids).includes(:nc_mall_record).
includes(:dyeworks_base_item).order(:name).limit(50)
if @items.empty?
render file: "public/404.html", status: :not_found, layout: nil
@ -123,10 +123,13 @@ class ItemsController < ApplicationController
end
# Group the items by category!
@nc_mall_items = @items.select(&:currently_in_mall?)
@other_nc_items = @items.select(&:nc?).reject(&:currently_in_mall?)
@nc_mall_items = @items.select(&:currently_in_mall?).
reject(&:dyeworks_active?)
@active_dyeworks_items = @items.select(&:dyeworks_active?)
@np_items = @items.select(&:np?)
@pb_items = @items.select(&:pb?)
@other_nc_items = @items.select(&:nc?).reject(&:currently_in_mall?).
reject(&:dyeworks_active?)
# Start loading the NC trade values for the non-Mall NC items.
trade_values_task = Async { Item.preload_nc_trade_values(@other_nc_items) }

View file

@ -161,12 +161,70 @@ module ItemsHelper
return nil if value.nil?
link_to "Owls listing: #{item.nc_trade_value.value_text}",
"https://www.neopets.com/~owls",
"https://www.neopets.com/~owls", target: "_blank",
title: 'Owls keeps track of approximate "capsule" values of NC items ' +
"for trading. Items with similar values can often be traded for one " +
"another. This is an estimate, not a rule!"
end
def dyeworks_explanation_subtitle_for(item)
base_item = item.dyeworks_base_item
content_tag :span, class: "dyeworks-explanation" do
concat link_to(base_item.name, base_item, target: "_blank")
concat " + 1 Potion"
end
end
def nc_total_for(items)
items.map(&:current_nc_price).sum
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]
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
summary = summaries.join(", ")
{nc_total:, summary:}
end
private
def build_on_pet_types(species, special_color=nil, &block)

View file

@ -202,6 +202,12 @@ class Item < ApplicationRecord
dyeworks_base_item.present?
end
# Whether this is a Dyeworks item whose base item can currently be purchased
# in the NC Mall, then dyed via Dyeworks.
def dyeworks_active?
dyeworks_base_item.present? && dyeworks_base_item.currently_in_mall?
end
DYEWORKS_NAME_PATTERN = %r{
^(
# Most Dyeworks items have a colon in the name.

View file

@ -15,7 +15,7 @@
%tr
%td
%th
Total: #{@nc_mall_items.map(&:current_nc_price).sum} NC
Total: #{nc_total_for @nc_mall_items} NC
(#{pluralize @nc_mall_items.size, "item"})
%td.actions-cell
@ -29,6 +29,47 @@
= cart_icon alt: ""
Buy (#{item.current_nc_price} NC)
- if @active_dyeworks_items.present?
%h2 Dyeworks items
:markdown
These are recolored "Dyeworks" variants of items. First get the "base"
item, then get a Dyeworks Hue Brew Potion, and combine them in the
[Dyeworks][dyeworks] section of the NC Mall! Potions can also be bought in
bundles of 5 or 10.
TODO: This is currently incorrect! Dyeworks items can't always be dyed, we
need to keep track of which ones actually can be right now!
[dyeworks]: https://www.neopets.com/mall/dyeworks/
%table.item-list
%thead
%td.thumbnail-cell
= image_tag "https://images.neopets.com/items/mall_80x80_cleaning.gif",
alt: "Dyeworks Hue Brew Potion"
%th
Total: #{dyeworks_nc_total_for @active_dyeworks_items} NC
= surround "(", ")" do
%span.price-breakdown{
title: "#{dyeworks_items_nc_total_for(@active_dyeworks_items)} NC"
}<
#{pluralize @active_dyeworks_items.size, "item"}
+
%span.price-breakdown{
title: dyeworks_potions_nc_summary(@active_dyeworks_items.size)
}<
#{pluralize @active_dyeworks_items.size, "potion"}
%td.actions-cell
%button{onclick: "alert('Todo!')"}
= cart_icon alt: ""
Buy all in NC Mall
%tbody
- @active_dyeworks_items.each do |item|
= render "item_list_row", item:,
subtitle: dyeworks_explanation_subtitle_for(item) do
%button{onclick: "alert('Todo!')"}
= cart_icon alt: ""
Buy base (#{item.dyeworks_base_item.current_nc_price} NC)
- if @np_items.present?
%h2 Neopoint items
:markdown
@ -99,7 +140,7 @@
= render "item_list_row", item:
- if @other_nc_items.present?
%h2 Neocash items (Capsules, Dyeworks, events, retired, etc.)
%h2 Neocash items (Capsules, events, retired, etc.)
:markdown
These items are part of the Neocash economy and can't be purchased with
Neopoints. We don't track all the details of how to get these items