Metadata-Version: 2.4
Name: dyecon
Version: 0.1.0
Summary: A lightweight Python library for building dynamic game economies with shared item values, local inventories, and adaptive pricing.
Author: Brianna Ladson
License: MIT
Keywords: python,economy,game-development,simulation,inventory,pricing
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Games/Entertainment
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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.

```python
economy = Economy({
	wood: 5,
	ore: 10,
})
```

### SubEconomy

Stores local inventory quantities and price modifiers.

```python
town = SubEconomy(economy)
merchant = SubEconomy(economy)
```

Each SubEconomy can have different quantities and prices for the same items.

---

## Quick Start

```python
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:

```python
50
4

10
15
```

---

## Economy

### Create an Economy

```python
economy = Economy()
```

### Create an Economy with Items

```python
economy = Economy({
	wood: 5,
	ore: 10,
})
```

### Set Base Value

```python
economy.set_base_value(wood, 5)
```

### Get Base Value

```python
economy.get_base_value(wood)
```

### Get Modified Value

```python
economy.get_value(wood, modifier=25)
```

---

## SubEconomy

### Create a SubEconomy

```python
town = SubEconomy(economy)
```

### Set Quantity

```python
town.set_quantity(wood, 100)
```

### Get Quantity

```python
town.get_quantity(wood)
```

### Add Items

```python
town.add_item(wood, 10)
```

### Remove Items

```python
town.remove_item(wood, 5)
```

Returns:

```python
True
```

or

```python
False
```

if insufficient quantity exists.

### Check Inventory

```python
town.has_item(wood, 10)
```

Returns:

```python
True
```

or

```python
False
```

### Set Modifier

```python
town.set_modifier(wood, 25)
```

### Change Modifier

```python
town.change_modifier(wood, -5)
```

### Get Modifier

```python
town.get_modifier(wood)
```

### Get Item Value

```python
town.get_value(wood)
```

This automatically applies the local modifier to the item's global base value.

### Iterate Through Inventory

```python
for item, quantity in town.get_items():
	print(item, quantity)
```

---

## Example: Town Economy

```python
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:

```python
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
