Add logic to infer the base for Dyeworks items
This works for most of the current 1,094 Dyeworks items! But there are a few exceptions, for cases where the base item name is not quite the same (e.g. the Dyeworks version is more concise). Maybe we'll add a database field to override this? - Dyeworks Baby Blue: Baby Valentine Jumper - Dyeworks Baby Pink: Baby Valentine Jumper - Dyeworks Black: Field of Flowers - Dyeworks Black: Games Master Challenge 2010 Lulu Shirt - Dyeworks Blue: Field of Flowers - Dyeworks Blue: Stars and Glitter Facepaint - Dyeworks Brown: Hanging Winter Candles Garland - Dyeworks Green: Stars and Glitter Facepaint - Dyeworks Magenta: Lovely Berry Blush - Dyeworks Orange & Pink: Winter Lights Effects - Dyeworks Orange: Games Master Challenge 2010 Lulu Shirt - Dyeworks Peach: Lovely Berry Blush - Dyeworks Purple: Baby Valentine Jumper - Dyeworks Purple: Games Master Challenge 2010 Lulu Shirt - Dyeworks Purple: Hanging Winter Candles Garland - Dyeworks Purple: Stars and Glitter Facepaint - Dyeworks Red & Green: Winter Lights Effects - Dyeworks Silver: Hanging Winter Candles Garland - Dyeworks Soft Pink: Lovely Berry Blush - Dyeworks Yellow & Magenta: Winter Lights Effects - Dyeworks Yellow: Field of Flowers
This commit is contained in:
parent
341869fb17
commit
68cb44d159
1 changed files with 20 additions and 0 deletions
|
@ -195,6 +195,26 @@ class Item < ApplicationRecord
|
|||
nc_mall_record.present?
|
||||
end
|
||||
|
||||
def dyeworks?
|
||||
dyeworks_base_item.present?
|
||||
end
|
||||
|
||||
DYEWORKS_NAME_PATTERN = %r{
|
||||
^(
|
||||
# Most Dyeworks items have a colon in the name.
|
||||
Dyeworks\s+(?<color>.+?:)\s*(?<base>.+)
|
||||
|
|
||||
# But sometimes they omit it. If so, assume the first word is the color!
|
||||
Dyeworks\s+(?<color>\S+)\s*(?<base>.+)
|
||||
)$
|
||||
}x
|
||||
def dyeworks_base_item
|
||||
name_match = name.match(DYEWORKS_NAME_PATTERN)
|
||||
return nil if name_match.nil?
|
||||
|
||||
Item.find_by_name(name_match["base"])
|
||||
end
|
||||
|
||||
def owned?
|
||||
@owned || false
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue