(Underdepth) Pass 3

This commit is contained in:
AlexKucera committed 2026-08-13 07:28:55 +02:00
1 parent 832f3a3345
commit c61d73bdfc
30 files changed
+4151

No files matched your search

+95
View File
@@ -0,0 +1,95 @@
"""All tunable values and colors live here. No magic numbers in logic."""
MAP_W: int = 80
MAP_H: int = 50
TILE: int = 16
SIGHT_RADIUS: int = 8
FLOORS: int = 10
BOSS_FLOOR: int = 9
# --- BSP dungeon generation --------------------------------------------------
BSP_SPLITS_MIN: int = 5
BSP_SPLITS_MAX: int = 8
SPLIT_MIN_DIM: int = 18
SPLIT_RATIO_MIN: float = 0.40
SPLIT_RATIO_MAX: float = 0.60
ROOM_MIN_W: int = 4
ROOM_MAX_W: int = 10
ROOM_MIN_H: int = 4
ROOM_MAX_H: int = 8
ROOM_SHRINK_MIN: int = 1
ROOM_SHRINK_MAX: int = 2
BOSS_ROOM_W: int = 20
BOSS_ROOM_H: int = 15
# --- combat tuning (referenced by phase 2, defined once here) ----------------
HIT_BASE: float = 0.70
HIT_STEP: float = 0.05
HIT_FLOOR: float = 0.10
HIT_CEIL: float = 0.95
RANGE_HIT_PENALTY: float = 0.03
# --- progression (XP, leveling) ----------------------------------------------
# XP_THRESHOLDS[i] is the cumulative XP needed to reach level i+2 (index 0 -> L2).
XP_THRESHOLDS: list[int] = [30, 70, 140, 250, 400, 600, 850, 1150, 1500]
# Per-level HP/power gains applied on reaching that level; index 0 -> L1->L2.
LEVEL_HP_GAINS: list[int] = [10, 10, 10, 10, 15, 15, 15, 15, 20]
LEVEL_POWER_GAINS: list[int] = [1, 1, 1, 1, 2, 2, 2, 2, 3]
MAX_LEVEL: int = 10
LOG_MAX: int = 50
# --- viewport / UI layout (renderer + main) ----------------------------------
VIEW_TILES_W: int = 50
VIEW_TILES_H: int = 30
PANEL_W: int = 200
TOP_BAR_H: int = 24
BOTTOM_BAR_H: int = 80
SCREEN_W: int = VIEW_TILES_W * TILE + PANEL_W # 1000
SCREEN_H: int = TOP_BAR_H + VIEW_TILES_H * TILE + BOTTOM_BAR_H # 584
# message-log color classifier keys (renderer heuristic)
LOG_COLOR_GOOD: tuple[str, ...] = (
"defeat", "defeats", "reach level", "slew", "conquer", "recover", "pick up",
"level up", "equip",
)
# --- consumable effects -------------------------------------------------------
STRENGTH_POWER_BONUS: int = 5
FIREBALL_DEFAULT_DAMAGE: int = 20
# --- colors ------------------------------------------------------------------
COLORS: dict[str, tuple[int, int, int]] = {
"wall_visible": (60, 60, 70),
"wall_explored": (30, 30, 35),
"floor_visible": (40, 35, 30),
"floor_explored": (20, 18, 15),
"player": (255, 255, 255),
"stairs": (255, 235, 50),
"weapon": (255, 215, 0),
"armor": (60, 120, 220),
"potion": (220, 40, 40),
"scroll": (0, 200, 200),
"ui_fg": (220, 220, 220),
"ui_dim": (140, 140, 140),
"ui_hp": (200, 40, 40),
"ui_xp": (80, 160, 240),
"msg_combat": (235, 235, 235),
"msg_hurt": (220, 60, 60),
"msg_good": (90, 220, 90),
"msg_item": (255, 215, 0),
"background": (0, 0, 0),
}
ENEMY_COLORS: dict[str, tuple[int, int, int]] = {
"Rat": (139, 69, 19),
"Goblin": (34, 139, 34),
"Skeleton Archer": (200, 200, 210),
"Orc Warrior": (139, 0, 0),
"Wraith": (138, 43, 226),
"Green Slime": (50, 205, 50),
"Ancient Dragon": (255, 40, 0),
}
+49
View File
@@ -0,0 +1,49 @@
"""Enemy roster. Stats match plan.md Enemy Roster exactly."""
from __future__ import annotations
from data.constants import ENEMY_COLORS
# accuracy/evasion/crit_chance are not enumerated in the plan's roster table;
# sensible defaults per enemy keep combat fair without contradicting it.
ENEMIES: dict[str, dict] = {
"Rat": {
"hp": 8, "power": 3, "armor": 0, "accuracy": 4, "evasion": 2,
"crit_chance": 0.05, "speed": 1, "behavior": "wander", "xp": 5,
"ranged_power": 0, "floors": (0, 3), "color": ENEMY_COLORS["Rat"],
},
"Goblin": {
"hp": 15, "power": 5, "armor": 1, "accuracy": 5, "evasion": 1,
"crit_chance": 0.05, "speed": 1, "behavior": "chase", "xp": 12,
"ranged_power": 0, "floors": (0, 5), "color": ENEMY_COLORS["Goblin"],
},
"Skeleton Archer": {
"hp": 12, "power": 4, "armor": 1, "accuracy": 6, "evasion": 1,
"crit_chance": 0.10, "speed": 1, "behavior": "ranged", "xp": 15,
"ranged_power": 6, "floors": (2, 7), "color": ENEMY_COLORS["Skeleton Archer"],
},
"Orc Warrior": {
"hp": 30, "power": 8, "armor": 3, "accuracy": 4, "evasion": 0,
"crit_chance": 0.05, "speed": 1, "behavior": "flee", "xp": 25,
"ranged_power": 0, "floors": (3, 8), "color": ENEMY_COLORS["Orc Warrior"],
},
"Wraith": {
"hp": 20, "power": 10, "armor": 0, "accuracy": 6, "evasion": 3,
"crit_chance": 0.10, "speed": 2, "behavior": "phase", "xp": 30,
"ranged_power": 0, "floors": (5, 8), "color": ENEMY_COLORS["Wraith"],
},
"Green Slime": {
"hp": 18, "power": 5, "armor": 1, "accuracy": 4, "evasion": 0,
"crit_chance": 0.05, "speed": 1, "behavior": "split", "xp": 18,
"ranged_power": 0, "floors": (4, 8), "color": ENEMY_COLORS["Green Slime"],
},
"Ancient Dragon": {
"hp": 120, "power": 15, "armor": 8, "accuracy": 7, "evasion": 1,
"crit_chance": 0.10, "speed": 1, "behavior": "chase", "xp": 200,
"ranged_power": 0, "floors": (9, 9), "color": ENEMY_COLORS["Ancient Dragon"],
},
}
def enemies_for_floor(floor_index: int) -> list[str]:
return [k for k, v in ENEMIES.items()
if v["floors"][0] <= floor_index <= v["floors"][1]]
+50
View File
@@ -0,0 +1,50 @@
"""Item catalog and depth-scaled rolling.
ITEM_CATALOG maps a name to the exact Item constructor fields (no x/y/name/color;
those are filled by make_item). roll_item gates gear by floor depth and leaves
consumables uniform, per plan.md item distribution.
"""
from __future__ import annotations
import random
ITEM_CATALOG: dict[str, dict] = {
"Rusty Dagger": {"kind": "weapon", "power": 2},
"Short Sword": {"kind": "weapon", "power": 4},
"Battle Axe": {"kind": "weapon", "power": 7},
"War Hammer": {"kind": "weapon", "power": 10, "crit_delta": -0.05},
"Leather Armor": {"kind": "armor", "armor": 2},
"Chain Mail": {"kind": "armor", "armor": 4},
"Plate Armor": {"kind": "armor", "armor": 7, "evasion_delta": -0.10},
"Healing Potion": {"kind": "potion", "sub": "healing", "heal": 30},
"Strength Potion": {"kind": "potion", "sub": "strength", "duration": 20},
"Invisibility Potion": {"kind": "potion", "sub": "invisibility", "duration": 15},
"Scroll of Fireball": {"kind": "scroll", "sub": "fireball", "damage": 20, "radius": 3},
"Scroll of Teleport": {"kind": "scroll", "sub": "teleport"},
"Scroll of Mapping": {"kind": "scroll", "sub": "mapping"},
}
# Minimum floor index at which a piece of gear may roll. Consumables have no
# entry -> available on every floor.
ITEM_MIN_FLOOR: dict[str, int] = {
"Rusty Dagger": 0,
"Short Sword": 2,
"Battle Axe": 4,
"War Hammer": 6,
"Leather Armor": 0,
"Chain Mail": 3,
"Plate Armor": 5,
}
def roll_item(floor_index: int, rng: random.Random):
# Lazy import: entities.item imports this module at top level.
from entities.item import make_item
gear = [n for n, d in ITEM_MIN_FLOOR.items() if floor_index >= d]
if rng.random() < 0.60 and gear:
name = rng.choice(gear)
else:
consumables = [n for n, s in ITEM_CATALOG.items() if s["kind"] in ("potion", "scroll")]
name = rng.choice(consumables)
return make_item(name)