mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-16 14:01:52 +00:00
bac6c22973
* eslint config + packages * updated eslint config * fix the issue eslint adding ;;;; at interfaces * first round with eslint --fix . * removed config for unused export * Revert "first round with eslint --fix ." This reverts commit 77a88e0895f7c3389cb223651b90d918af778fe9. * removed config for camelCase * for real this time, first round of eslint --fix . * halfway to manual eslint fix * eslint done * added "how to setup" the hook to eslint --fix each new file before commit (if wanted) * removed eslintrc config file duplicat * fix human error + ignore build folder + merge overrides * added curly brace style + eslint * applied double quote linter rule * added lefthook * test precommit * test precommit * test precommit * test precommit * test precommit * test precommit * test precommit * github action to run eslint * added node_modules to ignore eslint * different action for typescript * no need for different glob (default src) * node 20 * node 20 * removed no longer needed install file * remove hooks part from README * eslint fixes --------- Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt>
84 lines
2.0 KiB
TypeScript
84 lines
2.0 KiB
TypeScript
import Pokemon from "../field/pokemon";
|
|
import Move from "./move";
|
|
import { Type } from "./type";
|
|
import * as Utils from "../utils";
|
|
import { IncrementMovePriorityAbAttr, applyAbAttrs } from "./ability";
|
|
import { ProtectAttr } from "./move";
|
|
import { BattlerIndex } from "#app/battle.js";
|
|
|
|
export enum TerrainType {
|
|
NONE,
|
|
MISTY,
|
|
ELECTRIC,
|
|
GRASSY,
|
|
PSYCHIC
|
|
}
|
|
|
|
export class Terrain {
|
|
public terrainType: TerrainType;
|
|
public turnsLeft: integer;
|
|
|
|
constructor(terrainType: TerrainType, turnsLeft?: integer) {
|
|
this.terrainType = terrainType;
|
|
this.turnsLeft = turnsLeft || 0;
|
|
}
|
|
|
|
lapse(): boolean {
|
|
if (this.turnsLeft) {
|
|
return !!--this.turnsLeft;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
getAttackTypeMultiplier(attackType: Type): number {
|
|
switch (this.terrainType) {
|
|
case TerrainType.ELECTRIC:
|
|
if (attackType === Type.ELECTRIC) {
|
|
return 1.3;
|
|
}
|
|
break;
|
|
case TerrainType.GRASSY:
|
|
if (attackType === Type.GRASS) {
|
|
return 1.3;
|
|
}
|
|
break;
|
|
case TerrainType.PSYCHIC:
|
|
if (attackType === Type.PSYCHIC) {
|
|
return 1.3;
|
|
}
|
|
break;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
isMoveTerrainCancelled(user: Pokemon, targets: BattlerIndex[], move: Move): boolean {
|
|
switch (this.terrainType) {
|
|
case TerrainType.PSYCHIC:
|
|
if (!move.getAttrs(ProtectAttr).length) {
|
|
const priority = new Utils.IntegerHolder(move.priority);
|
|
applyAbAttrs(IncrementMovePriorityAbAttr, user, null, move, priority);
|
|
return priority.value > 0 && user.getOpponents().filter(o => targets.includes(o.getBattlerIndex())).length > 0;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function getTerrainColor(terrainType: TerrainType): [ integer, integer, integer ] {
|
|
switch (terrainType) {
|
|
case TerrainType.MISTY:
|
|
return [ 232, 136, 200 ];
|
|
case TerrainType.ELECTRIC:
|
|
return [ 248, 248, 120 ];
|
|
case TerrainType.GRASSY:
|
|
return [ 120, 200, 80 ];
|
|
case TerrainType.PSYCHIC:
|
|
return [ 160, 64, 160 ];
|
|
}
|
|
|
|
return [ 0, 0, 0 ];
|
|
}
|