Skip to content

Add rarity field to items, weapons, and armor #93

Description

@FirebrickRed

Summary:
Add D&D 5e rarity classification to all items, weapons, and armor for proper lore display and future mechanics.

Current State:
Items/weapons/armor have no rarity field. All items appear the same regardless of how rare they should be.

D&D 5e Rarity Tiers:

  • Common - Standard equipment
  • Uncommon - Minor magic items
  • Rare - Significant magic items
  • Very Rare - Powerful magic items
  • Legendary - Artifacts and unique items
  • Artifact - One-of-a-kind legendary items

Proposed Implementation

1. Add Rarity Field to Models

// DndItem.java, DndWeapon.java, DndArmor.java
private String rarity;  // "common", "uncommon", "rare", "very_rare", "legendary"

public String getRarity() {
    return rarity != null ? rarity : "common";  // Default to common
}

2. Update YAML Files

# DMContent/Weapons/weapon.yml
longsword:
  name: "Longsword"
  rarity: common       # Standard equipment
  # ...

flaming_sword:
  name: "Flaming Sword"
  rarity: rare         # Magic item
  # ...

# DMContent/Armor/armor.yml
leather_armor:
  rarity: common

# DMContent/Items/items.yml
healing_potion:
  rarity: common
  
ring_of_invisibility:
  rarity: legendary

3. Color-Code Item Names by Rarity

// In createItemStack()
NamedTextColor nameColor = switch (getRarity()) {
    case "uncommon" -> NamedTextColor.GREEN;
    case "rare" -> NamedTextColor.BLUE;
    case "very_rare" -> NamedTextColor.LIGHT_PURPLE;
    case "legendary" -> NamedTextColor.GOLD;
    default -> NamedTextColor.WHITE;  // common
};

meta.displayName(Component.text(name, nameColor));

4. Add Rarity to Item Lore

if (!"common".equals(rarity)) {
    lore.add(Component.text(capitalize(rarity), getRarityColor())
        .decoration(TextDecoration.ITALIC, true));
}

Example Display:

  • Longsword (white text)
  • Flame Tongue (blue text) "Rare"
  • Vorpal Sword (gold text) "Legendary"

Migration Plan

Phase 1: Add Field to Models (Backward Compatible)

  • Add rarity field to DndItem, DndWeapon, DndArmor
  • Default to "common" if not specified
  • No YAML changes required yet

Phase 2: Update Color Coding

  • Implement rarity-based colors in createItemStack()
  • Add rarity to item lore

Phase 3: Update YAMLs (Gradual)

  • Mark magic items as uncommon/rare/legendary
  • Standard equipment stays common (or omit field)

Future Use Cases

Shop System (Issue #75)

  • Rare items cost more or have limited stock
  • Magic shops only sell uncommon+ items

Loot Tables

  • Roll rarity tier before selecting item
  • "You find a rare magic item!"

Identification System (Future)

  • Unidentified magic items show "???" until identified
  • Rarity hints at power level

Crafting (Future)

  • Rare materials needed for rare items

Examples

Common Items (No Rarity Shown)

longsword:
  rarity: common  # or omit field
  # Display: "Longsword" (white)

Magic Items (Show Rarity)

flame_tongue:
  name: "Flame Tongue"
  rarity: rare
  # Display: "Flame Tongue" (blue)
  # Lore: "Rare" (italic, blue)

vorpal_sword:
  name: "Vorpal Sword"
  rarity: legendary
  # Display: "Vorpal Sword" (gold)
  # Lore: "Legendary" (italic, gold)

Testing

  • Create rare item → verify blue name
  • Create legendary item → verify gold name
  • Omit rarity field → verify defaults to common (white)
  • Check lore shows rarity for non-common items

Related: #75 (Shop System), future loot/crafting systems

Metadata

Metadata

Assignees

No one assigned

    Labels

    equipmentItems, inventory, weapons, armor

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions