Skip to content

Commit

Permalink
adjust various types
Browse files Browse the repository at this point in the history
added some missing properties that get extended into the Abilities class
  • Loading branch information
allmtz committed Jul 30, 2023
1 parent 50884be commit 8577207
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export type Trigger =
// 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`
type Cost = {
special: string;
special?: string;
plasma?: string | number;
energy?: number;
};

type Requirement = { plasma: number; energy?: number } | Cost;
type Requirement = { plasma?: number; energy?: number } | Cost;

type Target = { hexesHit: number; target: Creature };

Expand All @@ -60,6 +60,9 @@ type AbilityEffect = {
frost?: number;
};

type OffesnsiveBuff = number;
type DefensiveBuff = number;

export class Ability {
creature: Creature;
game: Game;
Expand All @@ -81,16 +84,26 @@ export class Ability {
require?: (damage?: Damage, hex?: Hex) => boolean;
query?: () => unknown;
affectedByMatSickness?: boolean;
activate?: (...args: unknown[]) => unknown;
activate?: (target?: any, hex?: any, path?: any) => unknown;
getAnimationData?: (...args: unknown[]) => unknown;
damages?: CreatureMasteries & { pure?: number | string };
damages?: CreatureMasteries & { pure?: number };
effects?: AbilityEffect[];
message?: string;
movementType?: () => 'flying'; // Currently, this functon only exists in `Scavenger.js`
triggeredThisChain?: boolean;

_disableCooldowns: boolean;

_energyNormal?: number;
_energySelfUpgraded: number;
mbuff?: OffesnsiveBuff;
obuff?: DefensiveBuff;
abilityName?: string;
// TODO: Once all abilities files are converted to TS, look into deleteing the `name` param as it appears unecessary
getAbilityName?: (name: string) => string;
getMovementBuff?: (buff: number) => number;
getOffenseBuff?: (buff: number) => number;
_targetTeam: Team;
constructor(creature: Creature, abilityID: AbilitySlot, game: Game) {
this.creature = creature;
this.game = game;
Expand Down Expand Up @@ -221,8 +234,9 @@ export class Ability {
/*
* End the ability. Must be called at the end of each ability function;
*
* TODO: Once all files in `abilities` are converted to TS, consider defaulting both of these arguments to `false`.
*/
end(disableLogMsg: boolean, deferredEnding: boolean) {
end(disableLogMsg?: boolean, deferredEnding?: boolean) {
const game = this.game;

if (!disableLogMsg) {
Expand Down

0 comments on commit 8577207

Please sign in to comment.