(Underdepths) Prepare for final pass

This commit is contained in:
AlexKucera committed 2026-08-14 09:56:00 +02:00
1 parent 2eb2a44fa9
commit ef28a370fd
53 files changed
-5020

No files matched your search

View File
Whitespace-only changes.
-126
View File
@@ -1,126 +0,0 @@
"""Tuning constants, palettes, and progression tables for Underdepths.
No magic numbers in game logic — everything tunable lives here.
"""
from __future__ import annotations
# --- viewport / grid -------------------------------------------------------
TILE: int = 20
MAP_W: int = 80
MAP_H: int = 50
SIGHT_RADIUS: int = 8
FLOOR_COUNT: int = 10
# --- dungeon generation ----------------------------------------------------
ROOM_MIN_W: int = 4
ROOM_MIN_H: int = 4
ROOM_MAX_W: int = 10
ROOM_MAX_H: int = 8
BSP_MIN_HALF: int = 12 # min half-axis before a region may split
BSP_LEAVES_MIN: int = 6
BSP_LEAVES_MAX: int = 10
BOSS_ROOM_W: int = 20
BOSS_ROOM_H: int = 15
WALL: int = 0
FLOOR: int = 1
# --- player base stats (plan.md Core Data Model) ---------------------------
PLAYER_BASE: dict = {
"hp": 50,
"max_hp": 50,
"power": 4,
"armor": 0,
"accuracy": 5,
"evasion": 2,
"crit_chance": 0.10,
"speed": 1,
}
# --- leveling: (cumulative_xp_to_next_level, hp_gain, power_gain) ----------
LEVEL_TABLE: list[tuple[int, int, int]] = [
(30, 10, 1),
(70, 10, 1),
(140, 10, 1),
(250, 10, 1),
(400, 15, 2),
(600, 15, 2),
(850, 15, 2),
(1150, 15, 2),
(1500, 20, 3),
]
LEVEL_CAP: int = 10
POTION_HEAL: int = 30
STRENGTH_POTION_POWER: int = 5
# --- named colors (plan.md Colors & viewport) ------------------------------
COLORS: dict = {
"bg": (8, 7, 10),
"wall_visible": (66, 66, 80),
"wall_top": (96, 96, 112),
"wall_explored": (44, 48, 64), # remembered walls: visible dark blue-gray
"floor_visible": (72, 62, 50),
"floor_explored": (36, 40, 56), # remembered floors: visible dark blue-gray
"stairs": (245, 215, 70),
"player": (235, 235, 235),
"rat": (140, 100, 70),
"goblin": (90, 160, 70),
"skeleton_archer": (210, 210, 200),
"orc_warrior": (150, 50, 50),
"wraith": (150, 90, 200),
"green_slime": (120, 200, 90),
"ancient_dragon": (200, 60, 50),
"item_weapon": (240, 200, 80),
"item_armor": (90, 140, 220),
"item_potion": (220, 80, 80),
"item_scroll": (90, 220, 220),
"hp_full": (80, 200, 80),
"hp_empty": (60, 30, 30),
"xp_bar": (90, 160, 230),
"panel": (18, 16, 22),
"panel_border": (90, 85, 110),
"text": (220, 220, 220),
"text_dim": (150, 145, 140),
"shadow": (0, 0, 0),
"heart": (224, 64, 74), # HP heart icon
"star": (255, 214, 92), # XP / level star icon
"log_bad": (236, 96, 96), # damage / death log
"log_good": (120, 222, 116), # level-up / victory log
"empty_slot": (52, 50, 64),
}
# --- single-char palette keys for procedural pixel-art grids (render layer) -
PALETTE: dict = {
".": None, # transparent
" ": None,
"K": (16, 14, 20), # darkest outline
"k": (40, 36, 46), # outline shade
"W": (60, 60, 70), # wall base
"w": (82, 82, 96), # wall highlight (top edge)
"e": (30, 30, 35), # explored wall
"F": (40, 35, 30), # floor base
"f": (54, 48, 41), # floor fleck
"E": (20, 18, 15), # explored floor
"s": (245, 215, 70), # stairs / yellow glow
"y": (240, 200, 80), # yellow accent (weapons)
"b": (90, 140, 220), # blue accent (armor)
"r": (200, 60, 50), # red accent (dragon / potions)
"g": (90, 200, 90), # green accent (goblin / slime)
"p": (150, 90, 200), # purple accent (wraith)
"c": (210, 210, 200), # bone white (skeleton)
"C": (90, 220, 220), # cyan accent (scrolls)
"G": (172, 178, 190), # steel (weapon blades)
"o": (140, 100, 70), # brown (rat)
"n": (150, 50, 50), # dark red (orc)
"h": (235, 235, 235), # light / player highlight
"H": (180, 60, 60), # blood / damage flash
"q": (170, 245, 245), # eerie glow (skeleton eye sockets)
}
# --- combat tuning (plan.md Systems) ---------------------------------------
HIT_BASE: float = 0.70
HIT_PER_POINT: float = 0.05
HIT_FLOOR: float = 0.10
HIT_CEIL: float = 0.95
# --- persistence ----------------------------------------------------------------
SAVE_FILE: str = "save.json"
-60
View File
@@ -1,60 +0,0 @@
"""Enemy roster per plan.md Enemy Roster + factory."""
from __future__ import annotations
from entities.enemy import Enemy
# Each entry is the full stat block. ``power`` is melee power; ranged enemies
# also carry ``ranged_power`` (read by the ranged AI). green_slime.can_split is
# True so its death spawns two Small Slimes; small_slime never splits.
ENEMY_DEFS: dict[str, dict] = {
"rat": dict(
name="Rat", hp=8, power=3, armor=0, speed=1,
behavior="wander", xp_value=5, accuracy=4, evasion=2, crit_chance=0.0,
),
"goblin": dict(
name="Goblin", hp=15, power=5, armor=1, speed=1,
behavior="chase", xp_value=12, accuracy=4, evasion=1, crit_chance=0.0,
),
"skeleton_archer": dict(
name="Skeleton Archer", hp=12, power=4, armor=1, speed=1,
behavior="ranged", xp_value=15, accuracy=5, evasion=1, crit_chance=0.05,
ranged_power=6,
),
"orc_warrior": dict(
name="Orc Warrior", hp=30, power=8, armor=3, speed=1,
behavior="flee", xp_value=25, accuracy=4, evasion=0, crit_chance=0.0,
),
"wraith": dict(
name="Wraith", hp=20, power=10, armor=0, speed=2,
behavior="phase", xp_value=30, accuracy=5, evasion=3, crit_chance=0.10,
),
"green_slime": dict(
name="Green Slime", hp=18, power=5, armor=1, speed=1,
behavior="split", xp_value=18, accuracy=4, evasion=0, crit_chance=0.0,
can_split=True,
),
"ancient_dragon": dict(
name="Ancient Dragon", hp=120, power=15, armor=8, speed=1,
behavior="chase", xp_value=200, accuracy=6, evasion=0, crit_chance=0.15,
),
"small_slime": dict(
name="Small Slime", hp=9, power=3, armor=0, speed=1,
behavior="chase", xp_value=9, accuracy=4, evasion=0, crit_chance=0.0,
can_split=False,
),
}
def make_enemy(kind: str, x: int, y: int) -> Enemy:
d = ENEMY_DEFS[kind]
return Enemy(
x=x, y=y, kind=kind, name=d["name"],
hp=d["hp"], max_hp=d["hp"],
power=d["power"], armor=d["armor"],
accuracy=d["accuracy"], evasion=d["evasion"],
crit_chance=d["crit_chance"], speed=d["speed"],
behavior=d["behavior"], xp_value=d["xp_value"],
last_known_pos=None, can_split=d.get("can_split", False),
ranged_power=d.get("ranged_power", 0),
sprite_key=kind,
)
-31
View File
@@ -1,31 +0,0 @@
"""Item catalog per plan.md Item catalog + factory."""
from __future__ import annotations
from entities.item import Item
# stats keys: weapons -> power (+opt crit_chance/evasion mods); armor -> armor
# (+opt evasion mod); potions/scrolls -> effect payload consumed by actions.
ITEM_DEFS: dict[str, dict] = {
"rusty_dagger": dict(name="Rusty Dagger", category="weapon", stats={"power": 2}),
"short_sword": dict(name="Short Sword", category="weapon", stats={"power": 4}),
"battle_axe": dict(name="Battle Axe", category="weapon", stats={"power": 7}),
"war_hammer": dict(name="War Hammer", category="weapon", stats={"power": 10, "crit_chance": -0.05}),
"leather_armor": dict(name="Leather Armor", category="armor", stats={"armor": 2}),
"chain_mail": dict(name="Chain Mail", category="armor", stats={"armor": 4}),
"plate_armor": dict(name="Plate Armor", category="armor", stats={"armor": 7, "evasion": -0.10}),
"healing_potion": dict(name="Healing Potion", category="potion", stats={"effect": "heal", "amount": 30}),
"strength_potion": dict(name="Strength Potion", category="potion", stats={"effect": "strength", "power": 5, "duration": 20}),
"invisibility_potion":dict(name="Invisibility Potion",category="potion",stats={"effect": "invisibility", "duration": 15}),
"fireball_scroll": dict(name="Scroll of Fireball",category="scroll", stats={"effect": "fireball", "damage": 20, "radius": 3}),
"teleport_scroll": dict(name="Scroll of Teleport",category="scroll", stats={"effect": "teleport"}),
"mapping_scroll": dict(name="Scroll of Mapping", category="scroll", stats={"effect": "mapping"}),
}
def make_item(kind: str, x: int, y: int) -> Item:
d = ITEM_DEFS[kind]
return Item(
x=x, y=y, kind=kind, name=d["name"],
category=d["category"], stats=dict(d["stats"]),
sprite_key=kind,
)
-311
View File
@@ -1,311 +0,0 @@
"""Procedural pixel-art grids: 2D arrays of single-char palette keys.
``render/sprites.get_sprite`` rasterizes a grid to a cached Surface, mapping each
char to a color from ``data.constants.PALETTE``. ``.``/space = transparent. The
marker char ``a`` is an item accent replaced at raster time by a per-kind tint
(``TINTS``), so one category shape recolors into distinct items. Rows may be
ragged; the rasterizer pads short rows with transparency.
"""
from __future__ import annotations
# Palette keys (see data.constants.PALETTE):
# . space = transparent K = darkest outline k = outline shade
# h = light/white s = stairs yellow y = yellow b = blue
# r = red g = green p = purple c = bone white o = brown n = dark red
# H = blood/damage a = item accent (tinted per kind)
GRIDS: dict[str, list[str]] = {
# ---- stairs: glowing yellow descending staircase (3 steps down-right) ----
"stairs": [
"..............",
".KKKKKK.......",
".KyyyyyK......",
".KsssssK......",
".KKKKKKK......",
"....KKKKKK....",
"....KyyyyyK...",
"....KsssssK...",
"....KKKKKKK...",
".......KKKKKK.",
".......KyyyyyK",
".......KsssssK",
".......KKKKKKK",
"..............",
"..............",
],
# ---- player: hooded adventurer, blue cloak, steel highlight ----
"player": [
"....KKKK....",
"...KhKKhk...",
"..KhhhhhhK..",
"..KhccccKh..",
"..KhhhhhhK..",
".KbbbbbbbbK.",
".KbhbbbbhbK.",
".KbbbbbbbbK.",
".KbbbbbbbbK.",
".KbbKKKKbbK.",
".KbK....KbK.",
".KK......KK.",
"............",
"............",
],
# ---- rat: small brown body, ears, pink tail ----
"rat": [
"..............",
"...KK....KK...",
"...KoK..KoK...",
"..KooooooK....",
".KooooooooK.KK",
".KoohhooooKKK.",
".KooooooooK...",
".KooooooooK...",
"..KooooooK....",
"...KooooK.....",
"....KhhK......",
"....K..K...oo.",
"...........oo.",
"..............",
],
# ---- goblin: green humanoid, pointed ears, crude blade ----
"goblin": [
"..............",
"..K.K....K.K..",
"..KgK....KgK..",
".KggggggggggK.",
".KgghhhhhggK..",
".KggKrrKggK...", # eyes/mouth
".KggggggggK...",
".KgggggggggK..",
".KgggKKKgggK..",
".KggK...KggK..",
".KgK.....KgK..",
".KK.......KK..",
".....yy.......", # crude blade
".....yy.......",
],
# ---- skeleton archer: thin bones, ribcage, drawn bow + quiver, glowing eyes ----
"skeleton_archer": [
"..............",
".....KKKK.....",
"....KccccK....",
"....KqccqK....", # glowing eye sockets
"....KccccK....",
"....KchhcK....", # cheek bones
".....KKKK.....", # teeth
"y...KccccK..o.", # quiver fletch | shoulders | bow tip
"yo..KcKKcK.o..", # ribs + bow limb
"yo..KcKKcKo...", # bow belly (closest to body)
"yo..KcKKcKo...",
"yo..KcKKcK.o..",
"yo..KcKKcK..o.", # bow tip
"y...KcKKcK...o",
"....KK..KK....", # pelvis
"....Kc..cK....", # thin bony legs
],
# ---- orc warrior: broad hulking brute, plate pauldrons, tusks, big blade ----
"orc_warrior": [
"..............",
".....KKKK.....",
"....KnnnnK....",
"....KHnnHK....", # red eyes / heavy brow
"....KnnnnK....",
"...hKnnnnKh...", # jutting tusks
"..KnnnnnnnnK..", # thick neck
"KKnnnnnnnnnnKK", # massive plate shoulders
"KnhhnnnnnnhhnK", # pauldron highlights
"KnnnnnnnnnnnnK", # broad chest
".KKnnnyynnnKK.", # fists + yellow crossguard
"..KnGGGGGGnK..", # big steel blade
"..KnhGGGGhnK..", # blade bright edge
"...KKGGGKK....", # heavy blade tip
"...KKK..KKK...", # legs
"...KK....KK...", # feet
],
# ---- wraith: translucent purple wisps, tattered cloak, no legs ----
"wraith": [
"..............",
".....KKKK.....",
"....KppppK....",
"...KppppppK...",
"...KpHHppK....", # glowing eyes
"...KpppppK....",
"..KpppppppK...",
".KpppppppppK..",
".KpKpKpKpKpK..", # tattered hem
"KpK.pK.pK.pK..",
"p.p..p...p..p.",
"..............",
"..............",
"..............",
],
# ---- green slime: big glossy domed blob, highlight, googly eyes, drip ----
"green_slime": [
"..............",
"...KKKKKKKK...",
"..KggggggggK..",
".KgghhhhgggK..", # glossy top-left highlight
".KghhKKhhggK..", # sheen
"KgggggggggggK.",
"KgghKggKhgggK.", # two googly eyes
"KgggggggggggK.",
"KgggggggggggK.",
".KgggggggggK..",
".KgggggggggK..",
"..KKKKKKKKKK..", # flat bottom (squished on ground)
".....g........", # drip
"....gg........",
".....g........",
"..............",
],
# ---- small slime: smaller cuter variant ----
"small_slime": [
"..............",
"..............",
"..............",
"....KKKKKK....",
"...KggggggK...",
"..KggHHggggK..",
"..KgghhggggK..",
"..KggggggggK..",
"..KggggggggK..",
"...KKKKKKKK...",
".....g........",
"..............",
"..............",
"..............",
],
# ---- ancient dragon: large red boss, horns, wings, fangs ----
"ancient_dragon": [
"K............K",
"KK..........KK",
".KrK......KrK.", # wing tips
"KrrrK....KrrrK",
"KrrrrKKKKrrrrK",
".KrrrrrrrrrrK.", # horns sweep
"..KHHrrrrHHK..", # eyes
"..KrrrrrrrrK...",
"..KrKnnnrKrK...", # fanged maw
".KrrrrrrrrrrK..",
"KrrKrrrrrrKrrK.",
"KrK..KrrK..KrK.",
"K.....KK.....K.",
"..............",
],
}
# ---- item category base shapes; the 'a' marker is tinted per kind (TINTS) ----
GRIDS["_weapon"] = [
"......Kh......", # pointed tip
".....KhaK.....", # blade (a = per-kind tint) w/ bright edge (h)
".....Khaa.....",
"....Khaaa.....",
"....KhaaK.....",
"...Khaaaa.....",
"...KhaaaK.....",
"..Khaaaaa.....",
"..KhaaaaK.....",
".Khaaaaaa.....",
".KhaaaaaK.....",
"KKyyyyyyyyyKK.", # wide yellow crossguard
"...KaaaaK.....", # grip
"...KaaaaK.....",
"...KaaaaK.....",
"....KyyK......", # pommel
]
GRIDS["_armor"] = [
"...KKKKKKKK...", # shield top
"..KaaaaaaaaK..",
".KaahhaaaaaaK.", # top-left highlight
".KaahbhaaaaaK.", # blue boss
"KaaabbbaaaaaK.", # blue cross (steel rim accents)
"KaaabbbaaaaaK.",
"KaaaabbbaaaK..",
"KaaaaaaaaaK...",
".KaaaaaaK.....",
"..KaaaaK......",
"...KaaK.......",
"....KK........", # point
"..............",
"..............",
"..............",
"..............",
]
GRIDS["_potion"] = [
".....KKKK.....", # neck
"....KooooK....", # cork
"....KKKKKK....", # shoulder
"..KKaaaaaaKK..",
".KaaaaaaaaaaK.",
".KaahaaaaaaaK.", # glass highlight
"KaaaaaaaaaaaK.", # round bulb (a = per-kind liquid)
"KaaaaaaaaaaaK.",
"KaaaaaaaaaaaK.",
"KaaaaaaaaaaaK.",
".KaaaaaaaaaK..",
".KaaaaaaaaaK..",
"..KKaaaaaKK...", # base
"..............",
"..............",
"..............",
]
GRIDS["_scroll"] = [
"..............",
".KhC......ChK.", # rolled end caps (top)
"KhCk......kChK", # cylindrical rolls: bright rim (h) + dark core (k)
"KhCkCCCCCCkChK", # flat paper between the rolls
"KhCkChCCCCkChK", # ruled line
"KhCkaaaaaakChK", # ribbon tie (a = per-kind tint)
"KhCkaaaaaakChK",
"KhCkCCChCCkChK", # ruled line
"KhCkCCCCCCkChK",
"KhCkCCCCCCkChK",
"KhCk......kChK", # rolls
".KhC......ChK.", # rolled end caps (bottom)
"..............",
"..............",
"..............",
"..............",
]
# Point every item kind at its category base shape (shared list, read-only).
_WEAPON_KINDS = ("rusty_dagger", "short_sword", "battle_axe", "war_hammer")
_ARMOR_KINDS = ("leather_armor", "chain_mail", "plate_armor")
_POTION_KINDS = ("healing_potion", "strength_potion", "invisibility_potion")
_SCROLL_KINDS = ("fireball_scroll", "teleport_scroll", "mapping_scroll")
for _k in _WEAPON_KINDS:
GRIDS[_k] = GRIDS["_weapon"]
for _k in _ARMOR_KINDS:
GRIDS[_k] = GRIDS["_armor"]
for _k in _POTION_KINDS:
GRIDS[_k] = GRIDS["_potion"]
for _k in _SCROLL_KINDS:
GRIDS[_k] = GRIDS["_scroll"]
# Per-kind accent tint applied to the 'a' marker (category hue + per-kind flavor).
TINTS: dict[str, tuple[int, int, int]] = {
"rusty_dagger": (170, 130, 80),
"short_sword": (210, 215, 225),
"battle_axe": (150, 155, 165),
"war_hammer": (120, 115, 130),
"leather_armor": (150, 110, 60),
"chain_armor": (120, 130, 145),
"chain_mail": (120, 130, 145),
"plate_armor": (170, 175, 190),
"healing_potion": (220, 80, 80),
"strength_potion": (230, 150, 60),
"invisibility_potion": (200, 160, 220),
"fireball_scroll": (240, 150, 60),
"teleport_scroll": (150, 120, 220),
"mapping_scroll": (90, 220, 220),
}