Skip to content

Configurable Economy System (Currency & Conversion Rates) #92

Description

@FirebrickRed

Summary:
Create a configurable economy system allowing DMs to customize currency types, conversion rates, and economic behavior per campaign.

Phase: 3 - Advanced Features
Systems: Economy, Configuration

Prerequisites:


Motivation

Different campaigns need different economic models:

  • Gritty/Low Magic: Rare gold (1 gold = 100 silver)
  • High Magic: Inflated economy (1 gold = 5 silver)
  • Homebrew: Custom currencies (Dragon Scales, Astral Shards)
  • Historical: Electrum-based economy

Currently, conversion rates are hardcoded (1 gold = 10 silver = 100 copper).

Proposed Configuration File

# DMContent/Config/economy.yml
economy:
  # Define all available currencies
  currencies:
    copper:
      name: "Copper Piece"
      abbreviation: "CP"
      plural: "Copper Pieces"
      base_value: 1              # All values relative to base unit
      item_id: copper_piece      # References DMContent/Items/copper_piece.yml
      
    silver:
      name: "Silver Piece"
      abbreviation: "SP"
      plural: "Silver Pieces"
      base_value: 10             # 1 silver = 10 copper
      item_id: silver_piece
      
    electrum:
      name: "Electrum Piece"
      abbreviation: "EP"
      plural: "Electrum Pieces"
      base_value: 50
      item_id: electrum_piece
      enabled: false             # Optional: Disable electrum in campaign
      
    gold:
      name: "Gold Piece"
      abbreviation: "GP"
      plural: "Gold Pieces"
      base_value: 100            # 1 gold = 100 copper = 10 silver
      item_id: gold_piece
      
    platinum:
      name: "Platinum Piece"
      abbreviation: "PP"
      plural: "Platinum Pieces"
      base_value: 1000           # 1 platinum = 10 gold
      item_id: platinum_piece
      
    # Homebrew example
    dragon_scale:
      name: "Dragon Scale"
      abbreviation: "DS"
      plural: "Dragon Scales"
      base_value: 5000           # Very valuable
      item_id: dragon_scale
      enabled: true

  # Conversion behavior
  conversion:
    enabled: true                     # Allow multi-currency payment (Issue #91)
    auto_convert_inventory: false     # Don't auto-stack coins in player inventory
    show_multiple_recipes: true       # Show items in all currencies in shops
    
  # Default starting money (overridden by backgrounds)
  starting_money:
    gold: 0
    silver: 0
    copper: 0

DM Customization Examples

Gritty Campaign (Rare Gold)

currencies:
  silver:
    base_value: 1        # Silver is base unit
  gold:
    base_value: 100      # 1 gold = 100 silver (not 10)

High Magic Economy (Inflated)

currencies:
  copper:
    base_value: 1
  silver:
    base_value: 5        # 1 silver = 5 copper (not 10)
  gold:
    base_value: 25       # 1 gold = 25 copper (not 100)

Homebrew Currency Only

currencies:
  copper:
    enabled: false
  silver:
    enabled: false
  gold:
    enabled: false
  platinum:
    enabled: false
  astral_shard:
    name: "Astral Shard"
    base_value: 1
    item_id: astral_shard

Implementation

EconomyConfig.java

public class EconomyConfig {
    private Map<String, CurrencyDefinition> currencies;
    private ConversionSettings conversion;
    private StartingMoney startingMoney;
    
    public static EconomyConfig load() {
        // Load from DMContent/Config/economy.yml
        // Fallback to defaults if file missing
    }
}

CurrencyDefinition.java

public class CurrencyDefinition {
    private String id;              // "gold", "silver", "dragon_scale"
    private String name;            // "Gold Piece"
    private String abbreviation;    // "GP"
    private String plural;          // "Gold Pieces"
    private int baseValue;          // Relative to base unit
    private String itemId;          // References DMContent/Items/
    private boolean enabled;        // Can disable currencies
}

Integration Points

Issue #75 (Shop System)

  • Shops reference currency types from config
  • Validate currency exists in economy.yml

Issue #91 (Multi-Currency Payment)

  • Use conversion.enabled setting
  • Use configured base_value for conversions

Backgrounds (Issue #17)

  • Use starting_money as fallback if background doesn't specify

Future: Banking System

  • Track wealth in base currency units
  • Convert for display

Default Behavior (No Config File)

If economy.yml doesn't exist, use D&D 5e defaults:

  • 1 platinum = 10 gold
  • 1 gold = 10 silver
  • 1 silver = 10 copper
  • Electrum = 5 silver (optional)

Testing

  • Change conversion rate → verify shop prices recalculate
  • Disable gold → verify shops only show other currencies
  • Add custom currency → verify it appears in shops
  • Delete economy.yml → verify defaults work

Related: #75 (Shop System), #91 (Multi-Currency Payment), #35 (YAML Configs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    configshop-systemShop, merchant, and economy features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions