Skip to content

Commit

Permalink
Revamp Gumble's passive ability
Browse files Browse the repository at this point in the history
Related to FreezingMoon#2635

Revamp Gumble's passive ability 'Gooey Body' to create a trap when Gumble is killed.

* Modify `src/abilities/Gumble.ts` to implement the new 'Gooey Body' ability.
  * When Gumble is killed, create a trap at Gumble's location that pins any unit that walks over it.
  * The trap prevents movement for the current round but allows the use of abilities.
  * Movement-related abilities can free the unit if landing outside the goo.
  * The trap remains until overlapped by another similar trap.
  * The upgraded ability does not affect allied units.
* Add the sprite file `assets/autoload/phaser/units/sprites/trap_goey-body.png` to the repository.
* Ensure the new ability is triggered by the 'onDeath' event.
  • Loading branch information
vishwamartur committed Nov 27, 2024
1 parent 796e653 commit 00627d8
Showing 1 changed file with 35 additions and 36 deletions.
71 changes: 35 additions & 36 deletions src/abilities/Gumble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default (G: Game) => {
// First Ability: Gooey Body
{
// Update stat buffs whenever health changes
trigger: 'onCreatureSummon onDamage onHeal',
trigger: 'onDeath',

require: function () {
// Always active
Expand All @@ -27,48 +27,47 @@ export default (G: Game) => {

activate: function () {
if (this.creature.dead) {
return;
}
// Attach a permanent effect that gives Gumble stat buffs
// Bonus points to pierce, slash and crush based on remaining health
const healthBonusDivisor = this.isUpgraded() ? 5 : 7;
const bonus = Math.floor((this.creature.health / healthBonusDivisor) * 3);
// Log whenever the bonus applied changes
const noLog = bonus == this._lastBonus;
this._lastBonus = bonus;
const statsToApplyBonus = ['pierce', 'slash', 'crush'];
const alterations = {};
for (let i = 0; i < statsToApplyBonus.length; i++) {
const key = statsToApplyBonus[i];
alterations[key] = bonus;
}
this.creature.replaceEffect(
new Effect(
'Gooey Body', // name
this.creature, // Caster
this.creature, // Target
'', // Trigger
const effect = new Effect(
'Gooey Body',
this.creature,
this.creature.hexagons[0],
'onStepIn',
{
alterations: alterations,
deleteTrigger: '',
stackable: false,
effectFn: () => {
if (bonus !== this._lastBonus) {
G.log('Effect ' + this.title + ' triggered');
requireFn: function (creature) {
if (this.isUpgraded() && creature.team === this.creature.team) {
return false;
}
return true;
},
effectFn: function (effect, creature) {
creature.remainingMove = 0;
},
alterations: {
moveable: false,
},
deleteTrigger: 'onStartPhase',
turnLifetime: 1,
},
G,
),
);
if (!noLog) {
G.log(
'%CreatureName' + this.creature.id + '% receives ' + bonus + ' pierce, slash and crush',
'trap_goey-body',
);

const trap = new Trap(
this.creature.x,
this.creature.y,
'trap_goey-body',
[effect],
this.creature.player,
{
ownerCreature: this.creature,
fullTurnLifetime: true,
},
G,
);

trap.hide();
}
},

_lastBonus: 0,
},

// Second Ability: Gummy Mallet
Expand Down Expand Up @@ -241,7 +240,7 @@ export default (G: Game) => {
'royal-seal',
[effect],
ability.creature.player,
{
{
ownerCreature: ability.creature,
fullTurnLifetime: true,
},
Expand Down

0 comments on commit 00627d8

Please sign in to comment.