Added flamethrower with buring effects

This commit is contained in:
2026-01-30 17:49:23 +11:00
parent c06823e08b
commit 41909fd8e6
15 changed files with 706 additions and 327 deletions

View File

@@ -41,28 +41,28 @@ export class GameEventHandler {
const player = this.scene.entityAccessor.getPlayer();
if (player) {
this.scene.progressionManager.allocateStat(player, statName);
this.scene.emitUIUpdate();
}
this.scene.emitUIUpdate();
}
});
events.on("allocate-passive", (nodeId: string) => {
const player = this.scene.entityAccessor.getPlayer();
if (player) {
this.scene.progressionManager.allocatePassive(player, nodeId);
this.scene.emitUIUpdate();
}
this.scene.emitUIUpdate();
}
});
events.on("player-wait", () => {
if (!this.scene.awaitingPlayer) return;
if (this.scene.isMenuOpen || this.scene.isInventoryOpen || this.scene.dungeonRenderer.isMinimapVisible()) return;
this.scene.commitPlayerAction({ type: "wait" });
});
events.on("player-search", () => {
if (!this.scene.awaitingPlayer) return;
if (this.scene.isMenuOpen || this.scene.isInventoryOpen || this.scene.dungeonRenderer.isMinimapVisible()) return;
console.log("Player searching...");
this.scene.commitPlayerAction({ type: "wait" });
});
@@ -86,7 +86,7 @@ export class GameEventHandler {
private handleUseItem(itemId: string) {
if (!this.scene.awaitingPlayer) return;
const player = this.scene.entityAccessor.getPlayer();
if (!player || !player.inventory) return;
@@ -95,48 +95,56 @@ export class GameEventHandler {
const item = player.inventory.items[itemIdx];
// Ranged Weapon Logic
if (item.type === "Weapon" && item.weaponType === "ranged") {
// Check Ammo
if (item.currentAmmo <= 0) {
if (item.type === "Weapon" && (item.weaponType === "ranged" || item.weaponType === "flamethrower")) {
if (item.weaponType === "ranged") {
// Check Ammo
if (item.currentAmmo <= 0) {
if (item.reloadingTurnsLeft > 0) {
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, "Reloading...", "#aaaaaa");
return;
}
// Try Reload
this.scene.startReload(player, item as any);
return;
}
// Is it already reloading?
if (item.reloadingTurnsLeft > 0) {
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, "Reloading...", "#aaaaaa");
return;
}
} else if (item.weaponType === "flamethrower") {
// Check Charges
if (item.charges <= 0) {
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, "No charges!", "#ff6600");
return;
}
}
// Try Reload
this.scene.startReload(player, item as any);
// Has ammo/charges, start targeting
if (this.scene.targetingSystem.isActive && this.scene.targetingSystem.itemId === item.id) {
// Already targeting - execute action
if (this.scene.targetingSystem.cursorPos) {
this.scene.executeThrow();
}
return;
}
// Is it already reloading?
if (item.reloadingTurnsLeft > 0) {
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, "Reloading...", "#aaaaaa");
return;
}
// Has ammo, start targeting
if (this.scene.targetingSystem.isActive && this.scene.targetingSystem.itemId === item.id) {
// Already targeting - execute shoot
if (this.scene.targetingSystem.cursorPos) {
this.scene.executeThrow();
}
return;
}
const { x: tx, y: ty } = this.scene.getPointerTilePos(this.scene.input.activePointer);
const { x: tx, y: ty } = this.scene.getPointerTilePos(this.scene.input.activePointer);
this.scene.targetingSystem.startTargeting(
item.id,
player.pos,
this.scene.world,
this.scene.entityAccessor,
this.scene.playerId,
this.scene.dungeonRenderer.seenArray,
this.scene.world.width,
{ x: tx, y: ty }
);
this.scene.emitUIUpdate();
this.scene.targetingSystem.startTargeting(
item.id,
player.pos,
this.scene.world,
this.scene.entityAccessor,
this.scene.playerId,
this.scene.dungeonRenderer.seenArray,
this.scene.world.width,
{ x: tx, y: ty }
);
this.scene.emitUIUpdate();
return;
}
@@ -144,27 +152,27 @@ export class GameEventHandler {
if (item.id === "upgrade_scroll") {
const uiScene = this.scene.scene.get("GameUI") as GameUI;
// Access the public inventory component
const inventoryOverlay = uiScene.inventory;
const inventoryOverlay = uiScene.inventory;
if (inventoryOverlay && inventoryOverlay instanceof InventoryOverlay) {
// Trigger upgrade mode
inventoryOverlay.enterUpgradeMode((targetItem: any) => {
const success = UpgradeManager.applyUpgrade(targetItem);
if (success) {
// Consume scroll logic handling stacking
const scrollItem = player.inventory?.items.find(it => it.id === "upgrade_scroll");
if (scrollItem) {
if (scrollItem.stackable && scrollItem.quantity && scrollItem.quantity > 1) {
scrollItem.quantity--;
} else {
this.scene.itemManager.removeFromInventory(player, "upgrade_scroll");
}
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, "Upgraded!", "#ffd700");
}
inventoryOverlay.cancelUpgradeMode();
this.scene.emitUIUpdate();
this.scene.commitPlayerAction({ type: "wait" });
const scrollItem = player.inventory?.items.find(it => it.id === "upgrade_scroll");
if (scrollItem) {
if (scrollItem.stackable && scrollItem.quantity && scrollItem.quantity > 1) {
scrollItem.quantity--;
} else {
this.scene.itemManager.removeFromInventory(player, "upgrade_scroll");
}
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, "Upgraded!", "#ffd700");
}
inventoryOverlay.cancelUpgradeMode();
this.scene.emitUIUpdate();
this.scene.commitPlayerAction({ type: "wait" });
} else {
// Should technically be prevented by UI highlights, but safety check
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, "Cannot upgrade!", "#ff0000");
@@ -172,49 +180,49 @@ export class GameEventHandler {
this.scene.emitUIUpdate();
}
});
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, "Select Item to Upgrade", "#ffffff");
}
return;
}
const result = this.scene.itemManager.handleUse(itemId, player);
if (result.success && result.consumed) {
const healAmount = player.stats.maxHp - player.stats.hp; // Already healed by manager
const actualHeal = Math.min(healAmount, player.stats.hp);
this.scene.dungeonRenderer.showHeal(player.pos.x, player.pos.y, actualHeal);
this.scene.commitPlayerAction({ type: "wait" });
this.scene.commitPlayerAction({ type: "wait" });
this.scene.emitUIUpdate();
} else if (result.success && !result.consumed) {
// Throwable item - start targeting
if (this.scene.targetingSystem.isActive && this.scene.targetingSystem.itemId === item.id) {
// Already targeting - execute throw
if (this.scene.targetingSystem.cursorPos) {
this.scene.executeThrow();
}
return;
}
const { x: tx, y: ty } = this.scene.getPointerTilePos(this.scene.input.activePointer);
// Throwable item - start targeting
if (this.scene.targetingSystem.isActive && this.scene.targetingSystem.itemId === item.id) {
// Already targeting - execute throw
if (this.scene.targetingSystem.cursorPos) {
this.scene.executeThrow();
}
return;
}
this.scene.targetingSystem.startTargeting(
item.id,
player.pos,
this.scene.world,
this.scene.entityAccessor,
this.scene.playerId,
this.scene.dungeonRenderer.seenArray,
this.scene.world.width,
{ x: tx, y: ty }
);
this.scene.emitUIUpdate();
const { x: tx, y: ty } = this.scene.getPointerTilePos(this.scene.input.activePointer);
this.scene.targetingSystem.startTargeting(
item.id,
player.pos,
this.scene.world,
this.scene.entityAccessor,
this.scene.playerId,
this.scene.dungeonRenderer.seenArray,
this.scene.world.width,
{ x: tx, y: ty }
);
this.scene.emitUIUpdate();
}
}
private handleDropItem(data: { itemId: string, pointerX: number, pointerY: number }) {
if (!this.scene.awaitingPlayer) return;
const player = this.scene.entityAccessor.getPlayer();
if (!player || !player.inventory) return;
@@ -225,7 +233,7 @@ export class GameEventHandler {
let dropPos = { x: player.pos.x, y: player.pos.y };
if (data.pointerX !== undefined && data.pointerY !== undefined) {
const tilePos = this.scene.getPointerTilePos({ x: data.pointerX, y: data.pointerY } as Phaser.Input.Pointer);
// Limit drop distance to 1 tile from player for balance/fairness
const dx = Math.sign(tilePos.x - player.pos.x);
const dy = Math.sign(tilePos.y - player.pos.y);
@@ -240,10 +248,10 @@ export class GameEventHandler {
// Remove from inventory and spawn in world
if (this.scene.itemManager.removeFromInventory(player, data.itemId)) {
this.scene.itemManager.spawnItem(item, dropPos);
const quantityText = (item.quantity && item.quantity > 1) ? ` x${item.quantity}` : "";
this.scene.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, `Dropped ${item.name}${quantityText}`, "#aaaaaa");
this.scene.emitUIUpdate();
}
}