All skills
thedivergentai avatar

/godot-economy-system

@9d6e91e

Expert patterns for game economies including currency management (multi-currency, wallet system), shop systems (buy/sell prices, stock limits), dynamic pricing (supply/demand), loot tables (weighted drops, rarity tiers), and economic balance (inflation control, currency sinks). Use for RPGs, trading games, or resource management systems. Trigger keywords: EconomyManager, currency, shop_item, loot_table, dynamic_pricing, buy_sell_spread, currency_sink, inflation, item_rarity.

Use this Skill: https://skilld.dev/gh/thedivergentai/gd-agentic-skills/godot-economy-system

This session only. Nothing lands on disk.

SKILL.md

β‰ˆ125 tokens always: the name and description. β‰ˆ2.9k when used: this file. β‰ˆ1.2k more on demand in 2 files.

Decision Tree: Currency Representation

Economy type Store as Why
Soft currency (gold, scrap) with UI decimals int cents / smallest unit Exact math; display value / 100.0
Premium / idle quantities >> 2^31 BigInt / multi-limb int (or carefully scaled float only if approx OK) 32-bit int caps ~2.1B
Multiplayer / persistent wallet Authoritative int (or BigInt) on server Client never finalizes spends
Prices with fractional display only Still int smallest unit Avoid 0.1 + 0.2 float drift

NEVER mix "use float for money" and "never use float for money" without this tree β€” pick one column and stick to it.

NEVER Do in Economy Systems

  • NEVER skip buy/sell spread β€” Same buy/sell price = infinite money.
  • NEVER skip currency sinks β€” Repairs, taxes, fees, consumables prevent inflation.
  • NEVER validate spends only on the client β€” Server/host is source of truth in multiplayer.
  • NEVER hardcode loot weights in scripts β€” Use Resources (loot_table_weighted.gd).
  • NEVER subtract before current >= amount β€” Underflow / negative wallets corrupt saves.
  • NEVER let UI mutate balances directly β€” UI requests; wallet_manager_singleton.gd / transaction_manager.gd decides.
  • NEVER ignore transaction logs in serious RPGs β€” Audit trail for missing currency.
  • NEVER exceed max caps without clamping β€” Cap before wrap / overflow.

Golden Path (MANDATORY)

  1. currency_resource.gd β€” denomination metadata
  2. wallet_manager_singleton.gd β€” balances + signals
  3. transaction_manager.gd β€” validated spend/grant pipeline
  4. Shop / loot / UI only after wallet+transactions exist

Delete ad-hoc EconomyManager gold tutorials β€” do not re-inline wallet logic in scenes.

Decision Points β†’ Scripts

Task Load Do NOT Load
Balances / Autoload wallet wallet_manager_singleton.gd Inline gold ints on Player
Spend/grant validation transaction_manager.gd UI calling gold -= n
Shop buy/sell + stock shop_item_data.gd + shop_system_logic.gd Equal buy/sell prices
Sales / reputation pricing dynamic_price_modifier.gd β€”
Weighted loot loot_table_weighted.gd Hardcoded % in enemy scripts
Loot β†’ wallet bridge loot_drop_economy_bridge.gd β€”
HUD sync currency_label_sync.gd Polling wallet in _process without signals
Save wallet economy_persistence_handler.gd β€”
Pickup VFX currency_pickup_effect.gd β€”
Multi-item barter trade_contract_resource.gd β€”

Available Scripts (full catalog)

Elite Deltas

MANDATORY for GPM logging, dynamic valuation, and moved shop/loot tutorials: economy-elite-patterns.md. Do NOT Load for wallet + transaction golden path only.

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain β€” do not preload the whole lattice.

Official Documentation

  • Resources β€” Currencies, shop items, loot tables, and trade contracts belong as shareable Resource assets so designers can retune prices and drop weights without code changes.
  • Resource β€” Use duplicate() when applying runtime price modifiers or per-merchant stock so one shop cannot mutate the shared .tres template for every vendor.
  • GDScript exports β€” @export buy/sell spreads, stock caps, currency ids, and loot weights so economy balance stays Inspector-driven.
  • Singletons (Autoload) β€” A WalletManager Autoload is the engine-supported pattern for balances that must survive scene changes (world ↔ shop ↔ menu).
  • Autoloads versus regular nodes β€” Keep global wallet state in Autoload; keep merchant UI and one-off shop logic as scene nodes so tests and multiplayer authority stay composable.
  • Using signals β€” Emit balance_changed / transaction_failed so HUD labels and pickup VFX subscribe without writing wallet balances from the UI.
  • Saving games β€” Persist wallet dictionaries (and stocked shop state) with the rest of progression data; never leave soft currency only in memory.
  • FileAccess β€” Read/write save payloads that include economy blobs; pair with project user:// paths for player-writable balance files.
  • JSON β€” Serialize currency_id β†’ amount dictionaries as JSON-compatible structures for transparent save/load and analytics dumps.
  • Random number generation β€” Weighted loot and drop rolls must use Godot RNG APIs (randf, seeded RNG) rather than ad-hoc modulo hacks.
  • RandomNumberGenerator β€” Seedable RNG instances make loot-table Monte Carlo and deterministic balance tests reproducible.
  • High-level multiplayer β€” Spend/grant validation must be authoritative on the server; clients request transactions and apply confirmed balance RPCs only.

Related Skills

Prerequisites
  • godot-resource-data-patterns β€” Currency, ShopItem, LootTable, and TradeContract definitions are Resource-first; load this before inventing parallel data formats for prices and drops.
  • godot-autoload-architecture β€” WalletManager as Autoload needs disciplined ownership, init order, and namespacing so economy state does not become a god-object dump.
  • godot-signal-architecture β€” Balance and transaction signals must stay β€œsignal up / call down” so UI never mutates the wallet directly.
  • godot-gdscript-mastery β€” Typed Resources, Dictionary wallets, and atomic purchase helpers assume solid GDScript patterns (guards before subtract, no float money).
Complements
  • godot-inventory-system β€” Buy/sell and barter are atomic wallet↔inventory exchanges; stock and capacity checks belong with inventory, not only with price math.
  • godot-save-load-systems β€” Economy persistence handlers should plug into the project save schema (versioning, migrate, encrypt premium balances if needed).
  • godot-rpg-stats β€” Charisma/reputation discounts and sink costs (repairs) need a consistent modifier layer rather than hardcoding multipliers in the shop UI.
  • godot-ui-containers β€” Shop screens and currency HUD layouts should bind to wallet signals; containers own presentation, WalletManager owns truth.
  • godot-quest-system β€” Quest gold rewards and turn-in sinks are major currency sources/sinks; wire rewards through the transaction API, not ad-hoc gold +=.
  • godot-combat-system β€” Loot-drop bridges listen to combat/loot events and grant funds without embedding economy rules inside damage pipelines.
Downstream / consumers
  • godot-monte-carlo-balancer β€” After sinks, loot weights, and shop spreads are Resource-driven, Monte Carlo farm/career sims prove inflation and time-to-afford bands before shipping curves.
  • godot-multiplayer-networking β€” Predicted UI spends and authoritative grant/spend RPCs build on the wallet’s request/validate/apply split.
  • godot-genre-idle-clicker β€” Idle/prestige currencies and sink loops assemble this skill with long-horizon balance and offline accrual genre glue.
  • godot-genre-action-rpg β€” Action-RPG shops, crafting sinks, and drop economies compose wallet + inventory + loot tables for progression pacing.
Master
  • godot-master β€” Library router and mirrored module entry; use when discovering peer skills or syncing shared script mirrors after Domain Skill edits.

Source: SKILL.md on GitHub

1 warning16d4 checks Β· Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides patterns for Godot game economies. It is well-structured and follows development best practices, though it contains logic for processing external save data and log strings which constitutes a potential indirect prompt injection surface.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW Β· No issues

  • Runlayer7mo

    2/3 files flagged

Signed by skilld at 9d6e91e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 weeks ago.

Activeupdated 2 months ago

README badge

README badge for thedivergentai/gd-agentic-skills/godot-economy-system