Skip to content

Commit

Permalink
Golden-Wyrm.js -> Golden-Wyrm.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
allmtz committed Feb 19, 2024
1 parent e1e7473 commit 8c24d29
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
24 changes: 15 additions & 9 deletions src/abilities/Golden-Wyrm.js → src/abilities/Golden-Wyrm.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Damage } from '../damage';
import { Team, isTeam } from '../utility/team';
import { Team } from '../utility/team';
import * as matrices from '../utility/matrices';
import { Creature } from '../creature';
import { Effect } from '../effect';
import Game from '../game';
import { Hex } from '../utility/hex';

/** Creates the abilities
* @param {Object} G the game object
* @return {void}
*/
export default (G) => {
export default (G: Game) => {
G.abilities[33] = [
// First Ability: Battle Cry
{
Expand Down Expand Up @@ -48,7 +50,7 @@ export default (G) => {
activate: function () {
const creature = this.creature;
const damage = new Damage(creature, { sonic: 30 }, this._targets.length, [], G);
const hits = new Set();
const hits: Set<Creature> = new Set();
G.Phaser.camera.shake(0.02, 300, true, G.Phaser.camera.SHAKE_HORIZONTAL, true);

this._targets.forEach((target) => {
Expand Down Expand Up @@ -113,6 +115,7 @@ export default (G) => {

this.game.grid.queryCreature({
fnOnConfirm: function () {
// eslint-disable-next-line
ability.animation(...arguments);
},
team: this._targetTeam,
Expand All @@ -122,7 +125,7 @@ export default (G) => {
});
},

activate: function (target) {
activate: function (target: Creature) {
this.end();
G.Phaser.camera.shake(0.02, 200, true, G.Phaser.camera.SHAKE_BOTH, true);

Expand Down Expand Up @@ -173,7 +176,7 @@ export default (G) => {
* @returns {Hex[]} Refer to Creature.getHexMap()
*/
_getHexes() {
return this.creature.getHexMap(matrices.frontnback3hex);
return this.creature.getHexMap(matrices.frontnback3hex, false);
},
},

Expand Down Expand Up @@ -218,9 +221,11 @@ export default (G) => {

this.game.grid.queryHexes({
fnOnSelect: function () {
// eslint-disable-next-line
ability._highlightDestination(...arguments);
},
fnOnConfirm: function () {
// eslint-disable-next-line
ability.animation(...arguments);
},
size: wyrm.size,
Expand All @@ -230,7 +235,7 @@ export default (G) => {
});
},

activate: function (hex) {
activate: function (hex: Hex) {
const ability = this;
ability.end();

Expand All @@ -249,7 +254,7 @@ export default (G) => {
});
},

_highlightDestination: function (hex) {
_highlightDestination: function (hex: Hex) {
this.creature.tracePosition({
x: hex.x,
y: hex.y,
Expand Down Expand Up @@ -343,6 +348,7 @@ export default (G) => {

G.grid.queryCreature({
fnOnConfirm: function () {
// eslint-disable-next-line
ability.animation(...arguments);
},
optTest: this._confirmTarget,
Expand All @@ -353,7 +359,7 @@ export default (G) => {
});
},

activate: function (target) {
activate: function (target: Creature) {
this.end();

// The health transferred is the creature's missing life, capped to 50.
Expand Down Expand Up @@ -416,7 +422,7 @@ export default (G) => {
* @param {Creature} creature Ally creature that could be targeted.
* @returns {boolean} Should the creature be targeted?
*/
_confirmTarget(creature) {
_confirmTarget(creature: Creature) {
return creature.health < creature.stats.health;
},
},
Expand Down
12 changes: 11 additions & 1 deletion src/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export type Trigger =
| 'oncePerDamageChain'
| 'onCreatureMove onOtherCreatureMove'
| 'onCreatureSummon onDamage onHeal'
| 'onStartPhase onEndPhase';
| 'onStartPhase onEndPhase'
| 'onDamage onStartPhase';

// Could get rid of the union and optionals by creating a separate (or conditional) type for Dark Priest's Cost
// This might narrow down the types in the constructor by checking `creature.name`
Expand Down Expand Up @@ -97,6 +98,8 @@ export class Ability {
triggeredThisChain?: boolean;
range?: { minimum?: number; regular: number; upgraded: number };

// Properties that begin with an underscore are used locally in a specific file in the `abilities` directory.
// For example: _lastBonus is unique to Gumble.ts.
_lastBonus?: number;

_disableCooldowns: boolean;
Expand All @@ -114,6 +117,13 @@ export class Ability {
_getMaxDistance: () => number;
_directions?: Direction[];
_targetTeam: Team;
_targets: Hex[];
_addOffenseBuff: () => void;
_maxTransferAmount: number;
_confirmTarget: (c: Creature) => boolean;
_damaged: boolean;
_executeHealthThreshold: number;
_highlightDestination: (...args: any) => void;

// Below methods exist in Snow-Bunny.ts
_detectFrontHexesWithEnemy: () => { direction: number; hex: Hex; enemyPos: Point }[];
Expand Down

0 comments on commit 8c24d29

Please sign in to comment.