mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-08 09:58:03 +00:00
56 lines
1.1 KiB
TypeScript
56 lines
1.1 KiB
TypeScript
|
import { Type } from "./type";
|
||
|
|
||
|
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.GRASSY:
|
||
|
if (attackType === Type.GRASS)
|
||
|
return 1.3;
|
||
|
break;
|
||
|
case TerrainType.PSYCHIC:
|
||
|
if (attackType === Type.PSYCHIC)
|
||
|
return 1.3;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export function getTerrainColor(terrainType: TerrainType): [ integer, integer, integer ] {
|
||
|
switch (terrainType) {
|
||
|
case TerrainType.GRASSY:
|
||
|
return [ 120, 200, 80 ];
|
||
|
case TerrainType.MISTY:
|
||
|
return [ 232, 136, 200 ];
|
||
|
case TerrainType.ELECTRIC:
|
||
|
return [ 248, 248, 120 ];
|
||
|
case TerrainType.PSYCHIC:
|
||
|
return [ 160, 64, 160 ];
|
||
|
}
|
||
|
|
||
|
return [ 0, 0, 0 ];
|
||
|
}
|