mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 17:12:44 +02:00
* [Refactor] Create utility function `makeArray` This replaces the `if(!Array.isArray(var)) { var = [var] }` pattern * Replace `if` with ternary, rename to `coerceArray` * Add TSDocs * Improve type inferencing * Replace missed `Array.isArray` checks * Apply Biome * Re-apply changes to phase manager * Re-apply to `SpeciesFormChangeStatusEffectTrigger` constructor Apply to new instances in test mocks
103 lines
2.0 KiB
TypeScript
103 lines
2.0 KiB
TypeScript
import { coerceArray } from "#app/utils/common";
|
|
import type { MockGameObject } from "../mockGameObject";
|
|
|
|
export default 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;
|
|
}
|
|
}
|