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

Cyber-Wolf.js -> Cyber-Wolf.ts #2543

Merged
merged 4 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions src/abilities/Cyber-Wolf.js → src/abilities/Cyber-Wolf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { Team, isTeam } from '../utility/team';
import * as matrices from '../utility/matrices';
import * as arrayUtils from '../utility/arrayUtils';
import { Creature } from '../creature';
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[31] = [
// First Ability: Bad Doggie
{
Expand All @@ -29,7 +31,7 @@ export default (G) => {

activate: function () {
// Check if there's an enemy creature in front
const hexesInFront = this.creature.getHexMap(matrices.inlinefront2hex);
const hexesInFront = this.creature.getHexMap(matrices.inlinefront2hex, false);
if (hexesInFront.length < 1) {
return;
}
Expand Down Expand Up @@ -71,14 +73,9 @@ export default (G) => {
return false;
}

if (
!this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex), {
team: this._targetTeam,
})
) {
return false;
}
return true;
return this.atLeastOneTarget(this.creature.getHexMap(matrices.frontnback2hex, false), {
team: this._targetTeam,
});
},

// query() :
Expand All @@ -88,17 +85,18 @@ export default (G) => {

G.grid.queryCreature({
fnOnConfirm: function () {
// eslint-disable-next-line
ability.animation(...arguments);
}, // fnOnConfirm
team: this._targetTeam,
id: crea.id,
flipped: crea.player.flipped,
hexes: crea.getHexMap(matrices.frontnback2hex),
hexes: crea.getHexMap(matrices.frontnback2hex, false),
});
},

// activate() :
activate: function (target) {
activate: function (target: Creature) {
const ability = this;
ability.end();
G.Phaser.camera.shake(0.01, 150, true, G.Phaser.camera.SHAKE_HORIZONTAL, true);
Expand Down Expand Up @@ -210,14 +208,12 @@ export default (G) => {
),
];

choices[0].choiceId = 0;
choices[1].choiceId = 1;

G.grid.queryChoice({
fnOnCancel: function () {
G.activeCreature.queryMove();
},
fnOnConfirm: function () {
// eslint-disable-next-line
ability.animation(...arguments);
},
team: Team.Both,
Expand All @@ -228,7 +224,7 @@ export default (G) => {
},

// activate() :
activate: function (choice) {
activate: function (choice: Hex[]) {
const ability = this;
ability.end();
G.Phaser.camera.shake(0.02, 350, true, G.Phaser.camera.SHAKE_HORIZONTAL, true);
Expand All @@ -238,8 +234,9 @@ export default (G) => {
const straitrow = matrices.straitrow;
const bellowrow = matrices.bellowrow;

let rows;
if (choice.choiceId === 0) {
let rows: Hex[][];
// Check to first hex to determine which direction was chosen
if (choice[0].x >= this.creature.x) {
// Front
rows = [
arrayUtils.filterCreature(
Expand Down Expand Up @@ -338,6 +335,7 @@ export default (G) => {

G.grid.queryCreature({
fnOnConfirm: function () {
// eslint-disable-next-line
ability.animation(...arguments);
}, // fnOnConfirm
team: Team.Enemy,
Expand All @@ -348,7 +346,7 @@ export default (G) => {
},

// activate() :
activate: function (crea) {
activate: function (crea: Creature) {
const ability = this;
ability.end();
G.Phaser.camera.shake(0.03, 333, true, G.Phaser.camera.SHAKE_VERTICAL, true);
Expand Down
2 changes: 1 addition & 1 deletion src/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ export class Ability {
*
* @param hexes Array of hexes to test.
* @param {Object} o
* @return At least one valid target?
* @return bool
*/
atLeastOneTarget(hexes: Hex[], o): boolean {
const defaultOpt = {
Expand Down
Loading