Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/math/random-data-generator/RandomDataGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ var RandomDataGenerator = new Class({
* @since 3.0.0
*
* @generic T
* @genericUse {T[]} - [array]
* @genericUse {ArrayLike<T>} - [array]
* @genericUse {T} - [$return]
*
* @param {T[]} array - The array to pick a random element from.
* @param {ArrayLike<T>} array - The array (or array-like object) to pick a random element from.
*
* @return {T} A random member of the array.
*/
Expand All @@ -370,6 +370,8 @@ var RandomDataGenerator = new Class({
*
* @return {number} -1 or +1.
*/
// NB: Catharsis (the underlying parser used by JSDoc) does not support parsing negative numbers inside types.
// Moreover, the `jsdoc` package used for typegen is (effectively) unmaintained, preventing us from typing this as `-1 | 1`.
sign: function ()
{
return this.pick(this.signs);
Expand All @@ -382,10 +384,10 @@ var RandomDataGenerator = new Class({
* @since 3.0.0
*
* @generic T
* @genericUse {T[]} - [array]
* @genericUse {ArrayLike<T>} - [array]
* @genericUse {T} - [$return]
*
* @param {T[]} array - The array to pick a random element from.
* @param {ArrayLike<T>} array - The array (or array-like object) to pick a random element from.
*
* @return {T} A random member of the array.
*/
Expand Down
23 changes: 14 additions & 9 deletions types/phaser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90353,10 +90353,10 @@ declare namespace Phaser {

/**
* Returns a random element from within the given array.
* @param array The array to pick a random element from.
* @param array The array (or array-like object) to pick a random element from.
* @returns A random member of the array.
*/
pick<T>(array: T[]): T;
pick<T>(array: ArrayLike<T>): T;

/**
* Returns a randomly selected sign value, either -1 or +1. Useful for multiplying a value
Expand All @@ -90367,10 +90367,10 @@ declare namespace Phaser {

/**
* Returns a random element from within the given array, favoring the earlier entries.
* @param array The array to pick a random element from.
* @param array The array (or array-like object) to pick a random element from.
* @returns A random member of the array.
*/
weightedPick<T>(array: T[]): T;
weightedPick<T>(array: ArrayLike<T>): T;

/**
* Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.
Expand Down Expand Up @@ -130528,7 +130528,8 @@ declare namespace Phaser {
* @param y The y coordinate of the pixel within the Texture.
* @param key The unique string-based key of the Texture.
* @param frame The string or index of the Frame.
* @returns A Color object populated with the color values of the requested pixel,or `null` if the coordinates were out of bounds.
* @returns A Color object populated with the color values of the requested pixel,
* or `null` if the coordinates were out of bounds.
*/
getPixel(x: number, y: number, key: string, frame?: string | number): Phaser.Display.Color | null;

Expand Down Expand Up @@ -131924,7 +131925,8 @@ declare namespace Phaser {
* GID this set will use here. Default 0.
* @param tileOffset Tile texture drawing offset.
* If not specified, it will default to {0, 0} Default {x: 0, y: 0}.
* @returns Returns the Tileset object that was created or updated, or null if itfailed.
* @returns Returns the Tileset object that was created or updated, or null if it
* failed.
*/
addTilesetImage(tilesetName: string, key?: string, tileWidth?: number, tileHeight?: number, tileMargin?: number, tileSpacing?: number, gid?: number, tileOffset?: object): Phaser.Tilemaps.Tileset | null;

Expand Down Expand Up @@ -137833,7 +137835,8 @@ declare namespace Phaser {
* Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index.
* Returns null if tile index is not contained in this Tileset.
* @param tileIndex The unique id of the tile across all tilesets in the map.
* @returns Object in the form { x, y } representing the top-left UV coordinatewithin the Tileset image.
* @returns Object in the form { x, y } representing the top-left UV coordinate
* within the Tileset image.
*/
getTileTextureCoordinates(tileIndex: number): object | null;

Expand Down Expand Up @@ -139243,7 +139246,8 @@ declare namespace Phaser {
* @param insertNull Controls how empty tiles (those with an index of -1) are stored in
* the LayerData. If `true`, empty tile positions are stored as `null`. If `false`, a Tile object
* with an index of -1 is created for each empty position instead.
* @returns - An array of LayerData objects, one for each entry injson.layer.
* @returns - An array of LayerData objects, one for each entry in
* json.layer.
*/
function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[];

Expand Down Expand Up @@ -139412,7 +139416,8 @@ declare namespace Phaser {
* @param json The Tiled JSON object.
* @param insertNull Controls how empty tiles, tiles with an index of -1, in the map
* data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}).
* @returns - An array of LayerData objects, one for each entry injson.layers with the type 'tilelayer'.
* @returns - An array of LayerData objects, one for each entry in
* json.layers with the type 'tilelayer'.
*/
function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[];

Expand Down