Compare commits

..

2 commits

Author SHA1 Message Date
f87f4e61b3 Add extra support info to Rainbow Pool pet types
Easy-to-notice hints for which pet types need more labeling!
2024-10-04 19:24:40 -07:00
dfca88bed3 Oops, use the Rainbow Pool list styles under "Other" show/hide 2024-10-04 18:46:53 -07:00
7 changed files with 55 additions and 5 deletions

View file

@ -55,6 +55,9 @@
position: relative
z-index: 1
.info
font-size: .85em
.rainbow-pool-pagination
margin-block: .5em
display: flex

View file

@ -13,7 +13,7 @@ class PetTypesController < ApplicationController
end
@pet_types = PetType.
includes(:color, :species).
includes(:color, :species, :pet_states).
order(created_at: :desc).
paginate(page: params[:page], per_page: 30)
@ -59,11 +59,12 @@ class PetTypesController < ApplicationController
#
# If no main poses are available, then we just make all the poses
# "canonical", and show the whole mish-mash!
MAIN_POSES = %w(HAPPY_FEM HAPPY_MASC SAD_FEM SAD_MASC SICK_FEM SICK_MASC)
def group_pet_states(pet_states)
pose_groups = pet_states.emotion_order.group_by(&:pose)
main_groups = pose_groups.select { |k| MAIN_POSES.include?(k) }.values
other_groups = pose_groups.reject { |k| MAIN_POSES.include?(k) }.values
main_groups =
pose_groups.select { |k| PetState::MAIN_POSES.include?(k) }.values
other_groups =
pose_groups.reject { |k| PetState::MAIN_POSES.include?(k) }.values
if main_groups.empty?
return {canonical: other_groups.flatten(1).sort_by(&:pose), other: []}

View file

@ -0,0 +1,16 @@
module PetTypesHelper
def moon_progress(num, total)
nearest_quarter = (4.0 * num / total).round / 4.0
if nearest_quarter >= 1
"🌕️"
elsif nearest_quarter >= 0.75
"🌔"
elsif nearest_quarter >= 0.5
"🌓"
elsif nearest_quarter >= 0.25
"🌒"
else
"🌑"
end
end
end

View file

@ -1,6 +1,8 @@
class PetState < ApplicationRecord
SwfAssetType = 'biology'
MAIN_POSES = %w(HAPPY_FEM HAPPY_MASC SAD_FEM SAD_MASC SICK_FEM SICK_MASC)
has_many :contributions, :as => :contributed,
:inverse_of => :contributed # in case of duplicates being merged
has_many :outfits

View file

@ -116,6 +116,23 @@ class PetType < ApplicationRecord
"#{color.human_name}-#{species.human_name}"
end
def fully_labeled?
num_missing_poses == 0
end
def num_poses
all_poses = pet_states.map(&:pose)
PetState::MAIN_POSES.count { |pose| all_poses.include? pose }
end
def num_missing_poses
PetState::MAIN_POSES.count - num_poses
end
def num_unlabeled_states
pet_states.count { |ps| ps.pose == "UNKNOWN" }
end
def self.basic_body_ids
PetType.basic.distinct.pluck(:body_id)
end

View file

@ -2,3 +2,14 @@
= link_to pet_type do
= pet_type_image pet_type, :happy, :thumb, class: "preview"
.name= pet_type.human_name
- if support_staff?
.info
- if pet_type.num_unlabeled_states > 0
%span{title: "Unlabeled states"}
❓️ #{pet_type.num_unlabeled_states} +
%span{title: "Labeled main poses"}
- if pet_type.fully_labeled?
✅ #{pet_type.num_poses}/#{pet_type.num_poses}
- else
= moon_progress pet_type.num_poses, pet_type.num_poses + pet_type.num_missing_poses
#{pet_type.num_poses}/#{pet_type.num_poses + pet_type.num_missing_poses}

View file

@ -19,7 +19,7 @@
- if @pet_states[:other].present?
%details
%summary Other
%ul.pet-states
%ul.rainbow-pool-list
= render @pet_states[:other]
- content_for :stylesheets do