(Underdepths) Prepare for Pass 2

This commit is contained in:
AlexKucera committed 2026-08-12 15:59:16 +02:00
1 parent 0b20f1ae53
commit 8259ca8ddf
34 files changed
+61 -3569

No files matched your search

-141
View File
@@ -1,141 +0,0 @@
from __future__ import annotations
MAP_WIDTH = 80
MAP_HEIGHT = 50
FLOOR_COUNT = 10
TILE_WALL = 0
TILE_FLOOR = 1
FOV_RADIUS = 8
BSP_MIN_SPLITS = 5
BSP_MAX_SPLITS = 8
ROOM_MIN_WIDTH = 4
ROOM_MAX_WIDTH = 10
ROOM_MIN_HEIGHT = 4
ROOM_MAX_HEIGHT = 8
ROOM_MARGIN = 1
TILE_SIZE = 16
VIEWPORT_WIDTH = 50
VIEWPORT_HEIGHT = 30
FPS = 60
WALL_COLOR = (60, 60, 70)
FLOOR_COLOR = (40, 35, 30)
PLAYER_COLOR = (255, 255, 255)
STAIRS_COLOR = (255, 220, 40)
BACKGROUND_COLOR = (0, 0, 0)
PLAYER_GLYPH = "@"
STAIRS_GLYPH = ">"
PLAYER_MAX_HP = 50
PLAYER_POWER = 4
PLAYER_ARMOR = 0
PLAYER_ACCURACY = 5
PLAYER_EVASION = 2
PLAYER_CRIT_CHANCE = 0.10
PLAYER_SPEED = 1
INVENTORY_CAPACITY = 26
HEALING_AMOUNT = 30
STRENGTH_BONUS = 5
STRENGTH_DURATION = 20
INVISIBILITY_DURATION = 15
FIREBALL_DAMAGE = 20
FIREBALL_RADIUS = 3
LEVEL_THRESHOLDS = (30, 70, 140, 250, 400, 600, 850, 1150, 1500)
LEVEL_HP_GAINS = (10, 10, 10, 10, 15, 15, 15, 15, 20)
LEVEL_POWER_GAINS = (1, 1, 1, 1, 2, 2, 2, 2, 3)
ENEMY_ACCURACY = 3
ENEMY_EVASION = 0
ENEMY_CRIT_CHANCE = 0.05
DRAGON_BREATH_DAMAGE = 15
DRAGON_BREATH_INTERVAL = 3
FLOOR_SPAWN_COUNTS = (
(3, 4, 2, 3),
(3, 4, 2, 3),
(4, 6, 2, 3),
(4, 6, 2, 3),
(5, 7, 3, 4),
(5, 7, 3, 4),
(6, 8, 3, 4),
(6, 8, 3, 4),
(7, 9, 4, 5),
)
BOSS_FLOOR = 9
BOSS_ARENA_WIDTH = 20
BOSS_ARENA_HEIGHT = 15
BOSS_HEALING_POTIONS = 2
HIT_BASE_CHANCE = 0.7
HIT_ACCURACY_SCALE = 0.05
HIT_MIN_CHANCE = 0.1
HIT_MAX_CHANCE = 0.95
CRITICAL_DAMAGE_MULTIPLIER = 2
CARDINAL_DIRECTIONS = ((0, -1), (-1, 0), (1, 0), (0, 1))
AI_WAIT_CHANCE = 0.5
AI_FLEE_HP_RATIO = 0.30
AI_RANGED_KITE_DISTANCE = 2
AI_RANGED_ATTACK_DISTANCE = 3
AI_RANGED_DISTANCE_PENALTY = 0.05
MESSAGE_LOG_LIMIT = 50
GAME_STATE_PLAYING = "playing"
GAME_STATE_DEAD = "dead"
GAME_TITLE = "Underdepths"
GAME_STATE_VICTORY = "victory"
SAVE_FILENAME = "save.json"
GAME_STATE_MENU = "menu"
GAME_STATE_SAVED = "saved"
TOP_PANEL_HEIGHT = 48
RIGHT_PANEL_WIDTH = 320
BOTTOM_PANEL_HEIGHT = 56
WINDOW_WIDTH = VIEWPORT_WIDTH * TILE_SIZE + RIGHT_PANEL_WIDTH
WINDOW_HEIGHT = TOP_PANEL_HEIGHT + VIEWPORT_HEIGHT * TILE_SIZE + BOTTOM_PANEL_HEIGHT
EXPLORED_WALL_COLOR = (30, 30, 35)
EXPLORED_FLOOR_COLOR = (20, 18, 15)
UI_BACKGROUND_COLOR = (12, 12, 16)
UI_PANEL_COLOR = (24, 24, 30)
UI_BORDER_COLOR = (75, 75, 90)
UI_TEXT_COLOR = (225, 225, 230)
UI_MUTED_COLOR = (145, 145, 155)
UI_HEALTH_COLOR = (55, 190, 75)
UI_HEALTH_MISSING_COLOR = (110, 35, 35)
UI_XP_COLOR = (70, 125, 220)
UI_ITEM_COLOR = (235, 205, 70)
UI_DAMAGE_COLOR = (235, 75, 65)
UI_LEVEL_COLOR = (80, 220, 110)
UI_OVERLAY_COLOR = (16, 16, 22)
UI_PADDING = 12
UI_LINE_HEIGHT = 22
UI_BAR_HEIGHT = 16
UI_SMALL_FONT_SIZE = 18
UI_FONT_SIZE = 22
UI_TITLE_FONT_SIZE = 40
OVERLAY_WIDTH = 600
OVERLAY_HEIGHT = 400
ENTITY_INSET = 2
ITEM_INSET = 4
MESSAGE_WRAP_WIDTH = 34
HELP_LINES = (
"Arrows / hjkl Move or melee attack",
"g Pick up item at feet",
"i Open inventory",
"e View/equip equipment",
"q Quaff a potion",
"r Read a scroll",
"> Descend stairs",
"S Save and quit",
"? Show this help",
"Esc Close or cancel",
"Arrows/letters Select; Enter confirms",
)
-72
View File
@@ -1,72 +0,0 @@
from __future__ import annotations
from dataclasses import dataclass
from collections.abc import Mapping
from types import MappingProxyType
from data.constants import ENEMY_ACCURACY, ENEMY_CRIT_CHANCE, ENEMY_EVASION
from entities.enemy import Enemy
@dataclass(frozen=True, slots=True)
class EnemyDefinition:
name: str
floors: tuple[int, int]
hp: int
power: int
armor: int
speed: int
behavior: str
xp: int
glyph: str
color: tuple[int, int, int]
ranged_power: int = 0
ENEMY_CATALOG: Mapping[str, EnemyDefinition] = MappingProxyType({
"Rat": EnemyDefinition("Rat", (0, 3), 8, 3, 0, 1, "wander", 5, "r", (140, 100, 60)),
"Goblin": EnemyDefinition("Goblin", (0, 5), 15, 5, 1, 1, "chase", 12, "g", (40, 180, 60)),
"Skeleton Archer": EnemyDefinition(
"Skeleton Archer", (2, 7), 12, 4, 1, 1, "ranged", 15, "s", (210, 210, 200), ranged_power=6
),
"Orc Warrior": EnemyDefinition(
"Orc Warrior", (3, 8), 30, 8, 3, 1, "flee", 25, "o", (150, 45, 35)
),
"Wraith": EnemyDefinition("Wraith", (5, 8), 20, 10, 0, 2, "phase", 30, "w", (150, 80, 190)),
"Green Slime": EnemyDefinition(
"Green Slime", (4, 8), 18, 5, 1, 1, "split", 18, "S", (70, 230, 70)
),
"Ancient Dragon": EnemyDefinition(
"Ancient Dragon", (9, 9), 120, 15, 8, 1, "dragon", 200, "D", (240, 40, 30)
),
})
def create_enemy(name: str, x: int, y: int) -> Enemy:
definition = ENEMY_CATALOG[name]
return Enemy(
x=x,
y=y,
glyph=definition.glyph,
color=definition.color,
name=definition.name,
hp=definition.hp,
max_hp=definition.hp,
power=definition.power,
armor=definition.armor,
accuracy=ENEMY_ACCURACY,
evasion=ENEMY_EVASION,
crit_chance=ENEMY_CRIT_CHANCE,
speed=definition.speed,
behavior=definition.behavior,
xp_reward=definition.xp,
ranged_power=definition.ranged_power,
)
def enemy_names_for_floor(floor_index: int) -> tuple[str, ...]:
return tuple(
name
for name, enemy in ENEMY_CATALOG.items()
if name != "Ancient Dragon" and enemy.floors[0] <= floor_index <= enemy.floors[1]
)
-106
View File
@@ -1,106 +0,0 @@
from __future__ import annotations
from dataclasses import dataclass
from collections.abc import Mapping
from types import MappingProxyType
from data.constants import (
FIREBALL_DAMAGE,
FIREBALL_RADIUS,
HEALING_AMOUNT,
INVISIBILITY_DURATION,
STRENGTH_BONUS,
STRENGTH_DURATION,
)
from entities.item import Item
@dataclass(frozen=True, slots=True)
class ItemDefinition:
name: str
category: str
glyph: str
color: tuple[int, int, int]
min_floor: int = 0
power_bonus: int = 0
armor_bonus: int = 0
crit_bonus: float = 0.0
evasion_bonus: float = 0.0
effect: str = ""
amount: int = 0
duration: int = 0
radius: int = 0
ITEM_CATALOG: Mapping[str, ItemDefinition] = MappingProxyType({
"Rusty Dagger": ItemDefinition("Rusty Dagger", "weapon", "/", (230, 210, 80), power_bonus=2),
"Short Sword": ItemDefinition("Short Sword", "weapon", "/", (230, 210, 80), min_floor=2, power_bonus=4),
"Battle Axe": ItemDefinition("Battle Axe", "weapon", "/", (230, 210, 80), min_floor=4, power_bonus=7),
"War Hammer": ItemDefinition(
"War Hammer", "weapon", "/", (230, 210, 80), min_floor=7, power_bonus=10, crit_bonus=-0.05
),
"Leather Armor": ItemDefinition("Leather Armor", "armor", "[", (70, 130, 230), armor_bonus=2),
"Chain Mail": ItemDefinition("Chain Mail", "armor", "[", (70, 130, 230), min_floor=3, armor_bonus=4),
"Plate Armor": ItemDefinition(
"Plate Armor", "armor", "[", (70, 130, 230), min_floor=6, armor_bonus=7, evasion_bonus=-2.0
),
"Healing Potion": ItemDefinition(
"Healing Potion", "potion", "!", (220, 50, 50), effect="healing", amount=HEALING_AMOUNT
),
"Strength Potion": ItemDefinition(
"Strength Potion",
"potion",
"!",
(220, 50, 50),
effect="strength",
amount=STRENGTH_BONUS,
duration=STRENGTH_DURATION,
),
"Invisibility Potion": ItemDefinition(
"Invisibility Potion",
"potion",
"!",
(220, 50, 50),
effect="invisibility",
duration=INVISIBILITY_DURATION,
),
"Scroll of Fireball": ItemDefinition(
"Scroll of Fireball",
"scroll",
"?",
(50, 220, 220),
effect="fireball",
amount=FIREBALL_DAMAGE,
radius=FIREBALL_RADIUS,
),
"Scroll of Teleport": ItemDefinition(
"Scroll of Teleport", "scroll", "?", (50, 220, 220), effect="teleport"
),
"Scroll of Mapping": ItemDefinition(
"Scroll of Mapping", "scroll", "?", (50, 220, 220), effect="mapping"
),
})
def create_item(name: str, x: int = 0, y: int = 0) -> Item:
definition = ITEM_CATALOG[name]
return Item(
x=x,
y=y,
glyph=definition.glyph,
color=definition.color,
name=definition.name,
category=definition.category,
power_bonus=definition.power_bonus,
armor_bonus=definition.armor_bonus,
crit_bonus=definition.crit_bonus,
evasion_bonus=definition.evasion_bonus,
effect=definition.effect,
amount=definition.amount,
duration=definition.duration,
radius=definition.radius,
)
def item_names_for_floor(floor_index: int) -> tuple[str, ...]:
return tuple(name for name, item in ITEM_CATALOG.items() if item.min_floor <= floor_index)