86 lines
2.9 KiB
Python
86 lines
2.9 KiB
Python
"""Enemy entities and the full stat roster from plan.md §Enemy Roster."""
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from entities.entity import Entity
|
|
|
|
ENEMY_KINDS: list[str] = [
|
|
"rat", "goblin", "skeleton_archer", "orc_warrior",
|
|
"wraith", "green_slime", "ancient_dragon",
|
|
]
|
|
|
|
# kind -> full roster. `floors` is the (min, max) depth gate from plan.md.
|
|
# `ranged` is ranged_power (skeleton bolt / dragon breath); 0 = no ranged.
|
|
_ROSTER: dict[str, dict] = {
|
|
"rat": dict(
|
|
name="Rat", hp=8, power=3, armor=0, accuracy=4, evasion=2, crit=0.05,
|
|
speed=1, behavior="wander", xp=5, ranged=0, floors=(0, 3),
|
|
),
|
|
"goblin": dict(
|
|
name="Goblin", hp=15, power=5, armor=1, accuracy=5, evasion=1, crit=0.05,
|
|
speed=1, behavior="chase", xp=12, ranged=0, floors=(0, 5),
|
|
),
|
|
"skeleton_archer": dict(
|
|
name="Skeleton Archer", hp=12, power=4, armor=1, accuracy=6, evasion=1, crit=0.10,
|
|
speed=1, behavior="ranged", xp=15, ranged=6, floors=(2, 7),
|
|
),
|
|
"orc_warrior": dict(
|
|
name="Orc Warrior", hp=30, power=8, armor=3, accuracy=5, evasion=0, crit=0.10,
|
|
speed=1, behavior="flee", xp=25, ranged=0, floors=(3, 8),
|
|
),
|
|
"wraith": dict(
|
|
name="Wraith", hp=20, power=10, armor=0, accuracy=6, evasion=3, crit=0.10,
|
|
speed=2, behavior="phase", xp=30, ranged=0, floors=(5, 8),
|
|
),
|
|
"green_slime": dict(
|
|
name="Green Slime", hp=18, power=5, armor=1, accuracy=4, evasion=0, crit=0.05,
|
|
speed=1, behavior="split", xp=18, ranged=0, floors=(4, 8),
|
|
),
|
|
"ancient_dragon": dict(
|
|
name="Ancient Dragon", hp=120, power=15, armor=8, accuracy=7, evasion=0, crit=0.15,
|
|
speed=1, behavior="chase", xp=200, ranged=15, floors=(9, 9),
|
|
),
|
|
}
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class Enemy(Entity):
|
|
name: str = ""
|
|
sprite_key: str = "enemy"
|
|
hp: int = 1
|
|
max_hp: int = 1
|
|
power: int = 0
|
|
armor: int = 0
|
|
accuracy: int = 0
|
|
evasion: int = 0
|
|
crit_chance: float = 0.0
|
|
speed: int = 1
|
|
behavior: str = "wander"
|
|
xp_value: int = 0
|
|
last_known_pos: tuple[int, int] | None = None
|
|
act_counter: int = 0
|
|
can_split: bool = True
|
|
ranged_power: int = 0
|
|
|
|
|
|
def make_enemy(kind: str, x: int, y: int) -> Enemy:
|
|
"""Construct an Enemy of the given kind at (x, y) with full roster stats."""
|
|
s = _ROSTER[kind]
|
|
return Enemy(
|
|
x=x, y=y, name=s["name"], sprite_key=kind,
|
|
hp=s["hp"], max_hp=s["hp"], power=s["power"], armor=s["armor"],
|
|
accuracy=s["accuracy"], evasion=s["evasion"], crit_chance=s["crit"],
|
|
speed=s["speed"], behavior=s["behavior"], xp_value=s["xp"],
|
|
ranged_power=s["ranged"],
|
|
)
|
|
|
|
|
|
def kinds_for_floor(floor_index: int) -> list[str]:
|
|
"""Non-boss enemy kinds allowed to spawn on the given floor (depth-gated)."""
|
|
return [
|
|
k for k, s in _ROSTER.items()
|
|
if k != "ancient_dragon"
|
|
and s["floors"][0] <= floor_index <= s["floors"][1]
|
|
]
|