mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-22 03:38:03 +00:00
Implement core hostile NPC combat system infrastructure: - Add #hostile tag handler to chat-helpers.js for Ink integration - Fix security-guard.ink to use proper hub pattern with -> hub instead of -> END - Add #hostile:security_guard tags to hostile conversation paths - Create combat configuration system (combat-config.js) - Create combat event constants (combat-events.js) - Implement player health tracking system with HP and KO state - Implement NPC hostile state management with HP tracking - Add combat debug utilities for testing - Add error handling utilities for validation - Integrate combat systems into game.js create() method - Create test-hostile.ink for testing hostile tag system This establishes the foundation for hostile NPC behavior, allowing NPCs to become hostile through Ink dialogue and tracking health for both player and NPCs.
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
/**
|
|
* Error handling utilities for combat system
|
|
*/
|
|
|
|
export function validateNumber(value, name, min = -Infinity, max = Infinity) {
|
|
if (typeof value !== 'number' || isNaN(value)) {
|
|
console.error(`${name} must be a valid number, got:`, value);
|
|
return false;
|
|
}
|
|
if (value < min || value > max) {
|
|
console.error(`${name} must be between ${min} and ${max}, got:`, value);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
export function validateNPCId(npcId) {
|
|
if (!npcId || typeof npcId !== 'string') {
|
|
console.error('Invalid NPC ID:', npcId);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
export function validateNPCExists(npcId) {
|
|
if (!validateNPCId(npcId)) return false;
|
|
|
|
if (!window.npcManager) {
|
|
console.error('NPC Manager not initialized');
|
|
return false;
|
|
}
|
|
|
|
const npc = window.npcManager.getNPC(npcId);
|
|
if (!npc) {
|
|
console.error(`NPC not found: ${npcId}`);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
export function validateSystem(systemName, windowProperty) {
|
|
if (!window[windowProperty]) {
|
|
console.error(`${systemName} not initialized (window.${windowProperty} is undefined)`);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
export function logCombatError(context, error) {
|
|
console.error(`[Combat Error] ${context}:`, error);
|
|
}
|
|
|
|
export function logCombatWarning(context, message) {
|
|
console.warn(`[Combat Warning] ${context}:`, message);
|
|
}
|