Compare commits
No commits in common. "3310394fb86bf8129d6f7bf15e0183d45353f4ac" and "5de9e2a27ba94329406ac5ffcdbfdb11e18dcca1" have entirely different histories.
3310394fb8
...
5de9e2a27b
6 changed files with 44 additions and 127 deletions
|
@ -67,12 +67,6 @@
|
||||||
text-decoration-style: dotted
|
text-decoration-style: dotted
|
||||||
cursor: help
|
cursor: help
|
||||||
|
|
||||||
.dyeworks-timeframe
|
|
||||||
font-style: italic
|
|
||||||
text-decoration-line: underline
|
|
||||||
text-decoration-style: dotted
|
|
||||||
cursor: help
|
|
||||||
|
|
||||||
.special-color-explanation
|
.special-color-explanation
|
||||||
text-wrap: balance
|
text-wrap: balance
|
||||||
font-style: italic
|
font-style: italic
|
||||||
|
@ -84,12 +78,13 @@
|
||||||
a
|
a
|
||||||
color: inherit
|
color: inherit
|
||||||
|
|
||||||
.owls-info-link
|
a[title]
|
||||||
cursor: help
|
|
||||||
|
|
||||||
.owls-info-label
|
|
||||||
text-decoration-line: underline
|
text-decoration-line: underline
|
||||||
text-decoration-style: dotted
|
text-decoration-style: dotted
|
||||||
|
cursor: help
|
||||||
|
|
||||||
|
&:hover, &:focus
|
||||||
|
text-decoration-style: solid
|
||||||
|
|
||||||
/* For wearable items that belong to a specific set that all come together,
|
/* For wearable items that belong to a specific set that all come together,
|
||||||
* like a Paint Brush. */
|
* like a Paint Brush. */
|
||||||
|
|
|
@ -122,19 +122,14 @@ 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_buyable?)
|
reject(&:dyeworks_active?)
|
||||||
@buyable_dyeworks_items = @items.select(&:dyeworks_buyable?)
|
@active_dyeworks_items = @items.select(&:dyeworks_active?)
|
||||||
@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_buyable?)
|
reject(&:dyeworks_active?)
|
||||||
|
|
||||||
# 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) }
|
||||||
|
|
|
@ -156,36 +156,22 @@ module ItemsHelper
|
||||||
"Last updated: #{date_str} (#{time_ago_str} ago)"
|
"Last updated: #{date_str} (#{time_ago_str} ago)"
|
||||||
end
|
end
|
||||||
|
|
||||||
NC_TRADE_VALUE_ESTIMATE_PATTERN = %r{
|
def nc_trade_value_subtitle_for(item)
|
||||||
^\s*
|
value = item.nc_trade_value
|
||||||
(?:
|
return nil if value.nil?
|
||||||
# Case 1: A single number
|
|
||||||
(?<single>[0-9]+)
|
link_to "Owls listing: #{item.nc_trade_value.value_text}",
|
||||||
|
|
"https://www.neopets.com/~owls", target: "_blank",
|
||||||
# Case 2: A range from low to high
|
title: 'Owls keeps track of approximate "capsule" values of NC items ' +
|
||||||
(?<low>[0-9]+)
|
"for trading. Items with similar values can often be traded for one " +
|
||||||
\p{Dash_Punctuation}
|
"another. This is an estimate, not a rule!"
|
||||||
(?<high>[0-9]+)
|
|
||||||
)
|
|
||||||
\s*$
|
|
||||||
}x
|
|
||||||
def nc_trade_value_is_estimate(nc_trade_value)
|
|
||||||
nc_trade_value.value_text.match?(NC_TRADE_VALUE_ESTIMATE_PATTERN)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Try to parse the NC trade value's text into something styled a bit more
|
def dyeworks_explanation_subtitle_for(item)
|
||||||
# nicely for our use case.
|
base_item = item.dyeworks_base_item
|
||||||
def nc_trade_value_estimate_text(nc_trade_value)
|
content_tag :span, class: "dyeworks-explanation" do
|
||||||
match = nc_trade_value.value_text.match(NC_TRADE_VALUE_ESTIMATE_PATTERN)
|
concat link_to(base_item.name, base_item, target: "_blank")
|
||||||
return nc_trade_value if match.nil?
|
concat " + 1 Potion"
|
||||||
|
|
||||||
match => {single:, low:, high:}
|
|
||||||
if single.present?
|
|
||||||
pluralize single.to_i, "capsule"
|
|
||||||
elsif low.present? && high.present?
|
|
||||||
"#{low}–#{high} capsules"
|
|
||||||
else
|
|
||||||
nc_trade_value
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -203,27 +203,11 @@ 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. It may or may not currently be *dyeable* in the NC Mall,
|
# in the NC Mall, then dyed via Dyeworks.
|
||||||
# because Dyeworks eligibility is often a limited-time event.
|
def dyeworks_active?
|
||||||
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.
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
-# Run the block first, so we can get the subtitle content if provided! Clear
|
- subtitle = nil unless defined? subtitle
|
||||||
-# out any old values beforehand, too.
|
|
||||||
- content_for :subtitle, "", flush: true
|
|
||||||
- content = yield
|
|
||||||
- subtitle = yield :subtitle
|
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td.thumbnail-cell
|
%td.thumbnail-cell
|
||||||
|
@ -12,4 +8,4 @@
|
||||||
= link_to item.name, item, target: "_blank"
|
= link_to item.name, item, target: "_blank"
|
||||||
- if subtitle.present?
|
- if subtitle.present?
|
||||||
.subtitle= subtitle
|
.subtitle= subtitle
|
||||||
%td.actions-cell= content
|
%td.actions-cell= yield
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
[nc]: https://secure.nc.neopets.com/get-neocash
|
[nc]: https://secure.nc.neopets.com/get-neocash
|
||||||
[gc]: https://secure.nc.neopets.com/nickcash-cards
|
[gc]: https://secure.nc.neopets.com/nickcash-cards
|
||||||
|
|
||||||
%table.item-list
|
%table.item-list
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
|
@ -30,7 +29,7 @@
|
||||||
= cart_icon alt: ""
|
= cart_icon alt: ""
|
||||||
Buy (#{item.current_nc_price} NC)
|
Buy (#{item.current_nc_price} NC)
|
||||||
|
|
||||||
- if @buyable_dyeworks_items.present?
|
- if @active_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"
|
||||||
|
@ -38,46 +37,35 @@
|
||||||
[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.
|
||||||
|
|
||||||
[dyeworks]: https://www.neopets.com/mall/dyeworks/
|
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
|
%table.item-list
|
||||||
%thead
|
%thead
|
||||||
%td.thumbnail-cell
|
%td.thumbnail-cell
|
||||||
= 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 @buyable_dyeworks_items} NC
|
Total: #{dyeworks_nc_total_for @active_dyeworks_items} NC
|
||||||
= surround "(", ")" do
|
= surround "(", ")" do
|
||||||
%span.price-breakdown{
|
%span.price-breakdown{
|
||||||
title: "#{dyeworks_items_nc_total_for(@buyable_dyeworks_items)} NC"
|
title: "#{dyeworks_items_nc_total_for(@active_dyeworks_items)} NC"
|
||||||
}<
|
}<
|
||||||
#{pluralize @buyable_dyeworks_items.size, "item"}
|
#{pluralize @active_dyeworks_items.size, "item"}
|
||||||
+
|
+
|
||||||
%span.price-breakdown{
|
%span.price-breakdown{
|
||||||
title: dyeworks_potions_nc_summary(@buyable_dyeworks_items.size)
|
title: dyeworks_potions_nc_summary(@active_dyeworks_items.size)
|
||||||
}<
|
}<
|
||||||
#{pluralize @buyable_dyeworks_items.size, "potion"}
|
#{pluralize @active_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
|
||||||
- @buyable_dyeworks_items.each do |item|
|
- @active_dyeworks_items.each do |item|
|
||||||
= render "item_list_row", item: do
|
= render "item_list_row", item:,
|
||||||
- base_item = item.dyeworks_base_item
|
subtitle: dyeworks_explanation_subtitle_for(item) do
|
||||||
|
|
||||||
- content_for :subtitle, flush: true do
|
|
||||||
= link_to base_item.name, base_item, target: "_blank"
|
|
||||||
+ 1 potion
|
|
||||||
- if item.dyeworks_permanent?
|
|
||||||
%span.dyeworks-timeframe{
|
|
||||||
title: "This recipe is NOT currently scheduled to be removed " +
|
|
||||||
"from Dyeworks. It might not stay forever, but it's also " +
|
|
||||||
"not part of a known limited-time event, like most " +
|
|
||||||
"Dyeworks items are."
|
|
||||||
}
|
|
||||||
(Permanent)
|
|
||||||
|
|
||||||
%button{onclick: "alert('Todo!')"}
|
%button{onclick: "alert('Todo!')"}
|
||||||
= cart_icon alt: ""
|
= cart_icon alt: ""
|
||||||
Buy base (#{item.dyeworks_base_item.current_nc_price} NC)
|
Buy base (#{item.dyeworks_base_item.current_nc_price} NC)
|
||||||
|
@ -93,7 +81,6 @@
|
||||||
[wiz]: https://www.neopets.com/shops/wizard.phtml
|
[wiz]: https://www.neopets.com/shops/wizard.phtml
|
||||||
[tp]: https://www.neopets.com/island/tradingpost.phtml?type=browse
|
[tp]: https://www.neopets.com/island/tradingpost.phtml?type=browse
|
||||||
[ag]: https://www.neopets.com/genie.phtml
|
[ag]: https://www.neopets.com/genie.phtml
|
||||||
|
|
||||||
%table.item-list
|
%table.item-list
|
||||||
%thead
|
%thead
|
||||||
%td
|
%td
|
||||||
|
@ -114,7 +101,6 @@
|
||||||
these items will be semi-permanently added to your Closet, even if your
|
these items will be semi-permanently added to your Closet, even if your
|
||||||
pet changes color again! You can use this to mix-and-match styles for
|
pet changes color again! You can use this to mix-and-match styles for
|
||||||
"cross-paint" outfits.
|
"cross-paint" outfits.
|
||||||
|
|
||||||
- @pb_items_by_color.each do |color, items|
|
- @pb_items_by_color.each do |color, items|
|
||||||
%table.item-list{"data-group-type": "bundle"}
|
%table.item-list{"data-group-type": "bundle"}
|
||||||
%thead
|
%thead
|
||||||
|
@ -156,21 +142,13 @@
|
||||||
- if @other_nc_items.present?
|
- if @other_nc_items.present?
|
||||||
%h2 Neocash items (Capsules, events, retired, etc.)
|
%h2 Neocash items (Capsules, events, retired, etc.)
|
||||||
:markdown
|
:markdown
|
||||||
These items are part of the Neocash economy, but not directly for sale.
|
These items are part of the Neocash economy and can't be purchased with
|
||||||
Sometimes they're available in the [NC Mall][mall], via special
|
Neopoints. We don't track all the details of how to get these items
|
||||||
bundles or events. Sometimes they're retired, and can only be obtained via
|
right now! Sometimes they're available via packs or capsules or events
|
||||||
gifts or trades.
|
in the [NC Mall][mall]. Sometimes they're retired and can't be
|
||||||
|
purchased at all anymore, and can only be obtained via gifts or trades.
|
||||||
|
|
||||||
[mall]: https://ncmall.neopets.com/
|
[mall]: https://ncmall.neopets.com/
|
||||||
|
|
||||||
- if @other_nc_items.any?(&:nc_trade_value)
|
|
||||||
:markdown
|
|
||||||
The [Owls Value Guide][owls] often has more details about how to get
|
|
||||||
these items, and how much they're usually worth in the NC Trading
|
|
||||||
community. We've loaded their info here for you, too! Thanks, Owls team!
|
|
||||||
|
|
||||||
[owls]: https://www.neopets.com/~owls
|
|
||||||
|
|
||||||
%table.item-list
|
%table.item-list
|
||||||
%thead
|
%thead
|
||||||
%td
|
%td
|
||||||
|
@ -178,24 +156,7 @@
|
||||||
Total: #{pluralize @other_nc_items.size, "item"}
|
Total: #{pluralize @other_nc_items.size, "item"}
|
||||||
%tbody
|
%tbody
|
||||||
- @other_nc_items.each do |item|
|
- @other_nc_items.each do |item|
|
||||||
= render "item_list_row", item: do
|
= render "item_list_row", item:, subtitle: nc_trade_value_subtitle_for(item) do
|
||||||
- content_for :subtitle, flush: true do
|
|
||||||
- if item.nc_trade_value.present?
|
|
||||||
- if nc_trade_value_is_estimate(item.nc_trade_value)
|
|
||||||
= link_to "https://www.neopets.com/~owls",
|
|
||||||
class: "owls-info-link", 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!' do
|
|
||||||
%span.owls-info-label [Owls]
|
|
||||||
Estimated value:
|
|
||||||
= nc_trade_value_estimate_text(item.nc_trade_value)
|
|
||||||
- else
|
|
||||||
= link_to "https://www.neopets.com/~owls",
|
|
||||||
class: "owls-info-link", target: "_blank",
|
|
||||||
title: "Owls keeps track of how to get certain special items, even when there isn't a clear NC trade estimate." do
|
|
||||||
%span.owls-info-label [Owls]
|
|
||||||
Trade info:
|
|
||||||
#{item.nc_trade_value.value_text}
|
|
||||||
|
|
||||||
= button_link_to "NC Trades",
|
= button_link_to "NC Trades",
|
||||||
item_trades_path(item, type: "offering"),
|
item_trades_path(item, type: "offering"),
|
||||||
target: "_blank", icon: search_icon
|
target: "_blank", icon: search_icon
|
||||||
|
|
Loading…
Reference in a new issue