2130d30133
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m33s
- Fix mana conversion to deduct from regen instead of mana pool (resolves player stuck at 1 mana below cap) - Fix Spire Tab error by removing unused legacy import (store-modules/enemy-utils) - Fix Grimoire Tab error by adding Array.isArray check for effects.map - Move utility functions from legacy store-modules to utils/ to eliminate legacy dependencies - Add regression test for mana conversion fix - Update SpellsTab.tsx imports to use utils instead of legacy stores
59 lines
3.1 KiB
TypeScript
59 lines
3.1 KiB
TypeScript
// ─── Enemy Naming System ───────────────────────────────────────────────
|
|
// Moved from store-modules/enemy-utils.ts to eliminate legacy dependencies
|
|
|
|
import type { EnemyState } from '../types';
|
|
import { SWARM_CONFIG } from '../constants';
|
|
import { getFloorMaxHP, getFloorElement } from './floor-utils';
|
|
|
|
// Enemy names by element and floor tier
|
|
const ENEMY_NAMES_BY_ELEMENT: Record<string, string[]> = {
|
|
fire: ['Fire Imp', 'Flame Sprite', 'Emberling', 'Scorchling', 'Inferno Whelp'],
|
|
water: ['Water Elemental', 'Tidal Wraith', 'Aqua Sprite', 'Drowned One', 'Tsunami Spawn'],
|
|
air: ['Wind Sylph', 'Gale Rider', 'Storm Spirit', 'Zephyr Darter', 'Cyclone Wisp'],
|
|
earth: ['Stone Golem', 'Earth Elemental', 'Graveling', 'Mountain Giant', 'Terra Brute'],
|
|
light: ['Light Saint', 'Radiant Angel', 'Luminous Spirit', 'Divine Warden', 'Holy Sentinel'],
|
|
dark: ['Shadow Assassin', 'Dark Cultist', 'Umbral Fiend', 'Void Walker', 'Night Stalker'],
|
|
death: ['Skeleton Warrior', 'Zombie Lord', 'Lichling', 'Bone Reaper', 'Necrotic Wraith'],
|
|
// Special element names
|
|
lightning: ['Storm Elemental', 'Thunder Hawk', 'Lightning Eel', 'Shock Sprite', 'Voltaic Wisp'],
|
|
metal: ['Iron Golem', 'Steel Guardian', 'Rust Monster', 'Chrome Beetle', 'Mercury Spirit'],
|
|
sand: ['Sand Wraith', 'Dune Stalker', 'Desert Spirit', 'Cactus Thrasher', 'Mirage Runner'],
|
|
crystal: ['Crystal Guardian', 'Prism Sprite', 'Gem Hound', 'Diamond Golem', 'Shardling'],
|
|
stellar: ['Star Spawn', 'Cosmic Entity', 'Nova Spirit', 'Astral Watcher', 'Supernova Seed'],
|
|
void: ['Void Lord', 'Abyssal Horror', 'Entropy Spawn', 'Chaos Elemental', 'Nether Beast'],
|
|
};
|
|
|
|
// Get enemy name based on element and floor tier (1-100)
|
|
export function getEnemyName(element: string, floor: number): string {
|
|
const names = ENEMY_NAMES_BY_ELEMENT[element] || ['Unknown Entity'];
|
|
// Higher floors get "stronger" sounding names (pick from later in the list)
|
|
const tierIndex = Math.min(names.length -1, Math.floor(floor / 20));
|
|
const randomIndex = (tierIndex + Math.floor(Math.random() * (names.length - tierIndex))) % names.length;
|
|
return names[randomIndex!];
|
|
}
|
|
|
|
// Generate enemies for a swarm room
|
|
export function generateSwarmEnemies(floor: number): EnemyState[] {
|
|
const baseHP = getFloorMaxHP(floor);
|
|
const element = getFloorElement(floor);
|
|
const numEnemies = SWARM_CONFIG.minEnemies +
|
|
Math.floor(Math.random() * (SWARM_CONFIG.maxEnemies - SWARM_CONFIG.minEnemies + 1));
|
|
|
|
const enemies: EnemyState[] = [];
|
|
for (let i = 0; i < numEnemies; i++) {
|
|
const enemyName = getEnemyName(element, floor);
|
|
enemies.push({
|
|
id: `enemy_${i}`,
|
|
name: enemyName,
|
|
hp: Math.floor(baseHP * SWARM_CONFIG.hpMultiplier),
|
|
maxHP: Math.floor(baseHP * SWARM_CONFIG.hpMultiplier),
|
|
armor: SWARM_CONFIG.armorBase + Math.floor(floor / 10) * SWARM_CONFIG.armorPerFloor,
|
|
dodgeChance: 0,
|
|
healthRegen: 0, // Will be set by caller if needed
|
|
barrier: 0, // Will be set by caller if needed
|
|
element,
|
|
});
|
|
}
|
|
return enemies;
|
|
}
|