forked from OpenNeo/impress
Use Owls to check for Permanent Dyeworks items
Previously, I added a Dyeworks section that was incorrect: the base item being available in the NC Mall does *not* mean you can necessarily dye it with a potion! In this change, we lean on Owls to tell us more about Dyeworks status, and only group items in this section that Owls has marked as "Permanent Dyeworks". We don't have support for limited-time Dyeworks items yet—I've sent out a message asking the Owls team for more info on what they do for those items!
This commit is contained in:
parent
5de9e2a27b
commit
b22ccbc2a3
3 changed files with 33 additions and 15 deletions
|
@ -122,14 +122,19 @@ class ItemsController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# For Dyeworks items whose base is currently in the NC Mall, preload their
|
||||||
|
# trade values. We'll use this to determine which ones are fully buyable rn
|
||||||
|
# (because Owls tracks this data and we don't).
|
||||||
|
Item.preload_nc_trade_values(@items.select(&:dyeworks_base_buyable?))
|
||||||
|
|
||||||
# Group the items by category!
|
# Group the items by category!
|
||||||
@nc_mall_items = @items.select(&:currently_in_mall?).
|
@nc_mall_items = @items.select(&:currently_in_mall?).
|
||||||
reject(&:dyeworks_active?)
|
reject(&:dyeworks_buyable?)
|
||||||
@active_dyeworks_items = @items.select(&:dyeworks_active?)
|
@buyable_dyeworks_items = @items.select(&:dyeworks_buyable?)
|
||||||
@np_items = @items.select(&:np?)
|
@np_items = @items.select(&:np?)
|
||||||
@pb_items = @items.select(&:pb?)
|
@pb_items = @items.select(&:pb?)
|
||||||
@other_nc_items = @items.select(&:nc?).reject(&:currently_in_mall?).
|
@other_nc_items = @items.select(&:nc?).reject(&:currently_in_mall?).
|
||||||
reject(&:dyeworks_active?)
|
reject(&:dyeworks_buyable?)
|
||||||
|
|
||||||
# Start loading the NC trade values for the non-Mall NC items.
|
# Start loading the NC trade values for the non-Mall NC items.
|
||||||
trade_values_task = Async { Item.preload_nc_trade_values(@other_nc_items) }
|
trade_values_task = Async { Item.preload_nc_trade_values(@other_nc_items) }
|
||||||
|
|
|
@ -203,11 +203,27 @@ class Item < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
# Whether this is a Dyeworks item whose base item can currently be purchased
|
# Whether this is a Dyeworks item whose base item can currently be purchased
|
||||||
# in the NC Mall, then dyed via Dyeworks.
|
# in the NC Mall. It may or may not currently be *dyeable* in the NC Mall,
|
||||||
def dyeworks_active?
|
# because Dyeworks eligibility is often a limited-time event.
|
||||||
|
def dyeworks_base_buyable?
|
||||||
dyeworks_base_item.present? && dyeworks_base_item.currently_in_mall?
|
dyeworks_base_item.present? && dyeworks_base_item.currently_in_mall?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Whether this is one of the few Dyeworks items that can be dyed in the NC
|
||||||
|
# Mall at any time, rather than as part of a limited-time event. (Owls tracks
|
||||||
|
# this, not us!)
|
||||||
|
def dyeworks_permanent?
|
||||||
|
nc_trade_value.value_text.include?("Permanent Dyeworks")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Whether this is a Dyeworks item whose base item can currently be purchased
|
||||||
|
# in the NC Mall, then dyed via Dyeworks. (Owls tracks this last part!)
|
||||||
|
def dyeworks_buyable?
|
||||||
|
# TODO: Add support for limited-time Dyeworks items. Does Owls offer this
|
||||||
|
# info too? (At time of writing, there are no active Dyeworks events.)
|
||||||
|
dyeworks_base_buyable? && dyeworks_permanent?
|
||||||
|
end
|
||||||
|
|
||||||
DYEWORKS_NAME_PATTERN = %r{
|
DYEWORKS_NAME_PATTERN = %r{
|
||||||
^(
|
^(
|
||||||
# Most Dyeworks items have a colon in the name.
|
# Most Dyeworks items have a colon in the name.
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
= cart_icon alt: ""
|
= cart_icon alt: ""
|
||||||
Buy (#{item.current_nc_price} NC)
|
Buy (#{item.current_nc_price} NC)
|
||||||
|
|
||||||
- if @active_dyeworks_items.present?
|
- if @buyable_dyeworks_items.present?
|
||||||
%h2 Dyeworks items
|
%h2 Dyeworks items
|
||||||
:markdown
|
:markdown
|
||||||
These are recolored "Dyeworks" variants of items. First get the "base"
|
These are recolored "Dyeworks" variants of items. First get the "base"
|
||||||
|
@ -37,9 +37,6 @@
|
||||||
[Dyeworks][dyeworks] section of the NC Mall! Potions can also be bought in
|
[Dyeworks][dyeworks] section of the NC Mall! Potions can also be bought in
|
||||||
bundles of 5 or 10.
|
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/
|
[dyeworks]: https://www.neopets.com/mall/dyeworks/
|
||||||
%table.item-list
|
%table.item-list
|
||||||
%thead
|
%thead
|
||||||
|
@ -47,23 +44,23 @@
|
||||||
= image_tag "https://images.neopets.com/items/mall_80x80_cleaning.gif",
|
= image_tag "https://images.neopets.com/items/mall_80x80_cleaning.gif",
|
||||||
alt: "Dyeworks Hue Brew Potion"
|
alt: "Dyeworks Hue Brew Potion"
|
||||||
%th
|
%th
|
||||||
Total: #{dyeworks_nc_total_for @active_dyeworks_items} NC
|
Total: #{dyeworks_nc_total_for @buyable_dyeworks_items} NC
|
||||||
= surround "(", ")" do
|
= surround "(", ")" do
|
||||||
%span.price-breakdown{
|
%span.price-breakdown{
|
||||||
title: "#{dyeworks_items_nc_total_for(@active_dyeworks_items)} NC"
|
title: "#{dyeworks_items_nc_total_for(@buyable_dyeworks_items)} NC"
|
||||||
}<
|
}<
|
||||||
#{pluralize @active_dyeworks_items.size, "item"}
|
#{pluralize @buyable_dyeworks_items.size, "item"}
|
||||||
+
|
+
|
||||||
%span.price-breakdown{
|
%span.price-breakdown{
|
||||||
title: dyeworks_potions_nc_summary(@active_dyeworks_items.size)
|
title: dyeworks_potions_nc_summary(@buyable_dyeworks_items.size)
|
||||||
}<
|
}<
|
||||||
#{pluralize @active_dyeworks_items.size, "potion"}
|
#{pluralize @buyable_dyeworks_items.size, "potion"}
|
||||||
%td.actions-cell
|
%td.actions-cell
|
||||||
%button{onclick: "alert('Todo!')"}
|
%button{onclick: "alert('Todo!')"}
|
||||||
= cart_icon alt: ""
|
= cart_icon alt: ""
|
||||||
Buy all in NC Mall
|
Buy all in NC Mall
|
||||||
%tbody
|
%tbody
|
||||||
- @active_dyeworks_items.each do |item|
|
- @buyable_dyeworks_items.each do |item|
|
||||||
= render "item_list_row", item:,
|
= render "item_list_row", item:,
|
||||||
subtitle: dyeworks_explanation_subtitle_for(item) do
|
subtitle: dyeworks_explanation_subtitle_for(item) do
|
||||||
%button{onclick: "alert('Todo!')"}
|
%button{onclick: "alert('Todo!')"}
|
||||||
|
|
Loading…
Reference in a new issue