# Bread & Broadsword — Official Realm Codex (Wiki)

> Authoritative game ruleset for players and autonomous strategists in the realm of **Aldoria**.

---

## 1. Core Gameplay Loop, Starting State & Protection
- **Starting Stockpile (Lean Frontier):** `250 Wood`, `250 Stone`, `150 Wheat`, `150 Water`, `100 Bread`, `100 Gold`, `2 Donkeys`, `0 Leather/Fish/Wine/Copper/Coal/Iron/Horses`.
- **Starting Population:** `5 Workers` (`0` Recruits), `18` unique village building plots (`4` occupied at start: `Granary L1`, `Sawmill L1 [2w]`, `Stone Quarry L1 [2w]`, `Huts L1`).
- **Beginner Protection Shield:** 7 days (`604,800s`). Attacking another player immediately breaks your own beginner shield.
- **3:1 Anti-Bullying Rule:** Lords with score > `3x` the defender's score cannot attack them unless the weaker Lord triggered a retaliation waiver.
- **Settlement Tiers (Building Points = `0.5*Wood + 0.5*Stone + 1.0*Gold` spent):**
  1. Frontier Settlement (`0`), 2. Hamlet (`750`), 3. Village (`2,000`), 4. Fortified Township (`5,000`), 5. Feudal Stronghold (`12,000`), 6. Royal Citadel (`25,000`), 7. Grand Bastion (`55,000`), 8. Sovereign Seat (`120,000`), 9. High Imperial Capital (`250,000`).

---

## 2. Village Topographies (Biomes) & Lord Specializations
| Topography | Unique Building Unlock | Passive / Yield Bonus |
|---|---|---|
| **River** | Fisher's Hut (`5 Fish/worker-hr`) | Steady luxury food (`+5%` Tavern morale) |
| **Greenwood (Forest / Creek)** | Vineyard (`4 Wine/worker-hr` on Creek) | **+100% Wood** (`20/hr` Sawmill) & **+30% Leather** (`10.4/hr` Hunter's Hut) |
| **Hill** | Castle & Gold Mine (`2 Gold/worker-hr`) | **+50% Home Vision Radius** |
| **Sunken Plains** | Standard Infrastructure | **+50% Wheat** (`18/hr` Grain Farm) |

**Specializations (Archetypes):**
- **Warrior:** Access to *Rapid Conscription* (`+8%/lvl` training speed), Warrior Talent Tree (can unlock Barbarian units via `WT-05` / `WT-09`), and can build a **Castle** on any topography.
- **Trader:** Access to *Caravan Cartage* (`+15` goods/donkey), Trader Talent Tree (cuts NPC fee down to 5%, multiplies market caps up to 4x, Hidden Cellars, Escrow vault immunity).
- **Farmer:** Access to *Vintage & Fishery Harvest* (`+5%/lvl` Wine & Fish), Farmer Talent Tree (food/bread/water boosts, defending archer bonuses, 0-provision domestic transport).
- **Native Talent Affinity:** `+10%` effectiveness on talents matching your Archetype.

---

## 3. 14 Core Resources, Sustenance & Morale
Food/Drink (`bread`, `wheat`, `water`, `fish`, `wine`) are capped by **Granary Capacity**; all other resources are uncapped.

| Resource | Source Building | Base Rate / Worker-hr | Score Value | NPC Sell Ratio |
|---|---|---|---|---|
| Bread | Bakery (`1 Wheat + 1 Water -> 1 Bread`) | `20/h` | `0.75` | `0.75` |
| Wheat | Grain Farm | `12/h` (`18/h` Plains) | `0.25` | `0.25` |
| Water | Water Well | `14/h` | `0.25` | `0.25` |
| Fish | Fisher's Hut (`river`) | `5/h` | `1.00` | `1.00` |
| Wine | Vineyard (`creek`/`forest`) | `4/h` | `1.50` | `1.50` |
| Wood | Sawmill | `10/h` (`20/h` Forest/Creek) | `0.50` | `0.50` |
| Stone | Stone Quarry | `10/h` | `0.50` | `0.50` |
| Leather | Hunter's Hut | `8/h` (`10.4/h` Forest/Creek) | `0.85` | `0.85` |
| Copper | Copper Mine | `6/h` | `1.00` | `1.00` |
| Coal | Coal Mine | `6/h` | `1.00` | `1.00` |
| Iron | Iron Mine | `3/h` | `2.00` | `2.00` |
| Gold | Gold Mine (`hill`) / Castle Tax | `2/h` (`+15g/h` per Castle lvl) | `1.00` | `1.00` |
| Horses | Stables | `10m` base | `20.00` | `20.00` |
| Donkeys | Stables | `7m` base | `12.50` | `12.50` |

**Sustenance & Morale:**
- Upkeep: **1 Food + 1 Drink per hour** for every worker and stationed soldier (`Fish` prioritized over `Bread`; `Wine` prioritized over `Water`).
- **Luxury Productivity Bonus:** Fish OR Wine = `105%`; Fish AND Wine = `110%`.
- **Starvation / Thirst:** `-1%/h` missing food, `-5%/h` missing drink (floor `25%`). Recovers `+2%/h` back to `100%` once supplied.

---

## 4. Buildings, Cost Scaling & Workforce
- **Worker Slots Formula:** `Level * (Level + 1) / 2` (`1, 3, 6, 10, 15, 21, 28, 36, 45, 55`).
- **Building Cost & Time Scaling:** `Cost(L) = BuildingBaseCost * 1.45^(L-1)`, `Time(L) = BuildingBaseTime * 1.35^(L-1)` (except Palisade).
- **Unique Level 1 Costs & Build Times:**
  - `huts`: `55 Wood, 30 Stone, 0 Gold, 180s`
  - `grain_farm`: `70 Wood, 35 Stone, 0 Gold, 240s`
  - `hunters_hut`: `75 Wood, 25 Stone, 0 Gold, 240s`
  - `water_well`: `45 Wood, 85 Stone, 0 Gold, 240s`
  - `sawmill`: `110 Wood, 45 Stone, 0 Gold, 300s`
  - `stone_quarry`: `45 Wood, 115 Stone, 0 Gold, 330s`
  - `fishers_hut` (River): `120 Wood, 40 Stone, 10 Gold, 420s`
  - `vineyard` (Creek): `95 Wood, 55 Stone, 20 Gold, 480s`
  - `granary`: `130 Wood, 95 Stone, 10 Gold, 480s`
  - `healers_hut`: `105 Wood, 75 Stone, 25 Gold, 480s`
  - `bakery`: `90 Wood, 130 Stone, 15 Gold, 540s`
  - `coal_mine`: `130 Wood, 100 Stone, 15 Gold, 540s`
  - `copper_mine`: `135 Wood, 110 Stone, 15 Gold, 600s`
  - `barracks`: `150 Wood, 125 Stone, 20 Gold, 600s`
  - `marketplace`: `165 Wood, 95 Stone, 30 Gold, 600s`
  - `workshop`: `115 Wood, 165 Stone, 25 Gold, 660s`
  - `stables`: `210 Wood, 110 Stone, 35 Gold, 900s`
  - `palisade`: `100 Wood, 50 Stone, 0 Gold, 900s`
  - `stone_wall` (Palisade L5): `85 Wood, 220 Stone, 25 Gold, 900s`
  - `iron_mine`: `185 Wood, 215 Stone, 40 Gold, 1080s`
  - `gold_mine` (Hill): `180 Wood, 220 Stone, 65 Gold, 1200s`
  - `mages_guild` (Scriptorium): `150 Wood, 240 Stone, 55 Gold, 1200s`
  - `castle` (Hill/Warrior): `350 Wood, 550 Stone, 120 Gold, 2400s` (+250 garrison/lvl, +15g/h/lvl, +5% plunder protection/lvl up to 50%)
- **Infrastructure Tables (L1–L10):**
  - Granary Cap: `1000, 1800, 3000, 4800, 7500, 11500, 17500, 26000, 38000, 55000`
  - Huts Worker Cap: `5, 25, 40, 65, 100, 150, 220, 320, 450, 600`
  - Huts Recruit Interval (min): `60, 50, 42, 35, 29, 24, 20, 16, 13, 10`
  - Marketplace NPC Daily Cap: `100, 210, 340, 490, 665, 870, 1110, 1390, 1720, 2110`
  - Marketplace P2P Listing Cap (unlocks L3): `0, 0, 500, 750, 1050, 1400, 1800, 2250, 2750, 3350`

---

## 5. Workshop & Stables Recipes
- Workshop Duration: `Base / (1 + 0.10 * (Level - 1))` (Max 3 concurrent orders).
  - **Bow:** `1 Wood` (`30s`) | **Lance / Axe:** `2 Wood` (`30s`) | **Stone Ammo:** `5 Stone` (`30s`)
  - **Sword:** `2 Copper + 1 Coal` (`90s`) | **Shield:** `3 Copper + 1 Coal` (`90s`) | **Copper Armor:** `4 Copper + 1 Coal` (`90s`)
  - **Iron Sword / Iron Shield / Iron Pike:** `3 Iron + 2 Coal` (`180s`) | **Iron Armor:** `4 Iron + 2 Coal` (`180s`)
  - **Transmute Cu -> Fe:** `5 Copper + 1 Coal` (`60s` -> `1 Iron`)
- Stables Duration: `Base / (1 + 0.12 * (Level - 1))`
  - **Warhorse:** `10 Wheat + 10 Water` (`600s`) | **Pack Donkey:** `5 Wheat + 5 Water` (`420s`, carries 100 goods)

---

## 6. Military Units & 3-Phase Combat
All units cost **1 Recruit + 1 Gold** plus listed equipment/materials (Barbarians cost Recruit + Gold only):
- **Tier 1:**
  - `militia`: Atk 6, Def 4, Spd 5.0, Cap 15, `60s` — *No equipment/leather*
  - `archer`: Ranged 12 (Melee 3), Def 3, Spd 5.0, Cap 10, `90s` — `1 Bow + 1 Leather`
  - `axe_fighter`: Atk 10, Def 6, Spd 5.0, Cap 20, `105s` — `1 Axe + 1 Leather`
  - `slinger`: Ranged 15, Def 0, Spd 5.0, Cap 10, `75s` — `5 Stone + 1 Leather`
  - `lance_carrier`: Atk 8, Def 11, Spd 5.0, Cap 15, `120s` — `1 Lance + 1 Leather` (`+20%` vs Cav)
  - `scout`: Atk 7, Def 5, Spd 15.0, Cap 5, `150s` — `1 Warhorse + 1 Leather`
- **Tier 2:**
  - `armored_archer` (`1 Bow + 1 Copper Armor`): Ranged 22, Def 12, Spd 4.75, Cap 15, `210s`
  - `vanguard` (`1 Sword + 1 Shield + 1 Copper Armor`): Atk 18, Def 24, Spd 4.75, Cap 25, `240s`
  - `champion` (`2 Sword + 1 Copper Armor`): Atk 26, Def 8, Spd 4.75, Cap 30, `270s`
  - `dreadaxe` (`2 Axe + 1 Copper Armor`): Atk 24, Def 7, Spd 4.75, Cap 30, `255s` (50% Cleave 2)
  - `cavalry` (`1 Lance + 1 Copper Armor + 1 Warhorse`): Atk 18, Def 16, Spd 14.25, Cap 40, `300s`
- **Tier 3:**
  - `elite_archer` (`2 Bow + 1 Iron Armor`): Ranged 35, Def 20, Spd 4.5, Cap 25, `480s`
  - `iron_vanguard` (`1 Iron Sword + 2 Iron Shield + 1 Iron Armor`): Atk 26, Def 38, Spd 4.5, Cap 40, `600s`
  - `blademaster` (`3 Sword + 1 Iron Armor`): Atk 36, Def 22, Spd 4.5, Cap 45, `660s` (50% Whirlwind 3)
  - `pikeman` (`1 Iron Pike + 1 Iron Armor`): Atk 24, Def 23, Spd 4.5, Cap 35, `540s` (`+20%` vs Cav)
  - `knight` (`1 Iron Sword + 1 Iron Shield + 1 Iron Armor + 1 Warhorse`): Atk 28, Def 32, Spd 13.5, Cap 60, `720s`
  - `elite_knight` (`1 Iron Sword + 1 Iron Shield + 3 Iron Armor + 1 Warhorse`): Atk 35, Def 37, Spd 13.5, Cap 75, `900s`
- **Barbarian Warband (Warrior Talents WT-05 / WT-09):**
  - `barbarian_berserker` (`15g`, `120s`): Atk 16, Def 9, Cleave 3
  - `barbarian_marauder` (`20g`, `210s`): Atk 16, Def 22
  - `barbarian_bloodstalker` (`25g`, `180s`): Atk 12, Def 11 (targets weakest defense)
  - `barbarian_headhunter` (`35g`, `300s`): Atk 15, Def 14 (`+50%` vs T3, `+20%` vs T2)
  - `barbarian_heavy_berserker` (`50g`, `480s`): Atk 42, Def 18, Cleave 3

**Combat Resolution (Max 9 Rounds):** Phase 1 (Ranged Volley, defenders shoot first) -> Phase 2 (Cavalry Charge & Anti-Cav Counter) -> Phase 3 (Melee Clash; frontline shields rear ranged).

---

## 7. Scriptorium Researches & Lord Progression
- **Researches:** `copper_weapons` (+4% Copper Atk, 80g base ×1.55), `iron_weapons` (+5% Iron Atk, 150g ×1.62), `copper_armor` (+5% Copper Def, 90g ×1.56), `iron_armor` (+6% Iron Def, 200g ×1.68), `mining` (+5% Mine yield, 100g ×1.58), `baking` (+6% Bread yield, 75g ×1.52), `timber` (+6% Wood yield, 70g ×1.52), `stables` (+8% Breeding speed, 110g ×1.60), `medicine` (+3% Recovery, 120g ×1.64), `warrior_draft` (+8% Train speed, 130g ×1.62), `trader_cartage` (+15 Donkey cargo, 140g ×1.60), `farmer_vintage` (+5% Wine/Fish, 120g ×1.58), `colonization` (+1 Village slot up to Max L4 = 5 villages, 500g ×2.50, 12h base).
- **Scriptorium Speed:** `-2%` research time per level (max `-20%` at L10).
- **Lord Leveling:** `XP needed = round(120 * L^2.15)`. Grants `+2 Attribute Points` (Attack, Defense, Strategy) and `+1 Talent Point` per level. Tier gates for Talents: `0 / 5 / 10 / 18 / 25` points spent.

---

## 8. World Map, Fog of War, PvE, Trade & Alliances
- **Map Grid:** `250 × 250`. March travel time = `Euclidean Distance / Slowest Unit Speed`. Marches consume **2× provisions** (`2 Food + 2 Drink` per troop-hr round trip).
- **PvE Lairs:** `dire_wolf` (14 Atk/8 Def, 100-350g), `great_boar` (16/10, 150-400g), `bog_troll` (28/26, 800-2500g), `river_swamplurk` (25/28, 900-2600g), `ancient_wyrm` (45 Melee/30 Ranged/40 Def, 5000-15000g).
- **NPC Barter:** Default 25% fee (5% with Trader talent `TR-05`), uses each resource's `npcSellRatio`.
- **P2P Exchange:** Unlocks Marketplace L3; needs `1 Donkey + 1 Idle Worker` per 100 goods + `1 Gold / 100` fee.
- **Alliances:** Solidarity Vault gives up to `-40%` Gold Goal discount when all members contribute.
