Sesión 15: Implementación de Inventario y lógica de evento de Rastrillo/Llave
This commit is contained in:
@@ -42,6 +42,18 @@ export class CombatSystem {
|
||||
// 3. Update State
|
||||
attacker.hasAttacked = true;
|
||||
|
||||
// Award Gold if hero killed monster
|
||||
if (result.defenderDied && attacker.type === 'hero') {
|
||||
const goldValue = (defender.stats && defender.stats.gold) || 0;
|
||||
if (goldValue > 0) {
|
||||
attacker.stats.gold = (attacker.stats.gold || 0) + goldValue;
|
||||
if (this.game.onEntityUpdate) this.game.onEntityUpdate(attacker);
|
||||
if (this.game.onShowMessage) {
|
||||
this.game.onShowMessage("Botín", `¡Has derrotado a ${defender.name}! Recibes ${goldValue} Oro.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Side Effects (Sound, UI Events)
|
||||
if (window.SOUND_MANAGER) {
|
||||
// Logic to choose sound could be expanded here based on Weapon Type
|
||||
@@ -87,6 +99,18 @@ export class CombatSystem {
|
||||
// 3. Update State
|
||||
attacker.hasAttacked = true;
|
||||
|
||||
// Award Gold if hero killed monster
|
||||
if (result.defenderDied && attacker.type === 'hero') {
|
||||
const goldValue = (defender.stats && defender.stats.gold) || 0;
|
||||
if (goldValue > 0) {
|
||||
attacker.stats.gold = (attacker.stats.gold || 0) + goldValue;
|
||||
if (this.game.onEntityUpdate) this.game.onEntityUpdate(attacker);
|
||||
if (this.game.onShowMessage) {
|
||||
this.game.onShowMessage("Botín", `¡Has derrotado a ${defender.name}! Recibes ${goldValue} Oro.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Side Effects
|
||||
if (window.SOUND_MANAGER) {
|
||||
window.SOUND_MANAGER.playSound('arrow');
|
||||
|
||||
Reference in New Issue
Block a user