pokerogue/test/testUtils/helpers/modifiersHelper.ts

60 lines
2.0 KiB
TypeScript
Raw Normal View History

[Daily] Daily standardization (#3776) * Disable Luck in Daily Runs If the Game Mode is Daily Run, the player's Luck is set to 0, and the Luck value is hidden. * Give free map in daily Adds a Map to the player's pool of starting items for Daily Runs. * Disable Eviolite in Daily Runs Disables Eviolite spawning in Daily Run mode. * Write shop test and add new overrides Adds new overrides that allow you to force content to be locked or unlocked These overrides were also added to the OverridesHelper to make them available to tests Adds a new check function for content unlocks, which returns `true` if it is overrode to be unlocked, `false` if it is overrode to be locked, and the unlock data mapped to a Boolean otherwise All existing checks (other than the ones that involve actually unlocking things) for unlockables have been changed to use this Added a pair of new exporting booleans, specifically for my test, that check if Eviolite or Mini Black Hole are in the loot table * Prevent shinies from altering runs Places variant rolls inside of an ExecuteWithSeedOffset block, using the current floor's RNG seed as the seed and the Pokémon's ID as the offset. --------- Co-authored-by: Leo Kim <47556641+KimJeongSun@users.noreply.github.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com>
2024-09-26 04:39:59 -04:00
import { expect } from "vitest";
import { GameManagerHelper } from "./gameManagerHelper";
import type { ModifierTypeKeys } from "#app/modifier/modifier-type";
import { itemPoolChecks } from "#app/modifier/modifier-type";
[Daily] Daily standardization (#3776) * Disable Luck in Daily Runs If the Game Mode is Daily Run, the player's Luck is set to 0, and the Luck value is hidden. * Give free map in daily Adds a Map to the player's pool of starting items for Daily Runs. * Disable Eviolite in Daily Runs Disables Eviolite spawning in Daily Run mode. * Write shop test and add new overrides Adds new overrides that allow you to force content to be locked or unlocked These overrides were also added to the OverridesHelper to make them available to tests Adds a new check function for content unlocks, which returns `true` if it is overrode to be unlocked, `false` if it is overrode to be locked, and the unlock data mapped to a Boolean otherwise All existing checks (other than the ones that involve actually unlocking things) for unlockables have been changed to use this Added a pair of new exporting booleans, specifically for my test, that check if Eviolite or Mini Black Hole are in the loot table * Prevent shinies from altering runs Places variant rolls inside of an ExecuteWithSeedOffset block, using the current floor's RNG seed as the seed and the Pokémon's ID as the offset. --------- Co-authored-by: Leo Kim <47556641+KimJeongSun@users.noreply.github.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com>
2024-09-26 04:39:59 -04:00
export class ModifierHelper extends GameManagerHelper {
/**
* Adds a Modifier to the list of modifiers to check for.
*
* Note that all modifiers are updated during the start of `SelectModifierPhase`.
* @param modifier The Modifier to add.
* @returns `this`
*/
addCheck(modifier: ModifierTypeKeys): this {
itemPoolChecks.set(modifier, undefined);
return this;
}
/**
* `get`s a value from the `itemPoolChecks` map.
*
* If the item is in the Modifier Pool, and the player can get it, will return `true`.
*
* If the item is *not* in the Modifier Pool, will return `false`.
*
* If a `SelectModifierPhase` has not occurred, and we do not know if the item is in the Modifier Pool or not, will return `undefined`.
* @param modifier
* @returns
*/
getCheck(modifier: ModifierTypeKeys): boolean | undefined {
return itemPoolChecks.get(modifier);
}
/**
* `expect`s a Modifier `toBeTruthy` (in the Modifier Pool) or `Falsy` (unobtainable on this floor). Use during a test.
*
* Note that if a `SelectModifierPhase` has not been run yet, these values will be `undefined`, and the check will fail.
* @param modifier The modifier to check.
* @param expectToBePreset Whether the Modifier should be in the Modifier Pool. Set to `false` to expect it to be absent instead.
* @returns `this`
*/
testCheck(modifier: ModifierTypeKeys, expectToBePreset: boolean): this {
if (expectToBePreset) {
expect(itemPoolChecks.get(modifier)).toBeTruthy();
}
expect(itemPoolChecks.get(modifier)).toBeFalsy();
return this;
}
/** Removes all modifier checks. @returns `this` */
clearChecks() {
itemPoolChecks.clear();
return this;
}
private log(...params: any[]) {
console.log("Modifiers:", ...params);
}
}