Fix critical bug in Combat.tsx: message split was using escaped backslash instead of newline
This commit is contained in:
@@ -600,7 +600,7 @@ async def npc_attack(player_id: int, combat: dict, npc_def, reduce_armor_func) -
|
|||||||
actual_damage = max(1, npc_damage - armor_absorbed)
|
actual_damage = max(1, npc_damage - armor_absorbed)
|
||||||
new_player_hp = max(0, player['hp'] - actual_damage)
|
new_player_hp = max(0, player['hp'] - actual_damage)
|
||||||
|
|
||||||
message += create_combat_message("enemy_attack", origin="enemy", npc_name=npc_def.name, damage=npc_damage, armor_absorbed=armor_absorbed)
|
message += f"{get_locale_string(npc_def.name)} attacks for {npc_damage} damage!"
|
||||||
if armor_absorbed > 0:
|
if armor_absorbed > 0:
|
||||||
message += f" (Armor absorbed {armor_absorbed})"
|
message += f" (Armor absorbed {armor_absorbed})"
|
||||||
|
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ async def combat_action(
|
|||||||
else:
|
else:
|
||||||
# Apply damage to NPC
|
# Apply damage to NPC
|
||||||
new_npc_hp = max(0, combat['npc_hp'] - damage)
|
new_npc_hp = max(0, combat['npc_hp'] - damage)
|
||||||
result_message = create_combat_message("player_attack", origin="player", damage=damage)
|
result_message = f"You attack for {damage} damage! "
|
||||||
|
|
||||||
# Apply weapon effects
|
# Apply weapon effects
|
||||||
if weapon_effects and 'bleeding' in weapon_effects:
|
if weapon_effects and 'bleeding' in weapon_effects:
|
||||||
@@ -304,7 +304,7 @@ async def combat_action(
|
|||||||
|
|
||||||
if new_npc_hp <= 0:
|
if new_npc_hp <= 0:
|
||||||
# NPC defeated
|
# NPC defeated
|
||||||
result_message += "\n" + create_combat_message("victory", origin="neutral", npc_name=npc_def.name)
|
result_message += f"Victory! Defeated {get_locale_string(npc_def.name)}"
|
||||||
combat_over = True
|
combat_over = True
|
||||||
player_won = True
|
player_won = True
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@ async def combat_action(
|
|||||||
# Failed to flee, NPC attacks
|
# Failed to flee, NPC attacks
|
||||||
npc_damage = random.randint(npc_def.damage_min, npc_def.damage_max)
|
npc_damage = random.randint(npc_def.damage_min, npc_def.damage_max)
|
||||||
new_player_hp = max(0, player['hp'] - npc_damage)
|
new_player_hp = max(0, player['hp'] - npc_damage)
|
||||||
result_message = create_combat_message("flee_fail", origin="enemy", npc_name=npc_def.name, damage=npc_damage)
|
result_message = f"Failed to flee! {get_locale_string(npc_def.name)} attacks for {npc_damage} damage!"
|
||||||
|
|
||||||
if new_player_hp <= 0:
|
if new_player_hp <= 0:
|
||||||
result_message += "\nYou have been defeated!"
|
result_message += "\nYou have been defeated!"
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ const Combat = ({
|
|||||||
const timeStr = now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' })
|
const timeStr = now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' })
|
||||||
|
|
||||||
// Parse message into structured parts
|
// Parse message into structured parts
|
||||||
const messages = data.message.split('\\n').filter((m: string) => m.trim())
|
const messages = data.message.split('\n').filter((m: string) => m.trim())
|
||||||
|
|
||||||
const playerMessages: any[] = []
|
const playerMessages: any[] = []
|
||||||
const enemyMessages: any[] = []
|
const enemyMessages: any[] = []
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ function CombatView({
|
|||||||
return (
|
return (
|
||||||
<div className="combat-view">
|
<div className="combat-view">
|
||||||
<div className="combat-header-inline">
|
<div className="combat-header-inline">
|
||||||
<h2>
|
<h2 style={{ background: 'linear-gradient(90deg, #4CAF50, #2196F3)', padding: '0.5rem', borderRadius: '8px' }}>
|
||||||
{combatState.is_pvp ? `⚔️ ${t('combat.title')} - PvP` : `⚔️ ${t('combat.title')} - ${displayEnemyName}`}
|
🆕 NEW COMBAT - {combatState.is_pvp ? `⚔️ ${t('combat.title')} - PvP` : `⚔️ ${t('combat.title')} - ${displayEnemyName}`}
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user