Compare commits
No commits in common. "bbd1849e19045564452bdda28788c539a0c2b7ae" and "cd28c26ae72a1fa1d25c0133b0e169f6f9b7d6a0" have entirely different histories.
bbd1849e19
...
cd28c26ae7
4 changed files with 47 additions and 55 deletions
|
@ -13,7 +13,7 @@ class ItemsController < ApplicationController
|
||||||
|
|
||||||
@items = @query.results.paginate(
|
@items = @query.results.paginate(
|
||||||
page: params[:page], per_page: per_page)
|
page: params[:page], per_page: per_page)
|
||||||
assign_closeted!(@items)
|
assign_closeted!
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
@ -54,7 +54,7 @@ class ItemsController < ApplicationController
|
||||||
end
|
end
|
||||||
elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
|
elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
|
||||||
@items = Item.find(params[:ids])
|
@items = Item.find(params[:ids])
|
||||||
assign_closeted!(@items)
|
assign_closeted!
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json { render json: @items }
|
format.json { render json: @items }
|
||||||
end
|
end
|
||||||
|
@ -104,7 +104,7 @@ class ItemsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
@items = @pet_type.needed_items.order(:name)
|
@items = @pet_type.needed_items.order(:name)
|
||||||
assign_closeted!(@items)
|
assign_closeted!
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { @pet_name = params[:name] ; render :layout => 'application' }
|
format.html { @pet_name = params[:name] ; render :layout => 'application' }
|
||||||
|
@ -113,15 +113,12 @@ class ItemsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def sources
|
def sources
|
||||||
# Load all the items, then group them by source.
|
|
||||||
item_ids = params[:ids].split(",")
|
item_ids = params[:ids].split(",")
|
||||||
@all_items = Item.where(id: item_ids).includes(:nc_mall_record).
|
@items = Item.where(id: item_ids).includes(:nc_mall_record).
|
||||||
includes(:dyeworks_base_item).order(:name).limit(50)
|
includes(:dyeworks_base_item).order(:name).limit(50)
|
||||||
@items = @all_items.group_by(&:source).tap { |i| i.default = [] }
|
assign_closeted!
|
||||||
|
|
||||||
assign_closeted!(@all_items)
|
if @items.empty?
|
||||||
|
|
||||||
if @all_items.empty?
|
|
||||||
render file: "public/404.html", status: :not_found, layout: nil
|
render file: "public/404.html", status: :not_found, layout: nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -129,14 +126,23 @@ class ItemsController < ApplicationController
|
||||||
# For Dyeworks items whose base is currently in the NC Mall, preload their
|
# 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
|
# trade values. We'll use this to determine which ones are fully buyable rn
|
||||||
# (because Owls tracks this data and we don't).
|
# (because Owls tracks this data and we don't).
|
||||||
Item.preload_nc_trade_values(@items[:dyeworks])
|
Item.preload_nc_trade_values(@items.select(&:dyeworks_base_buyable?))
|
||||||
|
|
||||||
|
# Group the items by category!
|
||||||
|
@nc_mall_items = @items.select(&:currently_in_mall?).
|
||||||
|
reject(&:dyeworks_buyable?)
|
||||||
|
@buyable_dyeworks_items = @items.select(&:dyeworks_buyable?)
|
||||||
|
@np_items = @items.select(&:np?)
|
||||||
|
@pb_items = @items.select(&:pb?)
|
||||||
|
@other_nc_items = @items.select(&:nc?).reject(&:currently_in_mall?).
|
||||||
|
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(@items[:other_nc]) }
|
trade_values_task = Async { Item.preload_nc_trade_values(@other_nc_items) }
|
||||||
|
|
||||||
# Also, PB items have some special handling: we group them by color, then
|
# Also, PB items have some special handling: we group them by color, then
|
||||||
# load example pet types for the colors that don't have paint brushes.
|
# load example pet types for the colors that don't have paint brushes.
|
||||||
@pb_items_by_color = @items[:pb].group_by(&:pb_color).
|
@pb_items_by_color = @pb_items.group_by(&:pb_color).
|
||||||
sort_by { |color, items| color&.name }.to_h
|
sort_by { |color, items| color&.name }.to_h
|
||||||
|
|
||||||
colors_without_thumbnails = @pb_items_by_color.keys.
|
colors_without_thumbnails = @pb_items_by_color.keys.
|
||||||
|
@ -152,7 +158,11 @@ class ItemsController < ApplicationController
|
||||||
|
|
||||||
# Create a second value that only include the items the user *needs*: that
|
# Create a second value that only include the items the user *needs*: that
|
||||||
# is, that they don't already own.
|
# is, that they don't already own.
|
||||||
@items_needed = @items.transform_values { |items| items.reject(&:owned?) }
|
@nc_mall_items_needed = @nc_mall_items.reject(&:owned?)
|
||||||
|
@buyable_dyeworks_items_needed = @buyable_dyeworks_items.reject(&:owned?)
|
||||||
|
@np_items_needed = @np_items.reject(&:owned?)
|
||||||
|
@pb_items_needed = @pb_items.reject(&:owned?)
|
||||||
|
@other_nc_items_needed = @other_nc_items.reject(&:owned?)
|
||||||
@pb_items_needed_by_color =
|
@pb_items_needed_by_color =
|
||||||
@pb_items_by_color.transform_values { |items| items.reject(&:owned?) }
|
@pb_items_by_color.transform_values { |items| items.reject(&:owned?) }
|
||||||
|
|
||||||
|
@ -164,8 +174,8 @@ class ItemsController < ApplicationController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def assign_closeted!(items)
|
def assign_closeted!
|
||||||
current_user.assign_closeted_to_items!(items) if user_signed_in?
|
current_user.assign_closeted_to_items!(@items) if user_signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_appearances
|
def load_appearances
|
||||||
|
|
|
@ -234,7 +234,6 @@ module ItemsHelper
|
||||||
num_items = 0
|
num_items = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
summaries << "0 NC" if summaries.empty?
|
|
||||||
summary = summaries.join(", ")
|
summary = summaries.join(", ")
|
||||||
|
|
||||||
{nc_total:, summary:}
|
{nc_total:, summary:}
|
||||||
|
|
|
@ -213,7 +213,6 @@ class Item < ApplicationRecord
|
||||||
# Mall at any time, rather than as part of a limited-time event. (Owls tracks
|
# Mall at any time, rather than as part of a limited-time event. (Owls tracks
|
||||||
# this, not us!)
|
# this, not us!)
|
||||||
def dyeworks_permanent?
|
def dyeworks_permanent?
|
||||||
return false if nc_trade_value.nil?
|
|
||||||
nc_trade_value.value_text.include?("Permanent Dyeworks")
|
nc_trade_value.value_text.include?("Permanent Dyeworks")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -241,22 +240,6 @@ class Item < ApplicationRecord
|
||||||
Item.find_by_name(name_match["base"])
|
Item.find_by_name(name_match["base"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def source
|
|
||||||
if dyeworks_buyable?
|
|
||||||
:dyeworks
|
|
||||||
elsif currently_in_mall?
|
|
||||||
:nc_mall
|
|
||||||
elsif nc?
|
|
||||||
:other_nc
|
|
||||||
elsif np?
|
|
||||||
:np
|
|
||||||
elsif pb?
|
|
||||||
:pb
|
|
||||||
else
|
|
||||||
raise "Item has no matching source (should not happen?)"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def owned?
|
def owned?
|
||||||
@owned || false
|
@owned || false
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
- title "Item Getting Guide"
|
- title "Item Getting Guide"
|
||||||
%h1#title Item Getting Guide
|
%h1#title Item Getting Guide
|
||||||
|
|
||||||
- if @items[:nc_mall].present?
|
- if @nc_mall_items.present?
|
||||||
%h2 NC Mall items
|
%h2 NC Mall items
|
||||||
:markdown
|
:markdown
|
||||||
These items are available in the NC Mall right now! You can buy them
|
These items are available in the NC Mall right now! You can buy them
|
||||||
|
@ -16,22 +16,22 @@
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%th
|
%th
|
||||||
Total: #{nc_total_for @items_needed[:nc_mall]} NC
|
Total: #{nc_total_for @nc_mall_items_needed} NC
|
||||||
(#{pluralize @items_needed[:nc_mall].size, "item"})
|
(#{pluralize @nc_mall_items_needed.size, "item"})
|
||||||
|
|
||||||
%td.actions-cell
|
%td.actions-cell
|
||||||
- if @items_needed[:nc_mall].present?
|
- if @nc_mall_items_needed.present?
|
||||||
%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
|
||||||
- @items[:nc_mall].each do |item|
|
- @nc_mall_items.each do |item|
|
||||||
= render "item_list_row", item: do
|
= render "item_list_row", item: do
|
||||||
%button{onclick: "alert('Todo!')"}
|
%button{onclick: "alert('Todo!')"}
|
||||||
= cart_icon alt: ""
|
= cart_icon alt: ""
|
||||||
Buy (#{item.current_nc_price} NC)
|
Buy (#{item.current_nc_price} NC)
|
||||||
|
|
||||||
- if @items[:dyeworks].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"
|
||||||
|
@ -48,24 +48,24 @@
|
||||||
= 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 @items_needed[:dyeworks]} NC
|
Total: #{dyeworks_nc_total_for @buyable_dyeworks_items_needed} NC
|
||||||
= surround "(", ")" do
|
= surround "(", ")" do
|
||||||
%span.price-breakdown{
|
%span.price-breakdown{
|
||||||
title: "#{dyeworks_items_nc_total_for(@items_needed[:dyeworks])} NC"
|
title: "#{dyeworks_items_nc_total_for(@buyable_dyeworks_items_needed)} NC"
|
||||||
}<
|
}<
|
||||||
#{pluralize @items_needed[:dyeworks].size, "item"}
|
#{pluralize @buyable_dyeworks_items_needed.size, "item"}
|
||||||
+
|
+
|
||||||
%span.price-breakdown{
|
%span.price-breakdown{
|
||||||
title: dyeworks_potions_nc_summary(@items_needed[:dyeworks].size)
|
title: dyeworks_potions_nc_summary(@buyable_dyeworks_items_needed.size)
|
||||||
}<
|
}<
|
||||||
#{pluralize @items_needed[:dyeworks].size, "potion"}
|
#{pluralize @buyable_dyeworks_items_needed.size, "potion"}
|
||||||
%td.actions-cell
|
%td.actions-cell
|
||||||
- if @items_needed[:dyeworks].present?
|
- if @buyable_dyeworks_items_needed.present?
|
||||||
%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
|
||||||
- @items[:dyeworks].each do |item|
|
- @buyable_dyeworks_items.each do |item|
|
||||||
= render "item_list_row", item: do
|
= render "item_list_row", item: do
|
||||||
- base_item = item.dyeworks_base_item
|
- base_item = item.dyeworks_base_item
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
= 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)
|
||||||
|
|
||||||
- if @items[:np].present?
|
- if @np_items.present?
|
||||||
%h2 Neopoint items
|
%h2 Neopoint items
|
||||||
:markdown
|
:markdown
|
||||||
These items can be purchased with Neopoints. For less-expensive items,
|
These items can be purchased with Neopoints. For less-expensive items,
|
||||||
|
@ -102,16 +102,16 @@
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%th{colspan: 2}
|
%th{colspan: 2}
|
||||||
Total: #{pluralize @items_needed[:np].size, "item"}
|
Total: #{pluralize @np_items_needed.size, "item"}
|
||||||
%tbody
|
%tbody
|
||||||
- @items[:np].each do |item|
|
- @np_items.each do |item|
|
||||||
= render "item_list_row", item: do
|
= render "item_list_row", item: do
|
||||||
= button_link_to "Shops", shop_wizard_url_for(item),
|
= button_link_to "Shops", shop_wizard_url_for(item),
|
||||||
target: "_blank", icon: search_icon
|
target: "_blank", icon: search_icon
|
||||||
= button_link_to "Trades", trading_post_url_for(item),
|
= button_link_to "Trades", trading_post_url_for(item),
|
||||||
target: "_blank", icon: search_icon
|
target: "_blank", icon: search_icon
|
||||||
|
|
||||||
- if @pb_items_by_color.present?
|
- if @pb_items.present?
|
||||||
%h2 Paint Brush items
|
%h2 Paint Brush items
|
||||||
:markdown
|
:markdown
|
||||||
These items are part of a paint brush set. Once you paint your pet,
|
These items are part of a paint brush set. Once you paint your pet,
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
- items.each do |item|
|
- items.each do |item|
|
||||||
= render "item_list_row", item:
|
= render "item_list_row", item:
|
||||||
|
|
||||||
- if @items[:other_nc].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, but not directly for sale.
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
|
|
||||||
[mall]: https://ncmall.neopets.com/
|
[mall]: https://ncmall.neopets.com/
|
||||||
|
|
||||||
- if @items[:other_nc].any?(&:nc_trade_value)
|
- if @other_nc_items.any?(&:nc_trade_value)
|
||||||
:markdown
|
:markdown
|
||||||
The [Owls Value Guide][owls] often has more details about how to get
|
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
|
these items, and how much they're usually worth in the NC Trading
|
||||||
|
@ -184,9 +184,9 @@
|
||||||
%thead
|
%thead
|
||||||
%td
|
%td
|
||||||
%th{colspan: 2}
|
%th{colspan: 2}
|
||||||
Total: #{pluralize @items_needed[:other_nc].size, "item"}
|
Total: #{pluralize @other_nc_items_needed.size, "item"}
|
||||||
%tbody
|
%tbody
|
||||||
- @items[:other_nc].each do |item|
|
- @other_nc_items.each do |item|
|
||||||
= 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?
|
||||||
|
|
Loading…
Reference in a new issue