From 26dfe13b0ee1e3646482e9557c91f749147148e4 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 18 Jun 2024 14:59:09 -0700 Subject: [PATCH] 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" --- app/models/item.rb | 17 ++++++++++++++--- app/views/items/sources.html.haml | 6 ++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/models/item.rb b/app/models/item.rb index d426e88a..0e9c174f 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -217,12 +217,23 @@ class Item < ApplicationRecord nc_trade_value.value_text.include?("Permanent Dyeworks") 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 # 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? + dyeworks_base_buyable? && dyeworks_dyeable? end DYEWORKS_NAME_PATTERN = %r{ diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index 8cf9b9be..af526ed4 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -80,6 +80,12 @@ "Dyeworks items are." } (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!')"} = cart_icon alt: ""