Compare commits

...

11 Commits

Author SHA1 Message Date
Benjamin Odom
8d3c334e50
Fix move.ts Errors (#1564) 2024-05-29 11:54:33 -04:00
Xavion3
1b7b539d68
Implements Supreme Overlord and fixes Last Respects (#1219)
* Implements Supreme Overlord

Also fixes count for Last Respects

* Add comments
2024-05-29 11:07:59 -04:00
Flora A
2fcde2907d
Added support for Pro Controller mapping (#1492) 2024-05-29 16:59:39 +02:00
Greenlamp2
c7fbf5b707
Merge pull request #1323 from JakubHanko/eslint_fix
Add ESLint flat config support
2024-05-29 16:53:23 +02:00
Greenlamp2
6b99eda84a
small detail in ui-inputs, was still working but not whitelisting keys, not sure if still needed though (#1560) 2024-05-29 14:33:36 +01:00
Benjamin Odom
a880185289
Fix Errors in ui-inputs.ts (#1549) 2024-05-29 13:16:57 +01:00
Jannik Tappert
9e0fd33510
Type Icons are now also localized when learning a new move (#1557) 2024-05-29 11:35:54 +01:00
Jakub Hanko
d024b840bf
Another try to fix ESLint CI run 2024-05-24 17:03:22 +02:00
Jakub Hanko
ab31247bd8
Fix ESLint action 2024-05-24 16:54:21 +02:00
Jakub Hanko
9a45e46900
Add empty line at the end of config 2024-05-24 16:41:46 +02:00
Jakub Hanko
80cd570b14
Add ESLint flat config support 2024-05-24 16:37:42 +02:00
13 changed files with 170 additions and 80 deletions

View File

@ -1,7 +0,0 @@
dist/*
build/*
coverage/*
public/*
.github/*
node_modules/*
.vscode/*

View File

@ -1,35 +0,0 @@
{
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser for TypeScript
"plugins": ["@typescript-eslint", "import"], // Includes TypeScript and import plugins
"overrides": [
{
"files": ["src/**/*.{ts,tsx,js,jsx}"], // Applies these rules to all TypeScript and JavaScript files in the src directory
"rules": {
// General rules that apply to all files
"eqeqeq": ["error", "always"], // Enforces the use of === and !== instead of == and !=
"indent": ["error", 2], // Enforces a 2-space indentation
"quotes": ["error", "double"], // Enforces the use of double quotes for strings
"no-var": "error", // Disallows the use of var, enforcing let or const instead
"prefer-const": "error", // Prefers the use of const for variables that are never reassigned
"no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this)
"@typescript-eslint/no-unused-vars": [ "error", {
"args": "none", // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used.
"ignoreRestSiblings": true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the rest.
}],
"eol-last": ["error", "always"], // Enforces at least one newline at the end of files
"@typescript-eslint/semi": ["error", "always"], // Requires semicolons for TypeScript-specific syntax
"semi": "off", // Disables the general semi rule for TypeScript files
"@typescript-eslint/no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax
"brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors
"curly": ["error", "all"], // Enforces the use of curly braces for all control statements
"@typescript-eslint/brace-style": ["error", "1tbs"],
"no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines
"skipBlankLines": false, // Enforces the rule even on blank lines
"ignoreComments": false // Enforces the rule on lines containing comments
}],
"space-before-blocks": ["error", "always"], // Enforces a space before blocks
"keyword-spacing": ["error", { "before": true, "after": true }] // Enforces spacing before and after keywords
}
}
]
}

View File

@ -28,4 +28,4 @@ jobs:
run: npm ci # Use 'npm ci' to install dependencies
- name: eslint # Step to run linters
uses: icrawl/action-eslint@v1
run: npm run eslint-ci

42
eslint.config.js Normal file
View File

@ -0,0 +1,42 @@
import tseslint from '@typescript-eslint/eslint-plugin';
import parser from '@typescript-eslint/parser';
import imports from 'eslint-plugin-import';
export default [
{
files: ["src/**/*.{ts,tsx,js,jsx}"],
ignores: ["dist/*", "build/*", "coverage/*", "public/*", ".github/*", "node_modules/*", ".vscode/*"],
languageOptions: {
parser: parser
},
plugins: {
imports: imports.configs.recommended,
'@typescript-eslint': tseslint
},
rules: {
"eqeqeq": ["error", "always"], // Enforces the use of === and !== instead of == and !=
"indent": ["error", 2], // Enforces a 2-space indentation
"quotes": ["error", "double"], // Enforces the use of double quotes for strings
"no-var": "error", // Disallows the use of var, enforcing let or const instead
"prefer-const": "error", // Prefers the use of const for variables that are never reassigned
"no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this)
"@typescript-eslint/no-unused-vars": [ "error", {
"args": "none", // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used.
"ignoreRestSiblings": true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the rest.
}],
"eol-last": ["error", "always"], // Enforces at least one newline at the end of files
"@typescript-eslint/semi": ["error", "always"], // Requires semicolons for TypeScript-specific syntax
"semi": "off", // Disables the general semi rule for TypeScript files
"no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax
"brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors
"curly": ["error", "all"], // Enforces the use of curly braces for all control statements
"@typescript-eslint/brace-style": ["error", "1tbs"],
"no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines
"skipBlankLines": false, // Enforces the rule even on blank lines
"ignoreComments": false // Enforces the rule on lines containing comments
}],
"space-before-blocks": ["error", "always"], // Enforces a space before blocks
"keyword-spacing": ["error", { "before": true, "after": true }] // Enforces spacing before and after keywords
}
}
]

View File

@ -11,7 +11,8 @@
"test": "vitest run",
"test:cov": "vitest run --coverage",
"test:watch": "vitest watch --coverage",
"eslint": "eslint --fix ."
"eslint": "eslint --fix .",
"eslint-ci": "eslint ."
},
"devDependencies": {
"@eslint/js": "^9.3.0",

View File

@ -63,6 +63,8 @@ export default class Battle {
private battleSeedState: string;
public moneyScattered: number;
public lastUsedPokeball: PokeballType;
public playerFaints: number; // The amount of times pokemon on the players side have fainted
public enemyFaints: number; // The amount of times pokemon on the enemies side have fainted
private rngCounter: integer = 0;
@ -89,6 +91,8 @@ export default class Battle {
this.battleSeedState = null;
this.moneyScattered = 0;
this.lastUsedPokeball = null;
this.playerFaints = 0;
this.enemyFaints = 0;
}
private initBattleSpec(): void {

28
src/configs/pad_procon.ts Normal file
View File

@ -0,0 +1,28 @@
/**
* Nintendo Pro Controller mapping
*/
const pad_procon = {
padID: "Pro Controller",
padType: "Nintendo",
gamepadMapping: {
RC_S: 1,
RC_E: 0,
RC_W: 3,
RC_N: 2,
START: 9, // +
SELECT: 8, // -
LB: 4,
RB: 5,
LT: 6,
RT: 7,
LS: 10,
RS: 11,
LC_N: 12,
LC_S: 13,
LC_W: 14,
LC_E: 15,
MENU: 16, // Home
},
};
export default pad_procon;

View File

@ -1083,6 +1083,37 @@ export class LowHpMoveTypePowerBoostAbAttr extends MoveTypePowerBoostAbAttr {
}
}
/**
* Abilities which cause a variable amount of power increase.
* @extends VariableMovePowerAbAttr
* @see {@link applyPreAttack}
*/
export class VariableMovePowerBoostAbAttr extends VariableMovePowerAbAttr {
private mult: (user: Pokemon, target: Pokemon, move: Move) => number;
/**
* @param mult A function which takes the user, target, and move, and returns the power multiplier. 1 means no multiplier.
* @param {boolean} showAbility Whether to show the ability when it activates.
*/
constructor(mult: (user: Pokemon, target: Pokemon, move: Move) => number, showAbility: boolean = true) {
super(showAbility);
this.mult = mult;
}
/**
* @override
*/
applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: PokemonMove, args: any[]): boolean {
const multiplier = this.mult(pokemon, defender, move.getMove());
if (multiplier !== 1) {
(args[0] as Utils.NumberHolder).value *= multiplier;
return true;
}
return false;
}
}
export class FieldVariableMovePowerAbAttr extends AbAttr {
applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: PokemonMove, args: any[]): boolean {
//const power = args[0] as Utils.NumberHolder;
@ -4251,7 +4282,8 @@ export function initAbilities() {
new Ability(Abilities.SHARPNESS, 9)
.attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5),
new Ability(Abilities.SUPREME_OVERLORD, 9)
.unimplemented(),
.attr(VariableMovePowerBoostAbAttr, (user, target, move) => 1 + 0.1 * Math.min(user.isPlayer() ? user.scene.currentBattle.playerFaints : user.scene.currentBattle.enemyFaints, 5))
.partial(),
new Ability(Abilities.COSTAR, 9)
.unimplemented(),
new Ability(Abilities.TOXIC_DEBRIS, 9)

View File

@ -144,8 +144,8 @@ export default class Move implements Localizable {
localize(): void {
const i18nKey = Moves[this.id].split("_").filter(f => f).map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join("") as unknown as string;
this.name = this.id ? `${i18next.t(`move:${i18nKey}.name`).toString()}${this.nameAppend}` : "";
this.effect = this.id ? `${i18next.t(`move:${i18nKey}.effect`).toString()}${this.nameAppend}` : "";
this.name = this.id ? `${i18next.t(`move:${i18nKey}.name`)}${this.nameAppend}` : "";
this.effect = this.id ? `${i18next.t(`move:${i18nKey}.effect`)}${this.nameAppend}` : "";
}
getAttrs(attrType: { new(...args: any[]): MoveAttr }): MoveAttr[] {
@ -2011,10 +2011,10 @@ export class PostVictoryStatChangeAttr extends MoveAttr {
}
applyPostVictory(user: Pokemon, target: Pokemon, move: Move): void {
if (this.condition && !this.condition(user, target, move)) {
return false;
return;
}
const statChangeAttr = new StatChangeAttr(this.stats, this.levels, this.showMessage);
statChangeAttr.apply(user, target, move);
statChangeAttr.apply(user, target, move, undefined);
}
}
@ -7508,10 +7508,7 @@ export function initMoves() {
.attr(ConfuseAttr)
.recklessMove(),
new AttackMove(Moves.LAST_RESPECTS, Type.GHOST, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 9)
.attr(MovePowerMultiplierAttr, (user, target, move) => {
return user.scene.getParty().reduce((acc, pokemonInParty) => acc + (pokemonInParty.status?.effect === StatusEffect.FAINT ? 1 : 0),
1,);
})
.attr(MovePowerMultiplierAttr, (user, target, move) => 1 + Math.min(user.isPlayer() ? user.scene.currentBattle.playerFaints : user.scene.currentBattle.enemyFaints, 100))
.makesContact(false),
new AttackMove(Moves.LUMINA_CRASH, Type.PSYCHIC, MoveCategory.SPECIAL, 80, 100, 10, 100, 0, 9)
.attr(StatChangeAttr, BattleStat.SPDEF, -2),

View File

@ -5,6 +5,7 @@ import pad_generic from "./configs/pad_generic";
import pad_unlicensedSNES from "./configs/pad_unlicensedSNES";
import pad_xbox360 from "./configs/pad_xbox360";
import pad_dualshock from "./configs/pad_dualshock";
import pad_procon from "./configs/pad_procon";
import {Button} from "./enums/buttons";
import BattleScene from "./battle-scene";
@ -422,6 +423,7 @@ export class InputsController {
* - If the ID includes both '081f' and 'e401', it is identified as an unlicensed SNES gamepad.
* - If the ID contains 'xbox' and '360', it is identified as an Xbox 360 gamepad.
* - If the ID contains '054c', it is identified as a DualShock gamepad.
* - If the ID includes both '057e' and '2009', it is identified as a Pro controller gamepad.
* If no specific identifiers are recognized, a generic gamepad configuration is returned.
*/
mapGamepad(id: string): GamepadConfig {
@ -433,6 +435,8 @@ export class InputsController {
return pad_xbox360;
} else if (id.includes("054c")) {
return pad_dualshock;
} else if (id.includes("057e") && id.includes("2009")) {
return pad_procon;
}
return pad_generic;

View File

@ -3491,6 +3491,13 @@ export class FaintPhase extends PokemonPhase {
doFaint(): void {
const pokemon = this.getPokemon();
// Track total times pokemon have been KO'd for supreme overlord/last respects
if (pokemon.isPlayer()) {
this.scene.currentBattle.playerFaints += 1;
} else {
this.scene.currentBattle.enemyFaints += 1;
}
this.scene.queueMessage(getPokemonMessage(pokemon, " fainted!"), null, true);
if (pokemon.turnData?.attacksReceived?.length) {

View File

@ -6,17 +6,16 @@ import StarterSelectUiHandler from "./ui/starter-select-ui-handler";
import {Setting, settingOptions} from "./system/settings";
import SettingsUiHandler from "./ui/settings-ui-handler";
import {Button} from "./enums/buttons";
import BattleScene from "./battle-scene";
export interface ActionKeys {
[key in Button]: () => void;
}
type ActionKeys = Record<Button, () => void>;
export class UiInputs {
private scene: Phaser.Scene;
private events: Phaser.Events;
private scene: BattleScene;
private events: Phaser.Events.EventEmitter;
private inputsController: InputsController;
constructor(scene: Phaser.Scene, inputsController: InputsController) {
constructor(scene: BattleScene, inputsController: InputsController) {
this.scene = scene;
this.inputsController = inputsController;
this.init();
@ -52,30 +51,48 @@ export class UiInputs {
}
getActionsKeyDown(): ActionKeys {
const actions = {};
actions[Button.UP] = () => this.buttonDirection(Button.UP);
actions[Button.DOWN] = () => this.buttonDirection(Button.DOWN);
actions[Button.LEFT] = () => this.buttonDirection(Button.LEFT);
actions[Button.RIGHT] = () => this.buttonDirection(Button.RIGHT);
actions[Button.SUBMIT] = () => this.buttonTouch();
actions[Button.ACTION] = () => this.buttonAb(Button.ACTION);
actions[Button.CANCEL] = () => this.buttonAb(Button.CANCEL);
actions[Button.MENU] = () => this.buttonMenu();
actions[Button.STATS] = () => this.buttonStats(true);
actions[Button.CYCLE_SHINY] = () => this.buttonCycleOption(Button.CYCLE_SHINY);
actions[Button.CYCLE_FORM] = () => this.buttonCycleOption(Button.CYCLE_FORM);
actions[Button.CYCLE_GENDER] = () => this.buttonCycleOption(Button.CYCLE_GENDER);
actions[Button.CYCLE_ABILITY] = () => this.buttonCycleOption(Button.CYCLE_ABILITY);
actions[Button.CYCLE_NATURE] = () => this.buttonCycleOption(Button.CYCLE_NATURE);
actions[Button.CYCLE_VARIANT] = () => this.buttonCycleOption(Button.CYCLE_VARIANT);
actions[Button.SPEED_UP] = () => this.buttonSpeedChange();
actions[Button.SLOW_DOWN] = () => this.buttonSpeedChange(false);
const actions: ActionKeys = {
[Button.UP]: () => this.buttonDirection(Button.UP),
[Button.DOWN]: () => this.buttonDirection(Button.DOWN),
[Button.LEFT]: () => this.buttonDirection(Button.LEFT),
[Button.RIGHT]: () => this.buttonDirection(Button.RIGHT),
[Button.SUBMIT]: () => this.buttonTouch(),
[Button.ACTION]: () => this.buttonAb(Button.ACTION),
[Button.CANCEL]: () => this.buttonAb(Button.CANCEL),
[Button.MENU]: () => this.buttonMenu(),
[Button.STATS]: () => this.buttonStats(true),
[Button.CYCLE_SHINY]: () => this.buttonCycleOption(Button.CYCLE_SHINY),
[Button.CYCLE_FORM]: () => this.buttonCycleOption(Button.CYCLE_FORM),
[Button.CYCLE_GENDER]: () => this.buttonCycleOption(Button.CYCLE_GENDER),
[Button.CYCLE_ABILITY]: () => this.buttonCycleOption(Button.CYCLE_ABILITY),
[Button.CYCLE_NATURE]: () => this.buttonCycleOption(Button.CYCLE_NATURE),
[Button.CYCLE_VARIANT]: () => this.buttonCycleOption(Button.CYCLE_VARIANT),
[Button.SPEED_UP]: () => this.buttonSpeedChange(),
[Button.SLOW_DOWN]: () => this.buttonSpeedChange(false),
};
return actions;
}
getActionsKeyUp(): ActionKeys {
const actions = {};
actions[Button.STATS] = () => this.buttonStats(false);
const actions: ActionKeys = {
[Button.UP]: () => undefined,
[Button.DOWN]: () => undefined,
[Button.LEFT]: () => undefined,
[Button.RIGHT]: () => undefined,
[Button.SUBMIT]: () => undefined,
[Button.ACTION]: () => undefined,
[Button.CANCEL]: () => undefined,
[Button.MENU]: () => undefined,
[Button.STATS]: () => this.buttonStats(false),
[Button.CYCLE_SHINY]: () => undefined,
[Button.CYCLE_FORM]: () => undefined,
[Button.CYCLE_GENDER]: () => undefined,
[Button.CYCLE_ABILITY]: () => undefined,
[Button.CYCLE_NATURE]: () => undefined,
[Button.CYCLE_VARIANT]: () => undefined,
[Button.SPEED_UP]: () => undefined,
[Button.SLOW_DOWN]: () => undefined,
};
return actions;
}

View File

@ -897,7 +897,7 @@ export default class SummaryUiHandler extends UiHandler {
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) {
this.extraMoveRowContainer.setVisible(true);
const newMoveTypeIcon = this.scene.add.sprite(0, 0, "types", Type[this.newMove.type].toLowerCase());
const newMoveTypeIcon = this.scene.add.sprite(0, 0, `types${Utils.verifyLang(i18next.language) ? `_${i18next.language}` : ""}`, Type[this.newMove.type].toLowerCase());
newMoveTypeIcon.setOrigin(0, 1);
this.extraMoveRowContainer.add(newMoveTypeIcon);