mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-20 16:42:45 +02:00
* Grabbed reverted changes from stuff
* Added version migrator for rage fist data + deepMergeSpriteData tests
* fixed formattign
* Fied a few
* Fixed constructor (maybe), moved deepCopy and deepMergeSpriteData to own file
`common.ts` is hella bloated so seems legit
* Moved empty moveset verification mapping thing to upgrade script bc i wanted to
* Fixed tests
* test added
* Fixed summondata being cleared inside summonPhase, removed `summonDataPrimer`
like seriously how come no-one checked this
* Fixed test
I forgot that we outsped and oneshot
* Fixed test
* huhjjjjjb
* Hopefully fixed bug
my sanity and homework are paying the price for this lol
* added commented out console.log statement
uncomment to see new berry data
* Fixed migrate script, re-added deprecated attributes out of necessity
* Fixed failing test by not trying to mock rng
* Fixed test
* Fixed tests
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update overrides.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update berry-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update encounter-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update game-data.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Added utility function `randSeedFloat`
basically just `Phaser.math.RND.realInRange(0, 1)`
* Applied review comments, cleaned up code a bit
* Removed unnecessary null checks for turnData and co.
I explicitly made them initialized by default for this very reason
* Added tests for Last Resort regarding moveHistory
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update battle-scene.ts
Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
* Update the-winstrate-challenge-encounter.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update battle-anims.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts comments
* Fixed a few outstanding issues with documentation
* Updated switch summon phase comment
* Re-added BattleSummonData as TempSummonData
* Hppefully fixed -1 sprite scale glitch
* Fixed comment
* Reveted `pokemon-forms.ts`
* Fuxed constructor
* fixed -1 bug
* Revert "Added utility function `randSeedFloat`"
This reverts commit 4c3447c851
.
---------
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import { expect, describe, it, beforeAll } from "vitest";
|
|
import { randomString, padInt } from "#app/utils/common";
|
|
import { deepMergeSpriteData } from "#app/utils/data";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
describe("utils", () => {
|
|
beforeAll(() => {
|
|
new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
describe("randomString", () => {
|
|
it("should return a string of the specified length", () => {
|
|
const str = randomString(10);
|
|
expect(str.length).toBe(10);
|
|
});
|
|
|
|
it("should work with seed", () => {
|
|
const state = Phaser.Math.RND.state();
|
|
const str1 = randomString(10, true);
|
|
Phaser.Math.RND.state(state);
|
|
const str2 = randomString(10, true);
|
|
|
|
expect(str1).toBe(str2);
|
|
});
|
|
});
|
|
|
|
describe("padInt", () => {
|
|
it("should return a string", () => {
|
|
const result = padInt(1, 10);
|
|
expect(typeof result).toBe("string");
|
|
});
|
|
|
|
it("should return a padded result with default padWith", () => {
|
|
const result = padInt(1, 3);
|
|
expect(result).toBe("001");
|
|
});
|
|
|
|
it("should return a padded result using a custom padWith", () => {
|
|
const result = padInt(1, 10, "yes");
|
|
expect(result).toBe("yesyesyes1");
|
|
});
|
|
|
|
it("should return inputted value when zero length is entered", () => {
|
|
const result = padInt(1, 0);
|
|
expect(result).toBe("1");
|
|
});
|
|
});
|
|
describe("deepMergeSpriteData", () => {
|
|
it("should merge two objects' common properties", () => {
|
|
const dest = { a: 1, b: 2 };
|
|
const source = { a: 3, b: 3, e: 4 };
|
|
deepMergeSpriteData(dest, source);
|
|
expect(dest).toEqual({ a: 3, b: 3 });
|
|
});
|
|
|
|
it("does nothing for identical objects", () => {
|
|
const dest = { a: 1, b: 2 };
|
|
const source = { a: 1, b: 2 };
|
|
deepMergeSpriteData(dest, source);
|
|
expect(dest).toEqual({ a: 1, b: 2 });
|
|
});
|
|
|
|
it("should preserve missing and mistyped properties", () => {
|
|
const dest = { a: 1, c: 56, d: "test" };
|
|
const source = { a: "apple", b: 3, d: "no hablo español" };
|
|
deepMergeSpriteData(dest, source);
|
|
expect(dest).toEqual({ a: 1, c: 56, d: "no hablo español" });
|
|
});
|
|
|
|
it("should copy arrays verbatim even with mismatches", () => {
|
|
const dest = { a: 1, b: [{ d: 1 }, { d: 2 }, { d: 3 }] };
|
|
const source = { a: 3, b: [{ c: [4, 5] }, { p: [7, 8] }], e: 4 };
|
|
deepMergeSpriteData(dest, source);
|
|
expect(dest).toEqual({ a: 3, b: [{ c: [4, 5] }, { p: [7, 8] }] });
|
|
});
|
|
});
|
|
});
|