# Shop & Marketplace System

## Overview
Advenexus has three distinct shopping systems: the **Weapon/Item Shop** (bot-run), the **Animal Shop** (bot-run for Gods tier), and the **Player Marketplace** (peer-to-peer trading). Additionally, there's a **Gem Shop** and **Profile Shop**. The marketplace requires players to switch to "seller mode" and operates exclusively in the #sellers channel.

---

## Commands

### Bot Shops
| Command | Description |
|---|---|
| `.shop [page]` | Browse weapon shop (paginated, 10 per page) |
| `.buy <weaponID>` | Buy a weapon by type ID |
| `.buy lootbox` | Buy a lootbox (2,000 🪙) |
| `.buy crate` | Buy a weapon crate (3,000 🪙) |
| `.buy guard dog` | Buy a guard dog (150 🪙) |
| `.buy diamond` | Buy a Sacrificial Diamond (50,000 🪙) |
| `.animal shop` | Browse buyable animals |
| `.animal buy <name>` / `.buy <name>` | Buy an animal |
| `.gem` | View your gems and equipped slots |
| `.gem equip <gemID>` | Equip a gem to a slot |
| `.gem unequip <hunt\|lucky\|stone>` | Unequip and consume a gem |

### Player Marketplace
| Command | Description |
|---|---|
| `.mode` | Check current mode |
| `.mode seller` | Switch to seller mode (5-min cooldown) |
| `.mode adventure` | Switch back to adventure mode |
| `.market` | View all active marketplace listings |
| `.market animals/weapons/enchantments/stones` | Filter listings by type |
| `.market mine` | View your own listings |
| `.player sell <item> <price>` | List an item for sale (seller mode required) |
| `.item buy <listingID>` | Buy a marketplace listing |
| `.market cancel <listingID>` | Cancel your listing |

---

## Weapon Shop

Sells all 24 weapons across 8 types and 3 tiers.

### Prices by Tier

| Tier | Price Range |
|---|---|
| Mythic | 15,000–18,000 🪙 |
| Legendary | 45,000–50,000 🪙 |
| Fabled | 100,000–120,000 🪙 |

See [battle.md](battle.md) for the full weapon type breakdown.

---

## Item Shop

| Item | Price | Description |
|---|---|---|
| Lootbox | 2,000 🪙 | Random animal (rare–fabled) |
| Weapon Crate | 3,000 🪙 | Enchantment (60%), diamond (18%), nothing (15%), legendary weapon (7%) |
| Guard Dog | 150 🪙 | 90% chance to block steals |
| Sacrificial Diamond | 50,000 🪙 | Used in `.craft` for guaranteed max stats |

---

## Animal Shop

- Only **Gods tier** animals available for direct purchase
- Price: **5,000,000 🪙** (from RARITY_CONFIG)
- Only base forms (no evolved forms)
- Purchased at level 1, stage 0

---

## Gem System

### Gem Types

| ID | Name | Category | Tier | Charges | Effect |
|---|---|---|---|---|---|
| HGC | Green Hunting Gem | Hunt | Common | 10 | ×2 animals per hunt |
| HGR | Yellow Hunting Gem | Hunt | Rare | 25 | ×2 animals per hunt |
| HGM | Red Hunting Gem | Hunt | Mythic | 50 | ×2 animals per hunt |
| LGC | Green Lucky Gem | Lucky | Common | 10 | +1% fabled tier chance |
| LGR | Yellow Lucky Gem | Lucky | Rare | 15 | +1.2% fabled tier chance |
| LGM | Red Lucky Gem | Lucky | Mythic | 20 | +1.5% fabled tier chance |
| GST | Gemstone | Stone | Unique | 20 | +3 animals per hunt |

### Gem Slots
- **3 gem slots** maximum (one per category: hunt, lucky, stone)
- Equipping removes the gem from inventory and places it in the slot
- **Unequipping consumes the gem** — it is destroyed, not returned
- Charges deplete with use during hunts

### Gem Drop Table (from hunting)

| Gem | Drop Weight |
|---|---|
| HGC (Green Hunting) | 24 |
| HGR (Yellow Hunting) | 8 |
| HGM (Red Hunting) | 1 |
| LGC (Green Lucky) | 24 |
| LGR (Yellow Lucky) | 8 |
| LGM (Red Lucky) | 1 |
| GST (Gemstone) | 20 |

---

## Player Marketplace

The peer-to-peer trading system. Players must be in **seller mode** to list items.

### Mode System
- **Adventure mode** (default) — cannot sell, can still buy
- **Seller mode** — enables listing items for sale
- **5-minute cooldown** between mode switches
- Marketplace only works in the **#sellers** channel

### Listing Items

**Command:** `.player sell <item name> <price>`

**Listing fee:** 2% of the sale price (deducted from seller's coins upfront)

### Tradable Items & Base Prices

| Item Type | Base Price Source |
|---|---|
| Animals | Rarity sell value (see inventory.md) |
| Weapons | Weapon shop price |
| Enchantments | Mythic: 10k, Legendary: 30k, Fabled: 50k |
| Evolution Stones | Mythic: 15k, Legendary: 30k, Fabled: 60k, Gods: 100k |

### Price Restrictions
- Allowed range: **-20% to +50%** of base price
- Example: item with 10,000 base → allowed range: 8,000–15,000 🪙

### Evolution Stage Price Multiplier
- Stage 1 (+): base price × **1.60** (+60%)
- Stage 2 (++): base price × **1.80** (+80%)

### Buying from Marketplace

**Command:** `.item buy <listingID>`

- Listing IDs are 4-character alphanumeric codes
- Cannot buy your own listing
- Full price transferred directly from buyer to seller
- If the item no longer exists (seller removed it), buyer is automatically refunded

### Item Transfer Rules

| Item Type | On Purchase |
|---|---|
| Animal | Transferred to buyer, **level reset to 1** (evolution stage kept) |
| Weapon | Transferred to buyer, unequipped from any slot |
| Enchantment | Removed from seller inventory, added to buyer with **fresh 50 usage** |
| Evolution Stone | Removed from seller inventory, added to buyer |

### Sell Restrictions

- **Animals:** cannot sell if in a team or equipped
- **Weapons:** cannot sell if equipped
- **Enchantments:** cannot sell if used (usage < max) or if equipped with no duplicates
- Items already listed cannot be listed again

### Listing Management
- `.market mine` — view all your listings (active and sold)
- `.market cancel <ID>` — cancel an active listing (no refund of listing fee)
- Max **30 listings** shown per marketplace view

---

## Edge Cases

- Guard dogs stack — you can buy and hold multiple
- Weapon shop is paginated (10 per page)
- Animal shop only shows base forms (excludes evolved forms from evolution chains)
- Gems are consumed when unequipped — they cannot be recovered
- Marketplace listing IDs are unique 4-character codes (letters + digits, no O/0/1/I confusion)
- If a marketplace item is sold/removed by the seller after listing, the buyer gets an automatic refund
- Listing fee (2%) is non-refundable even if the listing is cancelled
- Enchantments bought from marketplace always come with fresh 50 usage, regardless of seller's usage
