(Underdepths) Prepare for Pass 3

This commit is contained in:
AlexKucera committed 2026-08-12 18:48:39 +02:00
1 parent b49c285c89
commit dc8bfd6846
37 files changed
-5590

No files matched your search

View File
Whitespace-only changes.
-79
View File
@@ -1,79 +0,0 @@
"""Underdepths tuning constants.
Every magic number lives here so balancing is trivial. See plan.md for the
source-of-truth design tables.
"""
MAP_W = 80
MAP_H = 50
TILE_WALL = 0
TILE_FLOOR = 1
SIGHT_RADIUS = 8
# Cumulative XP required to reach level i+1 (index 0 is the level-1 start).
LEVEL_XP = [0, 30, 70, 140, 250, 400, 600, 850, 1150, 1500]
# Stat grants applied when advancing FROM level (i+1) -> (i+2); index i.
LEVEL_HP_GAIN = [10, 10, 10, 10, 15, 15, 15, 15, 20]
LEVEL_POWER_GAIN = [1, 1, 1, 1, 2, 2, 2, 2, 3]
PLAYER_BASE = {
"hp": 50,
"max_hp": 50,
"power": 4,
"armor": 0,
"accuracy": 5,
"evasion": 2,
"crit_chance": 0.10,
"speed": 1,
}
COLORS = {
# terrain
"wall_visible": (60, 60, 70),
"wall_explored": (30, 30, 35),
"floor_visible": (40, 35, 30),
"floor_explored": (20, 18, 15),
# actors
"player": (255, 255, 255),
"rat": (150, 100, 50), # brown
"goblin": (70, 180, 80), # green
"skeleton_archer": (210, 210, 210), # white-gray
"orc_warrior": (140, 40, 40), # dark red
"wraith": (160, 90, 210), # translucent purple
"green_slime": (100, 220, 100), # bright green
"small_slime": (130, 230, 130),
"ancient_dragon": (235, 50, 50), # bright red
# items
"weapon": (225, 205, 90), # yellow
"armor_item": (90, 120, 225), # blue
"potion": (225, 70, 70), # red
"scroll": (90, 205, 225), # cyan
"stairs": (240, 220, 60), # bright yellow
}
ROOM_MIN_W = 4
ROOM_MIN_H = 4
ROOM_MAX_W = 10
ROOM_MAX_H = 8
# BSP recursive-split count range.
BSP_MIN_SPLITS = 5
BSP_MAX_SPLITS = 8
# Smallest leaf dimension allowed; guarantees a room fits with a margin.
LEAF_MIN_W = 7
LEAF_MIN_H = 6
# Per-floor spawn ranges: floor_index -> (enemy_min, enemy_max, item_min, item_max).
SPAWN_TABLE = {
0: (3, 4, 2, 3),
1: (3, 4, 2, 3),
2: (4, 6, 2, 3),
3: (4, 6, 2, 3),
4: (5, 7, 3, 4),
5: (5, 7, 3, 4),
6: (6, 8, 3, 4),
7: (6, 8, 3, 4),
8: (7, 9, 4, 5),
9: (0, 0, 2, 2), # boss arena: no enemies, two healing potions
}
-83
View File
@@ -1,83 +0,0 @@
"""Enemy roster — the authoritative stats for every monster kind.
Each entry is a plain dict consumed by ``entities.enemy.make_enemy``. Values
mirror plan.md's Enemy Roster exactly; do not renumber them without updating
both the plan and ``tests/smoke.py``.
Per-kind keys:
name, hp, power, armor, speed, behavior, xp (every kind)
ranged_power (skeleton_archer)
can_split (green_slime)
glyph, color (rendering hints)
"""
from __future__ import annotations
__all__ = ["ENEMIES", "ENEMY_FLOORS"]
ENEMIES: dict[str, dict] = {
"rat": {
"name": "Rat",
"hp": 8, "power": 3, "armor": 0, "speed": 1,
"behavior": "wander", "xp": 5,
"glyph": "r", "color": (150, 100, 50),
},
"goblin": {
"name": "Goblin",
"hp": 15, "power": 5, "armor": 1, "speed": 1,
"behavior": "chase", "xp": 12,
"glyph": "g", "color": (70, 180, 80),
},
"skeleton_archer": {
"name": "Skeleton Archer",
"hp": 12, "power": 4, "ranged_power": 6,
"armor": 1, "speed": 1,
"behavior": "ranged", "xp": 15,
"glyph": "s", "color": (210, 210, 210),
},
"orc_warrior": {
"name": "Orc Warrior",
"hp": 30, "power": 8, "armor": 3, "speed": 1,
"behavior": "flee", "xp": 25,
"glyph": "o", "color": (140, 40, 40),
},
"wraith": {
"name": "Wraith",
"hp": 20, "power": 10, "armor": 0, "speed": 2,
"behavior": "phase", "xp": 30,
"glyph": "w", "color": (160, 90, 210),
},
"green_slime": {
"name": "Green Slime",
"hp": 18, "power": 5, "armor": 1, "speed": 1,
"behavior": "split", "xp": 18, "can_split": True,
"glyph": "j", "color": (100, 220, 100),
},
"ancient_dragon": {
"name": "Ancient Dragon",
"hp": 120, "power": 15, "armor": 8, "speed": 1,
"behavior": "chase", "xp": 200,
"glyph": "D", "color": (235, 50, 50),
},
"small_slime": {
"name": "Small Slime",
"hp": 9, "power": 3, "armor": 1, "speed": 1,
"behavior": "wander", "xp": 6,
"glyph": "i", "color": (130, 230, 130),
},
}
# Inclusive (min_floor, max_floor) window each kind may spawn on, per plan.md's
# "Floors" column. ``small_slime`` is only ever produced by a green-slime split
# (never placed directly), so its window is the full descent; ``ancient_dragon``
# is the floor-9 boss and never appears elsewhere.
ENEMY_FLOORS: dict[str, tuple[int, int]] = {
"rat": (0, 3),
"goblin": (0, 5),
"skeleton_archer": (2, 7),
"orc_warrior": (3, 8),
"green_slime": (4, 8),
"wraith": (5, 8),
"ancient_dragon": (9, 9),
"small_slime": (0, 9),
}
-138
View File
@@ -1,138 +0,0 @@
"""Item catalog — every base-game item, its category, stats and effect.
Each entry is a plain dict consumed by ``entities.item.make_item``. Keys:
category : one of "weapon" | "armor" | "potion" | "scroll"
stats : equipment bonuses applied while the item is equipped
(weapons/armor). E.g. {"power": 4} or {"armor": 7, "evasion": -0.10}.
effect : what happens when the item is consumed (potion) or read (scroll).
Always carries a "kind" tag the player methods dispatch on.
Glyphs/colors default by category in ``make_item``; entries may override.
"""
from __future__ import annotations
import random as _random
from typing import Optional
__all__ = ["ITEMS", "CATEGORIES", "ITEM_BY_FLOOR"]
CATEGORIES = ("weapon", "armor", "potion", "scroll")
ITEMS: dict[str, dict] = {
# --- weapons (power, occasionally a crit tweak) ----------------------- #
"Rusty Dagger": {
"category": "weapon",
"stats": {"power": 2},
"effect": {},
},
"Short Sword": {
"category": "weapon",
"stats": {"power": 4},
"effect": {},
},
"Battle Axe": {
"category": "weapon",
"stats": {"power": 7},
"effect": {},
},
"War Hammer": {
"category": "weapon",
"stats": {"power": 10, "crit_chance": -0.05},
"effect": {},
},
# --- armor (damage reduction, heavy armor hampers evasion) ------------ #
"Leather Armor": {
"category": "armor",
"stats": {"armor": 2},
"effect": {},
},
"Chain Mail": {
"category": "armor",
"stats": {"armor": 4},
"effect": {},
},
"Plate Armor": {
"category": "armor",
"stats": {"armor": 7, "evasion": -0.10},
"effect": {},
},
# --- potions (consumed on quaff) -------------------------------------- #
"Healing Potion": {
"category": "potion",
"stats": {},
"effect": {"kind": "heal", "amount": 30},
},
"Strength Potion": {
"category": "potion",
"stats": {},
"effect": {"kind": "strength", "power": 5, "duration": 20},
},
"Invisibility Potion": {
"category": "potion",
"stats": {},
"effect": {"kind": "invisibility", "duration": 15},
},
# --- scrolls (consumed on read) --------------------------------------- #
"Scroll of Fireball": {
"category": "scroll",
"stats": {},
"effect": {"kind": "fireball", "damage": 20, "radius": 3},
},
"Scroll of Teleport": {
"category": "scroll",
"stats": {},
"effect": {"kind": "teleport"},
},
"Scroll of Mapping": {
"category": "scroll",
"stats": {},
"effect": {"kind": "mapping"},
},
}
# Depth-scaled gear pools. Each tier lists the gear that may appear once the
# player has reached its min floor; deeper tiers supersede (but may repeat)
# shallower gear. Consumables are uniform across the whole descent.
_GEAR_TIERS = (
# (min_floor, weapons, armors)
(0, ["Rusty Dagger", "Short Sword"], ["Leather Armor"]),
(3, ["Short Sword", "Battle Axe"], ["Leather Armor", "Chain Mail"]),
(6, ["Battle Axe", "War Hammer"], ["Chain Mail", "Plate Armor"]),
)
_CONSUMABLES = [
"Healing Potion",
"Strength Potion",
"Invisibility Potion",
"Scroll of Fireball",
"Scroll of Teleport",
"Scroll of Mapping",
]
def _tier_pool(floor_index: int, kind: str) -> list[str]:
"""Return the depth-appropriate weapon/armor pool for ``floor_index``."""
pool: list[str] = []
for min_floor, weapons, armors in _GEAR_TIERS:
if floor_index >= min_floor:
pool = weapons if kind == "weapon" else armors
return pool
def ITEM_BY_FLOOR(floor_index: int, rng: Optional[random.Random] = None) -> str:
"""Pick a random item name, depth-scaled.
Weapons and armor improve with depth (a Rusty Dagger won't spawn on floor 7);
potions and scrolls are uniform across every floor. Roughly half of all
drops are consumables so the player always has a supply of tools.
"""
r = rng if rng is not None else _random
if r.random() < 0.5 or not _GEAR_TIERS:
return r.choice(_CONSUMABLES)
if r.random() < 0.5:
pool = _tier_pool(floor_index, "weapon")
else:
pool = _tier_pool(floor_index, "armor")
if not pool:
return r.choice(_CONSUMABLES)
return r.choice(pool)