pokerogue/test/test-utils/mocks/mocks-container/mock-rectangle.ts
Sirz Benjie e5e0835a96
[Misc][Refactor] Add scaffolding for TypedArrays and improve typing on methods related to arrays (#6547)
* make IVs use Uint8Array

* Add many typed array helpers

* Move array utils to its own file

* Add suppression comment

* Adjust type of `getStats`

* Adjust test mocks to use typed arrays

* Adjust signatures of some phases to use ArrayLike<T>

* Adjust signature of src/ui/containers/stats-container#updateIvs

* Remove comment gap to try to satisfy typedoc

* Ensure ivs are always set

* fix: fun-and-games me to use typed array

* Add new tests for array utilities

* Update type of ivs in save-data.ts

* Update part-timer-encounter.test.ts

* Convert uses of StatusEffect[] to Uint8Array

* Update ssui to use uint8array for ivs

* Revert use of typed arrays

* Move `nil` to @types/common

* Make more arrays readonly

* fix: remnant change to immune effects

* Even more array improvements

* Apply kev's suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* address Bertie's comments from code review

* tests: remove undefined check for bigint array types

* fixup abilities.ts

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-10-06 12:21:58 -05:00

103 lines
2.0 KiB
TypeScript

import type { MockGameObject } from "#test/test-utils/mocks/mock-game-object";
import { coerceArray } from "#utils/array";
export class MockRectangle implements MockGameObject {
private fillColor;
private scene;
public list: MockGameObject[] = [];
public name: string;
public active = true;
constructor(textureManager, _x, _y, _width, _height, fillColor) {
this.fillColor = fillColor;
this.scene = textureManager.scene;
}
setOrigin(_x, _y): this {
return this;
}
setAlpha(_alpha): this {
return this;
}
setVisible(_visible): this {
return this;
}
setName(_name): this {
return this;
}
once(_event, _callback, _source): this {
return this;
}
removeFromDisplayList(): this {
// same as remove or destroy
return this;
}
addedToScene() {
// This callback is invoked when this Game Object is added to a Scene.
}
setPositionRelative(_source, _x, _y): this {
/// Sets the position of this Game Object to be a relative position from the source Game Object.
return this;
}
destroy() {
this.list = [];
}
add(obj: MockGameObject | MockGameObject[]): this {
// Adds a child to this Game Object.
this.list.push(...coerceArray(obj));
return this;
}
removeAll() {
// Removes all Game Objects from this Container.
this.list = [];
}
addAt(obj, index): this {
// Adds a Game Object to this Container at the given index.
this.list.splice(index, 0, obj);
return this;
}
remove(obj): this {
const index = this.list.indexOf(obj);
if (index !== -1) {
this.list.splice(index, 1);
}
return this;
}
getIndex(obj) {
const index = this.list.indexOf(obj);
return index || -1;
}
getAt(index) {
return this.list[index];
}
getAll() {
return this.list;
}
setScale(_scale): this {
// return this.phaserText.setScale(scale);
return this;
}
off(): this {
return this;
}
setActive(active: boolean): this {
this.active = active;
return this;
}
}