1
0
Fork 0
forked from OpenNeo/impress

Improve Owls value presentation in Item Getting Guide

This commit is contained in:
Emi Matchu 2024-06-09 19:22:34 -07:00
parent be525d1d67
commit 3310394fb8
3 changed files with 61 additions and 11 deletions

View file

@ -85,10 +85,11 @@
color: inherit color: inherit
.owls-info-link .owls-info-link
cursor: help
.owls-info-label .owls-info-label
text-decoration-line: underline text-decoration-line: underline
text-decoration-style: dotted text-decoration-style: dotted
cursor: help
/* 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. */

View file

@ -156,6 +156,39 @@ 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{
^\s*
(?:
# Case 1: A single number
(?<single>[0-9]+)
|
# Case 2: A range from low to high
(?<low>[0-9]+)
\p{Dash_Punctuation}
(?<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
# Try to parse the NC trade value's text into something styled a bit more
# nicely for our use case.
def nc_trade_value_estimate_text(nc_trade_value)
match = nc_trade_value.value_text.match(NC_TRADE_VALUE_ESTIMATE_PATTERN)
return nc_trade_value if match.nil?
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
def nc_total_for(items) def nc_total_for(items)
items.map(&:current_nc_price).sum items.map(&:current_nc_price).sum
end end

View file

@ -156,14 +156,21 @@
- 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 and can't be purchased with These items are part of the Neocash economy, but not directly for sale.
Neopoints. We don't track all the details of how to get these items Sometimes they're available in the [NC Mall][mall], via special
right now! Sometimes they're available via packs or capsules or events bundles or events. Sometimes they're retired, and can only be obtained via
in the [NC Mall][mall]. Sometimes they're retired and can't be gifts or trades.
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
@ -174,11 +181,20 @@
= render "item_list_row", item: do = render "item_list_row", item: do
- content_for :subtitle, flush: true do - content_for :subtitle, flush: true do
- if item.nc_trade_value.present? - if item.nc_trade_value.present?
= link_to "https://www.neopets.com/~owls", - if nc_trade_value_is_estimate(item.nc_trade_value)
class: "owls-info-link", target: "_blank", = link_to "https://www.neopets.com/~owls",
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 class: "owls-info-link", target: "_blank",
%span.owls-info-label Owls listing: 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
#{item.nc_trade_value.value_text} %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"),