Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Abolished's Third Ability: Bonfire Spring #2658

Merged
merged 13 commits into from
Dec 10, 2024
16 changes: 9 additions & 7 deletions src/abilities/Abolished.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Creature } from '../creature';
import { Effect } from '../effect';
import * as arrayUtils from '../utility/arrayUtils';
import { getPointFacade } from '../utility/pointfacade';
import { isUndefined } from 'underscore';

/** Creates the abilities
* @param {Object} G the game object
Expand Down Expand Up @@ -210,19 +211,24 @@ export default (G) => {
{
// Type : Can be "onQuery", "onStartPhase", "onDamage"
trigger: 'onQuery',
range: 6,
range: 3,
require() {
return this.testRequirements();
},

query() {
const ability = this;
const crea = this.creature;
let totalRange = this.range;
if (this.isUpgraded()) {
totalRange = this.range + this.creature.accumulatedTeleportRange - 1;
}

// Relocates to any hex within range except for the current hex
crea.queryMove({
noPath: true,
isAbility: true,
range: G.grid.getFlyingRange(crea.x, crea.y, this.range, crea.size, crea.id),
range: G.grid.getFlyingRange(crea.x, crea.y, totalRange, crea.size, crea.id),
callback: function (hex, args) {
if (hex.x == args.creature.x && hex.y == args.creature.y) {
// Prevent null movement
Expand All @@ -237,11 +243,7 @@ export default (G) => {
activate(hex) {
const ability = this;
ability.end();

if (this.isUpgraded()) {
this.range += 1;
}

this.creature.accumulatedTeleportRange = 0;
const targets = ability.getTargets(ability.creature.adjacentHexes(1));

targets.forEach(function (item) {
Expand Down
91 changes: 46 additions & 45 deletions src/creature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export class Creature {
oldEnergy: number;
remainingMove: number;
abilities: Ability[];
accumulatedTeleportRange: number = 0; // Used for Abolished's third ability

creatureSprite: CreatureSprite;

Expand Down Expand Up @@ -635,56 +636,56 @@ export class Creature {
}

const defaultOptions = {
targeting: false,
noPath: false,
isAbility: false,
ownCreatureHexShade: true,
range: game.grid.getMovementRange(this.x, this.y, remainingMove, this.size, this.id),
callback: function (hex: Hex, args) {
if (hex.x == args.creature.x && hex.y == args.creature.y) {
// Prevent null movement
game.activeCreature.queryMove();
return;
}
targeting: false,
noPath: false,
isAbility: false,
ownCreatureHexShade: true,
range: game.grid.getMovementRange(this.x, this.y, remainingMove, this.size, this.id),
callback: function (hex: Hex, args) {
if (hex.x == args.creature.x && hex.y == args.creature.y) {
// Prevent null movement
game.activeCreature.queryMove();
return;
}

if (game.grid.materialize_overlay) {
const creature = game.retrieveCreatureStats(game.activeCreature.type);
game.Phaser.add
.tween(game.grid.materialize_overlay)
.to(
{
alpha: 0,
},
creature.animation.walk_speed,
Phaser.Easing.Linear.None,
)
.start();
}
if (game.grid.materialize_overlay) {
const creature = game.retrieveCreatureStats(game.activeCreature.type);
game.Phaser.add
.tween(game.grid.materialize_overlay)
.to(
{
alpha: 0,
},
creature.animation.walk_speed,
Phaser.Easing.Linear.None,
)
.start();
}

game.gamelog.add({
action: 'move',
game.gamelog.add({
action: 'move',
target: {
x: hex.x,
y: hex.y,
},
});
if (game.multiplayer) {
game.gameplay.moveTo({
target: {
x: hex.x,
y: hex.y,
},
});
if (game.multiplayer) {
game.gameplay.moveTo({
target: {
x: hex.x,
y: hex.y,
},
});
}
game.UI.btnDelay.changeState('disabled');
args.creature.moveTo(hex, {
animation: args.creature.movementType() === 'flying' ? 'fly' : 'walk',
callback: function () {
game.activeCreature.queryMove();
},
});
},
}
game.UI.btnDelay.changeState('disabled');
args.creature.moveTo(hex, {
animation: args.creature.movementType() === 'flying' ? 'fly' : 'walk',
callback: function () {
game.activeCreature.queryMove();
},
});
},
},
// overwrite any fields of `defaultOptions` that were provided in `options`
o = $j.extend(defaultOptions, options);

Expand Down Expand Up @@ -729,7 +730,7 @@ export class Creature {
fnOnConfirm: function () {
game.UI.btnSkipTurn.click();
},
fnOnCancel: function () {},
fnOnCancel: function () { },
confirmText: 'Skip turn',
});
} else {
Expand Down Expand Up @@ -1914,8 +1915,8 @@ class CreatureSprite {
(dir === 1
? this._frameInfo.originX
: HEX_WIDTH_PX * this._creatureSize -
this._sprite.texture.width -
this._frameInfo.originX) +
this._sprite.texture.width -
this._frameInfo.originX) +
this._sprite.texture.width / 2;
this._healthIndicatorSprite.x = dir === -1 ? 19 : 19 + HEX_WIDTH_PX * (this._creatureSize - 1);
this._healthIndicatorText.x =
Expand Down
19 changes: 14 additions & 5 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export default class Game {
setupOpt: Partial<GameConfig>,
matchInitialized?: boolean,
matchid?: number,
onLoadCompleteFn = () => {},
onLoadCompleteFn = () => { },
) {
// Need to remove keydown listener before new game start
// to prevent memory leak and mixing hotkeys between start screen and game
Expand Down Expand Up @@ -902,7 +902,7 @@ export default class Game {

o = $j.extend(
{
callback: function () {},
callback: function () { },
noTooltip: false,
tooltip: 'Skipped',
},
Expand Down Expand Up @@ -963,7 +963,7 @@ export default class Game {

o = $j.extend(
{
callback: function () {},
callback: function () { },
},
o,
);
Expand Down Expand Up @@ -1260,7 +1260,7 @@ export default class Game {
onStartPhase(/* creature, callback */) {
const creature = arguments[0],
totalTraps = this.traps.length;

let trap: Trap;

for (let i = 0; i < totalTraps; i++) {
Expand Down Expand Up @@ -1293,6 +1293,10 @@ export default class Game {
// Removed individual args from definition because we are using the arguments variable.
onEndPhase(/* creature, callback */) {
const creature = arguments[0];
// Check if Abolished used third ability
if (creature.abilities.some(ability => ability.title === 'Bonfire Spring')) {
creature.accumulatedTeleportRange += 1;
}

this.triggerDeleteEffect('onEndPhase', creature);
this.triggerAbility('onEndPhase', arguments);
Expand Down Expand Up @@ -1503,7 +1507,7 @@ export default class Game {

action(o, opt) {
const defaultOpt = {
callback: function () {},
callback: function () { },
};

opt = $j.extend(defaultOpt, opt);
Expand Down Expand Up @@ -1532,6 +1536,11 @@ export default class Game {
break;
case 'ability': {
const args = $j.makeArray(o.args[1]);
const ability = this.activeCreature.abilities[o.id];
// If Abolished used Bonfire Spring, reset the range
if (ability.title === 'Bonfire Spring') {
Luffy117 marked this conversation as resolved.
Show resolved Hide resolved
this.activeCreature.accumulatedTeleportRange = 0;
}

if (o.target.type == 'hex') {
args.unshift(this.grid.hexes[o.target.y][o.target.x]);
Expand Down
Loading