Skip to content

feat: add player titles and cosmetic unlocks (#463) - #494

Merged
Mkalbani merged 2 commits into
MindFlowInteractive:mainfrom
AwesomeuncleB:feat/463-player-titles-cosmetics
Nov 20, 2026
Merged

Mkalbani merged 2 commits into
MindFlowInteractive:mainfrom
AwesomeuncleB:feat/463-player-titles-cosmetics

Conversation

@AwesomeuncleB

Copy link
Copy Markdown
Contributor

Closes #463

What does this PR do?

Adds player titles and cosmetic items that unlock at milestones. Players can equip the ones they own, and profiles can show the equipped title.

Why?

Closes #463

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing behavior to change)
  • Refactor (no behavior change)
  • Docs / CI / tooling

How was it tested?

  • Unit tests added/updated
  • E2E test added/updated
  • Manual verification steps below

npx jest src/cosmetics: 33 tests pass.

What's included

New module src/cosmetics/:

  • Catalog (cosmetic_items): titles, avatar frames, name colours and profile badges. Each item has an unlock condition: level, total_xp, puzzles_solved, streak_days, achievement or manual. Conditions are validated when items are created or updated.
  • Unlocks (player_cosmetic_unlocks, unique per player and item): evaluateUnlocks grants every item whose milestone is now reached and skips items the player already owns. If two requests insert the same unlock at once, the duplicate is ignored safely.
  • Automatic unlocks on level-up: listens to the existing player.level_up event, so level and XP titles unlock with no extra wiring.
  • Equip / unequip (player_equipped_cosmetics, one slot per type): ownership is checked before equipping, and equipping replaces whatever was in that slot.
  • Profile display: returns the equipped title plus the other equipped items. Disabled items are hidden.
Method Path Access
GET /cosmetics?type=title Public catalog
GET /cosmetics/profile/:userId Public: equipped title and items for a profile
GET /cosmetics/me Player: owned items with equipped flags
POST /cosmetics/me/equip Player: equip an owned item
DELETE /cosmetics/me/equip/:slot Player: clear a slot
POST /cosmetics Admin: create
PATCH /cosmetics/:cosmeticId Admin: update
POST /cosmetics/:cosmeticId/grant Admin: give an item
POST /cosmetics/evaluate Admin/service: check milestones for a player

Checklist

  • npm run lint passes for the new files
  • npm run format:check passes
  • npm run typecheck: no new errors (main already has 149 existing errors; this PR adds none)
  • npm test passes for the new suite
  • I added/updated tests for the change
  • I updated relevant docs (README, JSDoc, comments)
  • I added a changeset / migration if schema changed
  • I read CONTRIBUTING.md

Risk & rollout

Additive only: new tables and new routes. The only change to existing code is registering the module in AppModule. Other milestone sources (puzzles solved, streaks, achievements) can call CosmeticsService.evaluateUnlocks or the admin endpoint. Production needs a migration for the new tables.

Closes #463

- Add CosmeticItem catalog entity covering titles, avatar frames,
  name colours and profile badges, each with a JSON unlock condition
  (level, total XP, puzzles solved, streak days, achievement, manual)
- Add PlayerCosmeticUnlock (unique per player and item) for ownership
- Add PlayerEquippedCosmetic with one slot per cosmetic type
- CosmeticsService:
  - catalog create/update with condition validation
  - evaluateUnlocks grants every newly met milestone, skips owned
    items and tolerates concurrent duplicate inserts
  - listens to player.level_up so level/XP titles unlock automatically
  - idempotent manual grants
  - equip/unequip with ownership check before equip
  - profile display data with the equipped title and items
- CosmeticsController: public catalog and profile display, JWT player
  routes for owned items and equip/unequip, admin-only catalog edits,
  grants and milestone evaluation
- Register CosmeticsModule in AppModule
- 33 unit tests

Closes MindFlowInteractive#463
@drips-wave

drips-wave Bot commented Nov 19, 2026

Copy link
Copy Markdown

@AwesomeuncleB Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Mkalbani

Copy link
Copy Markdown
Contributor

@AwesomeuncleB please resolve conflict

@Mkalbani
Mkalbani merged commit 6845a7a into MindFlowInteractive:main Nov 20, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Player Titles and Cosmetic Unlocks

2 participants