From d470dde1351428494e2bf7a6fd6147028c9329b5 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sat, 7 Sep 2024 16:12:05 -0700 Subject: [PATCH] Default to masc/fem for colors like "elderlyboy", in item previews instead of doing the random choice we do for most colors. This is especially noticeable in cases where like, I'm looking at the Elderlyboy Ogrin and like, it has *work* put into the masc eyes, and them fem eyes are just the standard ones. --- app/models/color.rb | 10 ++++++++++ app/models/pet_type.rb | 8 +++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/color.rb b/app/models/color.rb index e0c1aa70..8872fc44 100644 --- a/app/models/color.rb +++ b/app/models/color.rb @@ -35,6 +35,16 @@ class Color < ApplicationRecord end end + def default_gender_presentation + if name.downcase.ends_with? "boy" + :masc + elsif name.downcase.ends_with? "girl" + :fem + else + nil + end + end + def self.pranks_funny? now = Time.now.in_time_zone('Pacific Time (US & Canada)') now.month == 4 && now.day == 1 diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index beba90d9..96c31818 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -107,9 +107,11 @@ class PetType < ApplicationRecord def canonical_pet_state # For consistency (randomness is always scary!), we use the PetType ID to - # determine which gender to prefer. That way, it'll be stable, but we'll - # still get the *vibes* of uniform randomness. - preferred_gender = id % 2 == 0 ? :fem : :masc + # determine which gender to prefer, if it's not built into the color. That + # way, it'll be stable, but we'll still get the *vibes* of randomness. + preferred_gender = color.default_gender_presentation || + (id % 2 == 0 ? :fem : :masc) + puts preferred_gender # NOTE: If this were only being called on one pet type at a time, it would # be more efficient to send this as a single query with an `order` part and