# ⚔️ Code of Conquest — Game Mechanics Guide

Welcome to the **Code of Conquest Battle System** — a turn-based, JRPG-inspired combat framework that blends strategy, morality, and fate.  
Every action, from sword swings to spellcasting, is influenced by your attributes, alignment, and a touch of luck.

---

## 🧩 Core Attributes

Each hero or enemy has six base attributes that define their natural strengths and weaknesses.

| Attribute | Description |
|------------|--------------|
| **Strength (STR)** | Governs physical power, melee attacks, and endurance. |
| **Dexterity (DEX)** | Controls accuracy, evasion, and proficiency with ranged weapons. |
| **Intelligence (INT)** | Determines magic power and spell accuracy. |
| **Wisdom (WIS)** | Governs magical defense, perception, and resistance to debuffs. |
| **Luck (LCK)** | Influences critical hits, evasion, loot, and unexpected fortune. |
| **Charisma (CHA)** | Affects leadership, morale, and social interactions. |

---

## ⚙️ Derived Combat Stats

These values are automatically calculated from your core attributes, level, and equipment.

| Stat | Formula | Description |
|------|----------|-------------|
| **Attack (ATK)** | `(STR × 2) + WeaponBonus` | Physical damage output. |
| **Magic Power (MAG)** | `(INT × 2) + StaffBonus` | Magical damage output. |
| **Defense (DEF)** | `(STR × 0.5) + ArmorBonus` | Reduces incoming physical damage. |
| **Magic Defense (MDEF)** | `(WIS × 0.5) + GearBonus` | Reduces incoming magical damage. |
| **Accuracy (ACC)** | `(DEX × 2) + (LCK × 0.25)` | Likelihood of hitting your target. |
| **Evasion (EVA)** | `(DEX × 1.5) + (LCK × 0.25)` | Likelihood of dodging attacks. |
| **Critical Chance (CRIT%)** | `(LCK × 0.5)%` | Chance to land a critical hit. |
| **Resistance (RES)** | `(WIS × 2) + (LCK × 0.5)` | Chance to resist magical or status effects. |

---

## ⚔️ Combat Overview

Combat is **turn-based** and **formula-driven**.  
Every action follows a consistent, deterministic flow — modified by attributes, skills, and luck.

### Step 1 — Accuracy Check
Before any attack lands, its success is determined by comparing **Accuracy** and **Evasion**.

- **Physical attacks**
```

HitChance = ACC / (ACC + Target.EVA)

```
- **Magical attacks**
```

SpellHitChance = (INT + LCK) / ((INT + LCK) + (Target.WIS + Target.LCK))

```

If the resulting value ≥ a random roll (0–1), the attack hits.

---

### Step 2 — Damage Calculation

Once a hit lands, the system determines how much damage is dealt.

#### Physical Damage
```

BaseDamage = (ATK - (Target.DEF × 0.5))
Variance = random(0.9, 1.1)
CritModifier = 1.5 if roll ≤ CRIT% else 1.0
Damage = BaseDamage × Variance × CritModifier

```

#### Magical Damage
```

BaseDamage = (MAG - (Target.MDEF × 0.5))
Variance = random(0.9, 1.1)
Damage = BaseDamage × Variance

```

---

## 💫 Alignment Influence

Every character and creature has an **Alignment Score** from **–100 (Evil)** to **+100 (Good)**.  
The difference between two combatants’ alignments affects damage output.

```

AlignmentDifference = abs(Attacker.Alignment - Target.Alignment)
AlignmentBonus = (AlignmentDifference / 10) / 100

```

**Example:**  
A Paladin (+80) attacks a Necromancer (–70).  
Difference = 150 → +15% damage.

```

Damage = Damage × (1 + AlignmentBonus)

```

The greater the moral divide, the stronger the opposing strike.

---

## 🍀 Luck in Action

**Luck (LCK)** weaves subtle influence through nearly every mechanic:

| Mechanic | Luck Effect |
|-----------|--------------|
| Hit Accuracy | Boosts ACC slightly. |
| Critical Hits | Directly increases CRIT%. |
| Damage Rolls | Pushes random variance toward higher values. |
| Loot & Rewards | Increases rare drop chances. |
| Status Resistance | Adds to RES for debuff avoidance. |
| Escape & Initiative | Slightly improves odds in initiative rolls. |

Even a low-power adventurer with high luck can turn the tides of battle.

---

## 📈 Level Scaling

As characters grow in level, their core attributes increase according to **class-based growth curves**.

| Class | STR | DEX | INT | WIS | LCK | CHA |
|--------|------|------|------|------|------|------|
| Guardian | High | Low | Low | Medium | Low | Medium |
| Ranger | Medium | High | Low | Low | Medium | Medium |
| Arcanist | Low | Medium | High | Medium | Medium | Low |
| Cleric | Low | Low | Medium | High | Medium | High |

Level growth, combined with equipment bonuses and skills, naturally scales all derived stats.

---

## 🧠 Skill Modifiers

Every ability or spell uses the base formulas but applies **unique multipliers** or special effects.

| Skill | Type | Effects |
|--------|------|----------|
| **Power Slash** | Melee | Damage × 1.5, Accuracy × 0.9 |
| **Piercing Shot** | Ranged | Ignores 25% of target DEF |
| **Fireball** | Magic | Damage × 1.2, chance to Burn (INT + LCK based) |
| **Bless** | Support | Boosts ally ATK × 1.1 for 3 turns |
| **Hex** | Curse | Reduces enemy WIS × 0.8 for 2 turns |

Skills can be enhanced, learned, or combined as your characters progress.

---

## 🧮 Example Combat Resolution

**Scenario:**  
A Level 10 Guardian with high STR attacks an evil creature using *Power Slash.*

```

HitChance = ACC / (ACC + Target.EVA)
If hit:
Damage = ((ATK - (Target.DEF × 0.5)) × 1.5)
Damage *= random(0.9, 1.1)
Damage *= (1 + AlignmentBonus)
Damage *= CritModifier

```

**Result:**  
The system reports a hit, critical strike, or miss — then narrates the event through the AI Dungeon Master.

---

## 🔮 Design Philosophy

The **Code of Conquest Battle System** emphasizes:
- Predictable, understandable outcomes driven by player stats.
- Minimal dice-roll chaos — randomness exists, but never dominates.
- Moral alignment and luck as storytelling mechanics, not just numbers.
- Clear extensibility for future features like elemental affinities, buffs, and combo attacks.

Every fight is both a **test of numbers** and a **reflection of who your character truly is**.

---

*Last updated:* October 2025  
*System version:* 1.0 — “Balance of Fate”
