Compare commits
No commits in common. "74d5abd2a1b0f77cf85000d9c4d27b157be3af45" and "c7f4dc9bbb5713e95fc53bb80fc35cb69abebcba" have entirely different histories.
74d5abd2a1
...
c7f4dc9bbb
|
|
@ -61,9 +61,9 @@ export class CardObject extends Phaser.GameObjects.Container {
|
||||||
).setOrigin(0, 0.5);
|
).setOrigin(0, 0.5);
|
||||||
this.add(this.atkText);
|
this.add(this.atkText);
|
||||||
|
|
||||||
// Small "ATK" label — to the right of the value (assumes up to 2 digits)
|
// Small "ATK" label under the number (tiny, just for clarity)
|
||||||
const atkLabel = this.scene.add.text(
|
const atkLabel = this.scene.add.text(
|
||||||
-w / 2 + Math.round(19 * scale), topBannerCY,
|
-w / 2 + Math.round(5 * scale), topBannerCY + Math.round(bannerH * 0.30),
|
||||||
'ATK',
|
'ATK',
|
||||||
{ fontSize: fs(5.5), color: '#886666' }
|
{ fontSize: fs(5.5), color: '#886666' }
|
||||||
).setOrigin(0, 0.5);
|
).setOrigin(0, 0.5);
|
||||||
|
|
@ -77,9 +77,9 @@ export class CardObject extends Phaser.GameObjects.Container {
|
||||||
).setOrigin(1, 0.5);
|
).setOrigin(1, 0.5);
|
||||||
this.add(this.armText);
|
this.add(this.armText);
|
||||||
|
|
||||||
// Small "ARM" label — to the left of the value (assumes up to 2 digits)
|
// Small "ARM" label
|
||||||
const armLabel = this.scene.add.text(
|
const armLabel = this.scene.add.text(
|
||||||
w / 2 - Math.round(19 * scale), topBannerCY,
|
w / 2 - Math.round(5 * scale), topBannerCY + Math.round(bannerH * 0.30),
|
||||||
'ARM',
|
'ARM',
|
||||||
{ fontSize: fs(5.5), color: '#667799' }
|
{ fontSize: fs(5.5), color: '#667799' }
|
||||||
).setOrigin(1, 0.5);
|
).setOrigin(1, 0.5);
|
||||||
|
|
@ -144,9 +144,9 @@ export class CardObject extends Phaser.GameObjects.Container {
|
||||||
).setOrigin(0, 0.5);
|
).setOrigin(0, 0.5);
|
||||||
this.add(this.hpText);
|
this.add(this.hpText);
|
||||||
|
|
||||||
// Small "HP" label — to the right of the value (assumes up to 2 digits)
|
// Small "HP" label
|
||||||
const hpLabel = this.scene.add.text(
|
const hpLabel = this.scene.add.text(
|
||||||
-w / 2 + Math.round(19 * scale), bottomBannerCY,
|
-w / 2 + Math.round(5 * scale), bottomBannerCY + Math.round(bannerH * 0.30),
|
||||||
'HP',
|
'HP',
|
||||||
{ fontSize: fs(5.5), color: '#337755' }
|
{ fontSize: fs(5.5), color: '#337755' }
|
||||||
).setOrigin(0, 0.5);
|
).setOrigin(0, 0.5);
|
||||||
|
|
@ -160,9 +160,9 @@ export class CardObject extends Phaser.GameObjects.Container {
|
||||||
).setOrigin(1, 0.5);
|
).setOrigin(1, 0.5);
|
||||||
this.add(this.dlyText);
|
this.add(this.dlyText);
|
||||||
|
|
||||||
// Small "DLY" label — to the left of the value (assumes up to 2 digits)
|
// Small "DLY" label
|
||||||
const dlyLabel = this.scene.add.text(
|
const dlyLabel = this.scene.add.text(
|
||||||
w / 2 - Math.round(19 * scale), bottomBannerCY,
|
w / 2 - Math.round(5 * scale), bottomBannerCY + Math.round(bannerH * 0.30),
|
||||||
'DLY',
|
'DLY',
|
||||||
{ fontSize: fs(5.5), color: '#777777' }
|
{ fontSize: fs(5.5), color: '#777777' }
|
||||||
).setOrigin(1, 0.5);
|
).setOrigin(1, 0.5);
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,6 @@ export class BattleScene extends Phaser.Scene {
|
||||||
this.isAnimating = false;
|
this.isAnimating = false;
|
||||||
this._updateLog();
|
this._updateLog();
|
||||||
this.statusText.setText('Press SPACE or click Next Turn to advance');
|
this.statusText.setText('Press SPACE or click Next Turn to advance');
|
||||||
this._animateInitiativeHandoff();
|
|
||||||
if (this.engine.winner) {
|
if (this.engine.winner) {
|
||||||
this.time.delayedCall(600, () => this._showResult());
|
this.time.delayedCall(600, () => this._showResult());
|
||||||
}
|
}
|
||||||
|
|
@ -330,34 +329,24 @@ export class BattleScene extends Phaser.Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update a card's HP bar and stats at the moment of impact, then handle death.
|
// Update a card's HP bar and stats at the moment of impact, then handle death.
|
||||||
// If the defender was already killed via _onAttackReconcile, cardObjects.get() returns
|
|
||||||
// null here and the function exits early — no double-death.
|
|
||||||
_refreshCardAfterAttack(cardData) {
|
_refreshCardAfterAttack(cardData) {
|
||||||
if (!cardData) return;
|
if (!cardData) return;
|
||||||
const obj = this.cardObjects.get(cardData.instanceId)
|
const obj = this.cardObjects.get(cardData.instanceId)
|
||||||
?? this.commanderObjects?.get(cardData.instanceId);
|
?? this.commanderObjects?.get(cardData.instanceId);
|
||||||
if (!obj) return;
|
if (!obj) return;
|
||||||
obj.refresh();
|
obj.refresh(); // updates HP bar + stats text to current values
|
||||||
// Fallback death path for cards killed by counter/rupture without an HP loss animation
|
// Commanders never get destroyed — the win-check handles game-over
|
||||||
if (cardData.currentHP <= 0 && !obj.isCommander) {
|
if (cardData.currentHP <= 0 && !obj.isCommander) {
|
||||||
this._playCardDeath(obj, cardData);
|
// Explosion sprite centered on the card
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Explosion sprite + fade-out for a defeated lane card.
|
|
||||||
_playCardDeath(obj, cardData) {
|
|
||||||
this.cardObjects.delete(cardData.instanceId);
|
|
||||||
|
|
||||||
this.tweens.killTweensOf(obj);
|
|
||||||
obj.setScale(1).setDepth(0);
|
|
||||||
|
|
||||||
const explosionSprite = this.add.sprite(obj.x, obj.y, 'attacks')
|
const explosionSprite = this.add.sprite(obj.x, obj.y, 'attacks')
|
||||||
.setDisplaySize(630, 630)
|
.setDisplaySize(630, 630)
|
||||||
.setDepth(23);
|
.setDepth(23);
|
||||||
explosionSprite.play('explosion_anim');
|
explosionSprite.play('explosion_anim');
|
||||||
explosionSprite.once('animationcomplete', () => {
|
explosionSprite.once('animationcomplete', () => { if (explosionSprite.scene) explosionSprite.destroy(); });
|
||||||
if (explosionSprite.scene) explosionSprite.destroy();
|
|
||||||
if (!obj.scene) return;
|
this.cardObjects.delete(cardData.instanceId);
|
||||||
|
this.tweens.killTweensOf(obj);
|
||||||
|
obj.setScale(1).setDepth(0);
|
||||||
this.tweens.add({
|
this.tweens.add({
|
||||||
targets: obj,
|
targets: obj,
|
||||||
scaleX: 1.25, scaleY: 1.25,
|
scaleX: 1.25, scaleY: 1.25,
|
||||||
|
|
@ -366,7 +355,7 @@ export class BattleScene extends Phaser.Scene {
|
||||||
ease: 'Power2',
|
ease: 'Power2',
|
||||||
onComplete: () => { if (obj.scene) obj.destroy(); }
|
onComplete: () => { if (obj.scene) obj.destroy(); }
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animate a card appearing on the field (scale from 0 with overshoot)
|
// Animate a card appearing on the field (scale from 0 with overshoot)
|
||||||
|
|
@ -579,13 +568,9 @@ export class BattleScene extends Phaser.Scene {
|
||||||
const defenderObj = _lookup(event.defender?.instanceId);
|
const defenderObj = _lookup(event.defender?.instanceId);
|
||||||
const attackerObj = _lookup(event.attacker?.instanceId);
|
const attackerObj = _lookup(event.attacker?.instanceId);
|
||||||
|
|
||||||
// HP loss animation on defender; on completion, trigger death if HP reached zero
|
// HP loss animation on defender
|
||||||
if (defenderObj?.scene && event.damage > 0) {
|
if (defenderObj?.scene && event.damage > 0) {
|
||||||
defenderObj.animateHPLoss(event.damage, () => {
|
defenderObj.animateHPLoss(event.damage);
|
||||||
if (event.defender.currentHP <= 0 && !defenderObj.isCommander) {
|
|
||||||
this._playCardDeath(defenderObj, event.defender);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berserk ATK gain animation on attacker
|
// Berserk ATK gain animation on attacker
|
||||||
|
|
@ -783,18 +768,6 @@ export class BattleScene extends Phaser.Scene {
|
||||||
backBtn.on('pointerdown', () => this.scene.start(this.missionData ? 'CampaignScene' : 'MainMenuScene'));
|
backBtn.on('pointerdown', () => this.scene.start(this.missionData ? 'CampaignScene' : 'MainMenuScene'));
|
||||||
}
|
}
|
||||||
|
|
||||||
_animateInitiativeHandoff() {
|
|
||||||
if (!this.initiativeIndicator?.scene) return;
|
|
||||||
// playerGoesFirst still reflects the turn that just ended; next turn is the opposite
|
|
||||||
const targetY = this.playerGoesFirst ? 305 : 715;
|
|
||||||
this.tweens.add({
|
|
||||||
targets: this.initiativeIndicator,
|
|
||||||
y: targetY,
|
|
||||||
duration: 700,
|
|
||||||
ease: 'Power2.inOut'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateInitiativeIndicator(playerGoesFirst) {
|
_updateInitiativeIndicator(playerGoesFirst) {
|
||||||
if (this.initiativeIndicator) {
|
if (this.initiativeIndicator) {
|
||||||
this.initiativeIndicator.destroy();
|
this.initiativeIndicator.destroy();
|
||||||
|
|
@ -802,10 +775,10 @@ export class BattleScene extends Phaser.Scene {
|
||||||
}
|
}
|
||||||
if (!this.textures.exists('attacksFirst')) return;
|
if (!this.textures.exists('attacksFirst')) return;
|
||||||
// Position the indicator to the left of the commander card (commander at x=150, width=240)
|
// Position the indicator to the left of the commander card (commander at x=150, width=240)
|
||||||
const indicatorX = 60;
|
const indicatorX = 22;
|
||||||
const indicatorY = playerGoesFirst ? 715 : 305;
|
const indicatorY = playerGoesFirst ? 715 : 305;
|
||||||
this.initiativeIndicator = this.add.image(indicatorX, indicatorY, 'attacksFirst')
|
this.initiativeIndicator = this.add.image(indicatorX, indicatorY, 'attacksFirst')
|
||||||
.setDisplaySize(110, 110)
|
.setDisplaySize(44, 44)
|
||||||
.setDepth(5);
|
.setDepth(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue