Page MenuHomePhabricator

Allow Badges to be ordered by quality
Closed, ResolvedPublic

Assigned To
Authored By
chad
Jul 29 2015, 10:44 PM
Referenced Files
F1199116: tumblr_niihiwuOYG1sycx5ho1_400.gif
Apr 1 2016, 2:14 AM
F1198990: pasted_file
Apr 1 2016, 12:43 AM
F1198988: char_rarity.png
Apr 1 2016, 12:43 AM
Tokens
"Manufacturing Defect?" token, awarded by cburroughs.

Description

We should be able to sort a stack of Badges by highest quality -> shoddiest.

Event Timeline

chad raised the priority of this task from to Needs Triage.
chad updated the task description. (Show Details)
chad added a project: Badges.
chad moved this task to v1 on the Badges board.
chad added a subscriber: chad.
epriestley added a subscriber: epriestley.

It's currently impossible to sort badges by rarity because they rarities are internally 'grey', 'white', 'green', etc., and there is no natural order to these. For example, MySQL has no idea what order 'indigo', 'orange' and 'yellow' should go in, except alphabetical, which is not actually the correct order.

I think the cleanest fix here is:

  • Replace rarity constants (like grey, white, ...) with quality codes (like 10, 20, ...).
  • Replace the quality string column (currently text255) with a uint32 column so MySQL can sort it.
  • Add sort options to the UI.

Leaving some room between quality levels will give us more flexibility in the future if we want to add new quality levels or make them user-customizable.


Reasonable approach might be:

Extract the badge quality constants, names, etc., into a new PhabricatorBadgesQuality class or similar. You can look at HarbormasterUnitStatus for a reasonable sort of example of what this might look like.

The actual qualities should probably be defined somewhere as:

return array(
  10 => array(
    'color' => 'grey',
    'name' => pht('Poor'),
  ),
  20 => array(
    'color' => 'white',
    'name' => pht('Common'),
  ),
  ...

This will make it easy to extract them into some badges.quality-options config down the road if we want. I don't currently really anticipate doing this, but there are no drawbacks to preparing for the possibility.

Then migrate all the existing qualities:

UPDATE badge SET quality = 10 WHERE quality = 'grey';

And then change the column type to uint32 / INT UNSIGNED NOT NULL.

To make this sortable in the UI, modify PhabricatorBadgesQuery and implement getBuiltinOrders(), getOrderableColumns() and getPagingValueMap(). You can look at existing implementations of these for examples. The ordering option should automatically appear in the UI (and work properly) once these are implemented.

epriestley edited projects, added Badges (v0); removed Badges.

Did I get the colors wrong? I thought I copied them as they were...

It was mostly a comment that the title of this task was "Allow Badges to be ordered by Rarity" as in Rarity from My Little Pony and not just rarity.

I guess I am the only one with elite Pony knowledge here.

Haha. Yes, well, you claim in another file that it was WoW colors. Get your story straight, @chad !

FUN POLICE HERE

siren

TOO MUCH FUN DETECTED

siren

THE TECHNICAL TERM FOR THIS PROPERTY IS "QUALITY"

siren

epriestley renamed this task from Allow Badges to be ordered by Rarity to Allow Badges to be ordered by quality.Apr 1 2016, 1:15 PM
epriestley updated the task description. (Show Details)

Wait are they not Blizzard colors any more? My team can't handle using different colors from WoW and Diablo III and will find this feature too confusing if they have to learn about ponies too. Phabricator is ruined forever.

Too many deck slots, product literally unplayable.