DyEcon
A lightweight Python library for building dynamic game economies with shared item values, local inventories, and adaptive pricing.
Concepts
DyEcon is built around two classes:
Economy
Stores the global base values for items.
economy = Economy({
wood: 5,
ore: 10,
})
SubEconomy
Stores local inventory quantities and price modifiers.
town = SubEconomy(economy)
merchant = SubEconomy(economy)
Each SubEconomy can have different quantities and prices for the same items.
Quick Start
from dyecon import Economy, SubEconomy
wood = "Wood"
ore = "Ore"
economy = Economy({
wood: 5,
ore: 10,
})
town = SubEconomy(economy)
town.add_item(wood, 50)
town.add_item(ore, 10)
town.change_modifier(wood, -20)
town.change_modifier(ore, 50)
print(town.get_quantity(wood))
print(town.get_value(wood))
print(town.get_quantity(ore))
print(town.get_value(ore))
Output:
50
4
10
15
Economy
Create an Economy
economy = Economy()
Create an Economy with Items
economy = Economy({
wood: 5,
ore: 10,
})
Set Base Value
economy.set_base_value(wood, 5)
Get Base Value
economy.get_base_value(wood)
Get Modified Value
economy.get_value(wood, modifier=25)
SubEconomy
Create a SubEconomy
town = SubEconomy(economy)
Set Quantity
town.set_quantity(wood, 100)
Get Quantity
town.get_quantity(wood)
Add Items
town.add_item(wood, 10)
Remove Items
town.remove_item(wood, 5)
Returns:
True
or
False
if insufficient quantity exists.
Check Inventory
town.has_item(wood, 10)
Returns:
True
or
False
Set Modifier
town.set_modifier(wood, 25)
Change Modifier
town.change_modifier(wood, -5)
Get Modifier
town.get_modifier(wood)
Get Item Value
town.get_value(wood)
This automatically applies the local modifier to the item's global base value.
Iterate Through Inventory
for item, quantity in town.get_items():
print(item, quantity)
Example: Town Economy
from dyecon import Economy, SubEconomy
wood = "Wood"
ore = "Ore"
economy = Economy({
wood: 5,
ore: 10,
})
town = SubEconomy(economy)
town.add_item(wood, 100)
town.add_item(ore, 2)
town.change_modifier(wood, -20)
town.change_modifier(ore, 50)
print(f"Wood Price: {town.get_value(wood)}")
print(f"Ore Price: {town.get_value(ore)}")
Output:
Wood Price: 4
Ore Price: 15
Use Cases
DyEcon can be used for:
- Town economies
- Shops
- Traveling merchants
- Guild inventories
- Trading systems
- Resource management games
- RPG economies
- Simulation games
License
MIT License
Metadata
Release files for dyecon 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dyecon-0.1.0.tar.gz | 3.8 kB | Without provenance | Details for dyecon-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dyecon-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dyecon-0.1.0-py3-none-any.whl |
Total release size: 7.6 kB
Release files / dyecon-0.1.0.tar.gz
| Download URL | dyecon-0.1.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3506407aa02b80f424f5be270ecba6efb6606fb11d3fb86634e47e8d5e485feb
|
|
BLAKE2b-256 checksum How to use checksums |
d430e8034816ca5c013e694cc12eb61f0086bcd1205f8103c8457a06b55bb854
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / dyecon-0.1.0-py3-none-any.whl
| Download URL | dyecon-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9af1ca1dda1bc9eb36fc47b6e0a5988997e256507f5d40eb598091ad248387b
|
|
BLAKE2b-256 checksum How to use checksums |
9eb89d8587e485d2b218d696f2a0337fc420f1cd5b5554952b7c98b8f46b6236
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for dyecon 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.