Skip to content

Commit

Permalink
Merge pull request #1999 from nandastone/1088-b
Browse files Browse the repository at this point in the history
Abolished "Fiery Touch" ability change + shrunken targeting hexes, fixes #1088
  • Loading branch information
DreadKnight committed Jan 4, 2022
2 parents 75e4f30 + 7825126 commit c83f536
Show file tree
Hide file tree
Showing 29 changed files with 945 additions and 696 deletions.
119 changes: 87 additions & 32 deletions src/abilities/Abolished.js
Expand Up @@ -63,12 +63,31 @@ export default (G) => {
}
},
},
// Fiery touch

/**
* Basic Ability: Fiery Touch
*
* Attack a single enemy unit within 3 range (forwards, backwards, or diagonal)
* dealing both slash and burn damage.
*
* When upgraded, the range is extended to 6 but only the burn damage is applied.
*
* Targeting rules:
* - The target must be an enemy unit.
* - The target must be inline forwards, backwards, or diagonally within 3 range.
* - The path to the target unit cannot be interrupted by any obstacles or units.
*
* Other rules:
* - Whether dealing both damage types or just one (upgraded extra range), only
* one attack and damage should occur.
* - When upgraded, the extended range of the burn damage should be indicated
* with "reduced effect" (scaled down) hexagons.
*/
{
// Type : Can be "onQuery", "onStartPhase", "onDamage"
trigger: 'onQuery',
distance: 3,
_targetTeam: Team.enemy,

_targetTeam: Team.Enemy,

require() {
if (!this.testRequirements()) {
return false;
Expand All @@ -77,42 +96,46 @@ export default (G) => {
if (
!this.testDirection({
team: this._targetTeam,
distance: this.distance,
distance: this._getDistance(),
sourceCreature: this.creature,
})
) {
return false;
}

return true;
},

query() {
let ability = this;
let crea = this.creature;
const ability = this;
const abolished = this.creature;

if (this.isUpgraded()) {
this.distance = 5;
}
// TODO: Visually show reduced damage hexes for 4-6 range.

G.grid.queryDirection({
fnOnConfirm: function () {
ability.animation(...arguments);
},
flipped: crea.player.flipped,
flipped: abolished.player.flipped,
team: this._targetTeam,
id: this.creature.id,
requireCreature: true,
x: crea.x,
y: crea.y,
distance: this.distance,
sourceCreature: crea,
x: abolished.x,
y: abolished.y,
distance: this._getDistance(),
distanceFalloff: this.range.regular,
sourceCreature: abolished,
});
},

activate(path, args) {
let ability = this;
const ability = this;
const target = arrayUtils.last(path).creature;

let target = arrayUtils.last(path).creature;
let startX = ability.creature.sprite.scale.x > 0 ? 232 : 52;
let projectileInstance = G.animations.projectile(
ability.end();

const startX = ability.creature.sprite.scale.x > 0 ? 232 : 52;
const projectileInstance = G.animations.projectile(
this,
target,
'effects_fiery-touch',
Expand All @@ -121,29 +144,61 @@ export default (G) => {
startX,
-20,
);
let tween = projectileInstance[0];
let sprite = projectileInstance[1];
const tween = projectileInstance[0];
const sprite = projectileInstance[1];
const damage = this._getDamage(path);

tween.onComplete.add(function () {
let damage = new Damage(
ability.creature, // Attacker
ability.damages, // Damage Type
1, // Area
[], // Effects
G,
);
target.takeDamage(damage);

ability.end();
// `this` refers to the animation object, _not_ the ability.
this.destroy();
}, sprite); // End tween.onComplete

target.takeDamage(damage);
}, sprite);
},

getAnimationData: function () {
return {
duration: 425,
};
},

/**
* Calculate the maximum distance the ability can be targeted and activated.
*
* @returns {number} Ability maximum distance
*/
_getDistance() {
return this.isUpgraded() ? this.range.upgraded : this.range.regular;
},

/**
* Calculate the damage of the ability as it changes depending on the distance
* that it is used.
*
* @param {Hex[]} path Path from the Abolished to the target unit. May contain
* creature hexes.
* @returns {Damage} Final damage
*/
_getDamage(path) {
/* The path may contain multiple hexes from the source/target unit, so reduce
to the path BETWEEN the source/target for simpler logic. */
const distance = arrayUtils.filterCreature([...path], false, false).length;
const damages = {
...this.damages,
slash:
/* If the ability was targeted beyond the regular range, only the burn
damage is applied.
`distance` is 1 less than the ability range as it's the distance BETWEEN
the units, rather than the distance used in query calculations which
may included hexagons of either creature. */
distance >= this.range.regular ? 0 : this.damages.slash,
};

return new Damage(this.creature, damages, 1, [], G);
},
},

// Wild Fire
{
// Type : Can be "onQuery", "onStartPhase", "onDamage"
Expand Down
4 changes: 2 additions & 2 deletions src/abilities/Asher.js
Expand Up @@ -59,7 +59,7 @@ export default (G) => {
trigger: 'onQuery',

distance: 2,
_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

// require() :
require: function () {
Expand Down Expand Up @@ -121,7 +121,7 @@ export default (G) => {
// Type : Can be "onQuery","onStartPhase","onDamage"
trigger: 'onQuery',

_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

// require() :
require: function () {
Expand Down
6 changes: 3 additions & 3 deletions src/abilities/Chimera.js
Expand Up @@ -38,7 +38,7 @@ export default (G) => {
// Type : Can be "onQuery","onStartPhase","onDamage"
trigger: 'onQuery',

_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

// require() :
require: function () {
Expand Down Expand Up @@ -108,7 +108,7 @@ export default (G) => {
// Type : Can be "onQuery", "onStartPhase", "onDamage"
trigger: 'onQuery',

_targetTeam: Team.both,
_targetTeam: Team.Both,

// require() :
require: function () {
Expand Down Expand Up @@ -200,7 +200,7 @@ export default (G) => {
// Type : Can be "onQuery", "onStartPhase", "onDamage"
trigger: 'onQuery',

_targetTeam: Team.both,
_targetTeam: Team.Both,

_getDirections: function () {
return this.testDirections({
Expand Down
8 changes: 4 additions & 4 deletions src/abilities/Cyber-Wolf.js
Expand Up @@ -37,7 +37,7 @@ export default (G) => {
if (!target) {
return;
}
if (!isTeam(this.creature, target, Team.enemy)) {
if (!isTeam(this.creature, target, Team.Enemy)) {
return;
}

Expand All @@ -62,7 +62,7 @@ export default (G) => {
// Type : Can be "onQuery", "onStartPhase", "onDamage"
trigger: 'onQuery',

_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

// require() :
require: function () {
Expand Down Expand Up @@ -218,7 +218,7 @@ export default (G) => {
fnOnConfirm: function () {
ability.animation(...arguments);
},
team: Team.both,
team: Team.Both,
id: crea.id,
requireCreature: false,
choices: choices,
Expand Down Expand Up @@ -337,7 +337,7 @@ export default (G) => {
fnOnConfirm: function () {
ability.animation(...arguments);
}, // fnOnConfirm
team: Team.enemy,
team: Team.Enemy,
id: crea.id,
flipped: crea.player.flipped,
hexes: hexes,
Expand Down
4 changes: 2 additions & 2 deletions src/abilities/Dark-Priest.js
Expand Up @@ -67,7 +67,7 @@ export default (G) => {
// Type : Can be "onQuery", "onStartPhase", "onDamage"
trigger: 'onQuery',

_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

// require() :
require: function () {
Expand Down Expand Up @@ -126,7 +126,7 @@ export default (G) => {
// Type : Can be "onQuery", "onStartPhase", "onDamage"
trigger: 'onQuery',

_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

// require() :
require: function () {
Expand Down
6 changes: 3 additions & 3 deletions src/abilities/Golden-Wyrm.js
Expand Up @@ -35,7 +35,7 @@ export default (G) => {
// Upgraded version only activates if enemy is in adjacent hexes
if (
!this.atLeastOneTarget(this._targets, {
team: Team.enemy,
team: Team.Enemy,
})
) {
return false;
Expand Down Expand Up @@ -88,7 +88,7 @@ export default (G) => {

_executeHealthThreshold: 45,

_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

require: function () {
if (!this.testRequirements()) {
Expand Down Expand Up @@ -305,7 +305,7 @@ export default (G) => {
{
trigger: 'onQuery',

_targetTeam: Team.ally,
_targetTeam: Team.Ally,

_maxTransferAmount: 50,

Expand Down
6 changes: 3 additions & 3 deletions src/abilities/Gumble.js
Expand Up @@ -107,7 +107,7 @@ export default (G) => {
fnOnConfirm: function () {
ability.animation(...arguments);
},
team: Team.both,
team: Team.Both,
id: this.creature.id,
requireCreature: false,
choices: choices,
Expand Down Expand Up @@ -135,7 +135,7 @@ export default (G) => {
continue;
}
let damages = this.damages;
if (isTeam(this.creature, targets[i].target, Team.enemy)) {
if (isTeam(this.creature, targets[i].target, Team.Enemy)) {
damages = enemyDamages;
}
let dmg = new Damage(this.creature, damages, targets[i].hexesHit, [], G);
Expand Down Expand Up @@ -251,7 +251,7 @@ export default (G) => {
trigger: 'onQuery',

directions: [1, 1, 1, 1, 1, 1],
_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

// require() :
require: function () {
Expand Down
10 changes: 5 additions & 5 deletions src/abilities/Headless.js
Expand Up @@ -28,7 +28,7 @@ export default (G) => {
{
trigger: 'onStartPhase onEndPhase',

_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

require: function () {
// Headless only triggers ability on its own turn.
Expand Down Expand Up @@ -96,7 +96,7 @@ export default (G) => {
// Type : Can be "onQuery", "onStartPhase", "onDamage"
trigger: 'onQuery',

_targetTeam: Team.enemy,
_targetTeam: Team.Enemy,

// require() :
require: function () {
Expand Down Expand Up @@ -196,7 +196,7 @@ export default (G) => {
{
trigger: 'onQuery',

_targetTeam: Team.both,
_targetTeam: Team.Both,
_directions: [0, 1, 0, 0, 1, 0],

require: function () {
Expand Down Expand Up @@ -275,7 +275,7 @@ export default (G) => {
);
path = arrayUtils.sortByDirection(
[...deadzonePath, ...path],
args.direction === Direction.Left ? Direction.Right : Direction.Left,
args.direction === Direction.Right ? Direction.Left : Direction.Right,
);

ability.end();
Expand Down Expand Up @@ -391,7 +391,7 @@ export default (G) => {
fnOnConfirm: function () {
ability.animation(...arguments);
},
team: Team.both,
team: Team.Both,
requireCreature: 0,
id: crea.id,
flipped: crea.player.flipped,
Expand Down

0 comments on commit c83f536

Please sign in to comment.