Parse "Limited Dyeworks" items from Owls

Yay thank you Owls team! I might also try to parse the dates too, the
format seems to be "Owls: Limited Dyeworks - Dyeable Thru July 15"
This commit is contained in:
Emi Matchu 2024-06-18 14:59:09 -07:00
parent 4d24a9577f
commit 26dfe13b0e
2 changed files with 20 additions and 3 deletions

View file

@ -217,12 +217,23 @@ class Item < ApplicationRecord
nc_trade_value.value_text.include?("Permanent Dyeworks") nc_trade_value.value_text.include?("Permanent Dyeworks")
end end
# Whether this is a Dyeworks item that can be dyed in the NC Mall ~right now,
# but only as part of a limited-time event. (Owls tracks this, not us!)
def dyeworks_limited?
return false if nc_trade_value.nil?
nc_trade_value.value_text.include?("Limited Dyeworks")
end
# Whether this is a Dyeworks item that can be dyed in the NC Mall ~right now,
# either at any time or as a limited-time event. (Owls tracks this, not us!)
def dyeworks_dyeable?
dyeworks_permanent? || dyeworks_limited?
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. (Owls tracks this last part!) # in the NC Mall, then dyed via Dyeworks. (Owls tracks this last part!)
def dyeworks_buyable? def dyeworks_buyable?
# TODO: Add support for limited-time Dyeworks items. Does Owls offer this dyeworks_base_buyable? && dyeworks_dyeable?
# info too? (At time of writing, there are no active Dyeworks events.)
dyeworks_base_buyable? && dyeworks_permanent?
end end
DYEWORKS_NAME_PATTERN = %r{ DYEWORKS_NAME_PATTERN = %r{

View file

@ -80,6 +80,12 @@
"Dyeworks items are." "Dyeworks items are."
} }
(Permanent) (Permanent)
- elsif item.dyeworks_limited?
%span.dyeworks-timeframe{
title: "This recipe is part of a limited-time Dyeworks " +
"event, and is scheduled to be removed from the NC Mall soon."
}
(Limited-time)
%button{onclick: "alert('Todo!')"} %button{onclick: "alert('Todo!')"}
= cart_icon alt: "" = cart_icon alt: ""