Compare commits
No commits in common. "5f2c45442398e22dff95ed5d88b9f75e4b19b36d" and "d470dde1351428494e2bf7a6fd6147028c9329b5" have entirely different histories.
5f2c454423
...
d470dde135
1 changed files with 2 additions and 6 deletions
|
@ -111,6 +111,7 @@ class PetType < ApplicationRecord
|
||||||
# way, it'll be stable, but we'll still get the *vibes* of randomness.
|
# way, it'll be stable, but we'll still get the *vibes* of randomness.
|
||||||
preferred_gender = color.default_gender_presentation ||
|
preferred_gender = color.default_gender_presentation ||
|
||||||
(id % 2 == 0 ? :fem : :masc)
|
(id % 2 == 0 ? :fem : :masc)
|
||||||
|
puts preferred_gender
|
||||||
|
|
||||||
# NOTE: If this were only being called on one pet type at a time, it would
|
# 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
|
# be more efficient to send this as a single query with an `order` part and
|
||||||
|
@ -122,15 +123,10 @@ class PetType < ApplicationRecord
|
||||||
pet_states.sort_by { |pet_state|
|
pet_states.sort_by { |pet_state|
|
||||||
gender = pet_state.female? ? :fem : :masc
|
gender = pet_state.female? ? :fem : :masc
|
||||||
[
|
[
|
||||||
# We prefer labeled pet states first, because states no one has seen or
|
|
||||||
# validated are such a wildcard! Then we prefer unglitched, then we
|
|
||||||
# prefer maximally happy. (Correct sad is better than glitched happy!)
|
|
||||||
# Then we pick our arbitrary-ish gender, then we pick the latest if all
|
|
||||||
# else failed and it's an unlabeled free-for-all.
|
|
||||||
pet_state.mood_id.present? ? -1 : 1, # Prefer mood is labeled
|
pet_state.mood_id.present? ? -1 : 1, # Prefer mood is labeled
|
||||||
!pet_state.glitched? ? -1 : 1, # Prefer is not glitched
|
|
||||||
pet_state.mood_id, # Prefer mood is happy, then sad, then sick
|
pet_state.mood_id, # Prefer mood is happy, then sad, then sick
|
||||||
gender == preferred_gender ? -1 : 1, # Prefer our "random" gender
|
gender == preferred_gender ? -1 : 1, # Prefer our "random" gender
|
||||||
|
!pet_state.glitched? ? -1 : 1, # Prefer is not glitched
|
||||||
-pet_state.id, # Prefer newer pet states
|
-pet_state.id, # Prefer newer pet states
|
||||||
]
|
]
|
||||||
}.first
|
}.first
|
||||||
|
|
Loading…
Reference in a new issue