$npx -y skills add thedivergentai/GD-Agentic-Skills --skill godot-economy-systemExpert 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). U
| 1 | ## Godot 4.7 Baseline |
| 2 | |
| 3 | - Expert patterns in this skill target **Godot 4.7+** (stable, 2026-06-18). |
| 4 | - Consult the [Godot 4.7 migration guide](https://docs.godotengine.org/en/4.7/tutorials/migrating/upgrading_to_godot_4.7.html) when upgrading projects from 4.6. |
| 5 | - **NEVER** assume 4.6 defaults (stretch mode, audio area_mask, RichTextLabel percent flags) without checking 4.7 migration notes. |
| 6 | |
| 7 | # Economy System |
| 8 | |
| 9 | Expert guidance for designing balanced game economies with currency, shops, and loot. |
| 10 | |
| 11 | ## Available Scripts |
| 12 | |
| 13 | ### [currency_resource.gd](scripts/currency_resource.gd) |
| 14 | Specialized data container for defining distinct denominations (Gold, Gems, XP) with UI metadata. |
| 15 | |
| 16 | ### [wallet_manager_singleton.gd](scripts/wallet_manager_singleton.gd) |
| 17 | Centralized AutoLoad orchestrator for managing balances and processing secure transactions. |
| 18 | |
| 19 | ### [shop_item_data.gd](scripts/shop_item_data.gd) |
| 20 | Resource-based definition for purchasables, including pricing, currency types, and stock limits. |
| 21 | |
| 22 | ### [shop_system_logic.gd](scripts/shop_system_logic.gd) |
| 23 | Decoupled logic for handling buy/sell exchanges between the Wallet and Inventory systems. |
| 24 | |
| 25 | ### [dynamic_price_modifier.gd](scripts/dynamic_price_modifier.gd) |
| 26 | Injection pattern for applying temporary discounts or markups based on world state (e.g. Sales). |
| 27 | |
| 28 | ### [currency_label_sync.gd](scripts/currency_label_sync.gd) |
| 29 | Reactive UI hook for automatically updating currency displays when balances change. |
| 30 | |
| 31 | ### [loot_drop_economy_bridge.gd](scripts/loot_drop_economy_bridge.gd) |
| 32 | Bridge node for capturing loot events and adding funds to the player's wallet. |
| 33 | |
| 34 | ### [economy_persistence_handler.gd](scripts/economy_persistence_handler.gd) |
| 35 | Expert logic for serializing financial states into secure, loadable dictionaries. |
| 36 | |
| 37 | ### [currency_pickup_effect.gd](scripts/currency_pickup_effect.gd) |
| 38 | Visual feedback controller that triggers particles or animations upon financial gain. |
| 39 | |
| 40 | ### [trade_contract_resource.gd](scripts/trade_contract_resource.gd) |
| 41 | Advanced barter system definition for multi-item "Quid Pro Quo" transactions. |
| 42 | |
| 43 | ## NEVER Do in Economy Systems |
| 44 | |
| 45 | - **NEVER use `int` for large-scale premium economies** — Standard 32-bit integers cap at 2.1 billion. For massive quantities, use `float` or a custom `BigInt` structure [12]. |
| 46 | - **NEVER forget to implement a Buy/Sell price spread** — Allowing players to sell items for the same price they bought them creates infinite money exploits [13]. |
| 47 | - **NEVER skip "Currency Sinks"** — Without mandatory costs (repairs, taxes, consumables), the game economy will suffer from hyper-inflation [14]. |
| 48 | - **NEVER perform currency validation only on the client** — In multiplayer or persistent games, the server MUST be the source of truth for all financial transactions [15]. |
| 49 | - **NEVER hardcode loot drop percentages inside scripts** — Changing drop rates should not require a recompile. Use Resources or outside data files for easy balancing [16]. |
| 50 | - **NEVER allow negative balances via underflow** — Always check `if current >= amount` BEFORE subtracting. Negative gold can break logic and save files. |
| 51 | - **NEVER modify the wallet balance directly from the UI** — The UI should only request a transaction. The `WalletManager` should decide if it's valid and update the state. |
| 52 | - **NEVER use floating point math for exact currency counts** — `0.1 + 0.2` might equal `0.30000000000000004`, leading to discrepancies. Use `int` for cents/smallest units. |
| 53 | - **NEVER ignore "Transaction Logs" in serious RPGs** — If money disappears, you need a history of events to debug whether it was a bug or a legitimate game event. |
| 54 | - **NEVER give rewards without checking "Max Limit"** — If a player is capped at 999,999 gold, adding 1,000 should result in 999,999, not a wrapped negative number. |
| 55 | |
| 56 | --- |
| 57 | |
| 58 | ## Currency Manager |
| 59 | |
| 60 | ```gdscript |
| 61 | # economy_manager.gd (AutoLoad) |
| 62 | extends Node |
| 63 | |
| 64 | signal currency_changed(old_amount: int, new_amount: int) |
| 65 | |
| 66 | var gold: int = 0 |
| 67 | |
| 68 | func add_currency(amount: int) -> void: |
| 69 | var old := gold |
| 70 | gold += amount |
| 71 | currency_changed.emit(old, gold) |
| 72 | |
| 73 | func spend_currency(amount: int) -> bool: |
| 74 | if gold < amount: |
| 75 | return false |
| 76 | |
| 77 | var old := gold |
| 78 | gold -= amount |
| 79 | currency_changed.emit(old, gold) |
| 80 | return true |
| 81 | |
| 82 | func has_currency(amount: int) -> bool: |
| 83 | return gold >= amount |
| 84 | ``` |
| 85 | |
| 86 | ## Shop System |
| 87 | |
| 88 | ```gdscript |
| 89 | # shop_item.gd |
| 90 | class_name ShopItem |
| 91 | extends Resource |
| 92 | |
| 93 | @export var item: Item |
| 94 | @export var buy_price: int |
| 95 | @export var sell_price: int |
| 96 | @export var stock: int |