unite-lib 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -145,6 +145,21 @@ declare function getMapImageUrl(map: Map, resolution?: MapResolution, options?:
145
145
  * Returns spawns for a given map id (e.g. "map-groudon", "map-kyogre", "map-rayquaza").
146
146
  */
147
147
  declare function getSpawnsByMap(mapId: string): MapSpawn[];
148
+ /**
149
+ * Parses game clock "MM:SS" to seconds remaining (e.g. "10:00" → 600, "02:00" → 120).
150
+ */
151
+ declare function parseGameClockToSeconds(clock: string): number;
152
+ /**
153
+ * Returns whether a spawn is visible at the given game clock (seconds remaining).
154
+ * Considers both spawnTime (spawn appears when clock ≤ spawnTime) and despawnTime
155
+ * (spawn disappears when clock ≤ despawnTime, e.g. center Natu/Altaria when boss spawns at 02:00).
156
+ */
157
+ declare function isSpawnVisibleAtGameClock(spawn: MapSpawn, gameClockSeconds: number): boolean;
158
+ /**
159
+ * Returns spawns for a map that are visible at the given game clock (seconds remaining).
160
+ * Use this when you need to show only spawns that have already appeared and not yet despawned.
161
+ */
162
+ declare function getSpawnsByMapVisibleAt(mapId: string, gameClockSeconds: number): MapSpawn[];
148
163
  /**
149
164
  * Returns the neutral by id, or undefined if not found.
150
165
  */
@@ -165,4 +180,4 @@ declare function getPokemonsByBattleType(battleType: BattleType): Pokemon[];
165
180
  declare function getPokemonsByTag(tag: Tag): Pokemon[];
166
181
  declare function getActivePokemons(): Pokemon[];
167
182
 
168
- export { BattleType, type GetImageUrlOptions, type Map, type MapResolution, type MapSpawn, type Move, type MoveSlotId, type Neutral, type Pokemon, type PokemonImages, type PokemonStats, Tag, getActivePokemons, getImageUrl, getMapImageUrl, getNeutralById, getNeutralImageUrl, getPokemonByDex, getPokemonByName, getPokemonBySlug, getPokemonSlug, getPokemonsByBattleType, getPokemonsByTag, getSpawnsByMap, maps, moves, neutrals, pokemons, spawns };
183
+ export { BattleType, type GetImageUrlOptions, type Map, type MapResolution, type MapSpawn, type Move, type MoveSlotId, type Neutral, type Pokemon, type PokemonImages, type PokemonStats, Tag, getActivePokemons, getImageUrl, getMapImageUrl, getNeutralById, getNeutralImageUrl, getPokemonByDex, getPokemonByName, getPokemonBySlug, getPokemonSlug, getPokemonsByBattleType, getPokemonsByTag, getSpawnsByMap, getSpawnsByMapVisibleAt, isSpawnVisibleAtGameClock, maps, moves, neutrals, parseGameClockToSeconds, pokemons, spawns };
package/dist/index.d.ts CHANGED
@@ -145,6 +145,21 @@ declare function getMapImageUrl(map: Map, resolution?: MapResolution, options?:
145
145
  * Returns spawns for a given map id (e.g. "map-groudon", "map-kyogre", "map-rayquaza").
146
146
  */
147
147
  declare function getSpawnsByMap(mapId: string): MapSpawn[];
148
+ /**
149
+ * Parses game clock "MM:SS" to seconds remaining (e.g. "10:00" → 600, "02:00" → 120).
150
+ */
151
+ declare function parseGameClockToSeconds(clock: string): number;
152
+ /**
153
+ * Returns whether a spawn is visible at the given game clock (seconds remaining).
154
+ * Considers both spawnTime (spawn appears when clock ≤ spawnTime) and despawnTime
155
+ * (spawn disappears when clock ≤ despawnTime, e.g. center Natu/Altaria when boss spawns at 02:00).
156
+ */
157
+ declare function isSpawnVisibleAtGameClock(spawn: MapSpawn, gameClockSeconds: number): boolean;
158
+ /**
159
+ * Returns spawns for a map that are visible at the given game clock (seconds remaining).
160
+ * Use this when you need to show only spawns that have already appeared and not yet despawned.
161
+ */
162
+ declare function getSpawnsByMapVisibleAt(mapId: string, gameClockSeconds: number): MapSpawn[];
148
163
  /**
149
164
  * Returns the neutral by id, or undefined if not found.
150
165
  */
@@ -165,4 +180,4 @@ declare function getPokemonsByBattleType(battleType: BattleType): Pokemon[];
165
180
  declare function getPokemonsByTag(tag: Tag): Pokemon[];
166
181
  declare function getActivePokemons(): Pokemon[];
167
182
 
168
- export { BattleType, type GetImageUrlOptions, type Map, type MapResolution, type MapSpawn, type Move, type MoveSlotId, type Neutral, type Pokemon, type PokemonImages, type PokemonStats, Tag, getActivePokemons, getImageUrl, getMapImageUrl, getNeutralById, getNeutralImageUrl, getPokemonByDex, getPokemonByName, getPokemonBySlug, getPokemonSlug, getPokemonsByBattleType, getPokemonsByTag, getSpawnsByMap, maps, moves, neutrals, pokemons, spawns };
183
+ export { BattleType, type GetImageUrlOptions, type Map, type MapResolution, type MapSpawn, type Move, type MoveSlotId, type Neutral, type Pokemon, type PokemonImages, type PokemonStats, Tag, getActivePokemons, getImageUrl, getMapImageUrl, getNeutralById, getNeutralImageUrl, getPokemonByDex, getPokemonByName, getPokemonBySlug, getPokemonSlug, getPokemonsByBattleType, getPokemonsByTag, getSpawnsByMap, getSpawnsByMapVisibleAt, isSpawnVisibleAtGameClock, maps, moves, neutrals, parseGameClockToSeconds, pokemons, spawns };
@@ -41,9 +41,12 @@ var UniteLib = (() => {
41
41
  getSpawnInfo: () => getSpawnInfo,
42
42
  getSpawnInfoForSpawn: () => getSpawnInfoForSpawn,
43
43
  getSpawnsByMap: () => getSpawnsByMap,
44
+ getSpawnsByMapVisibleAt: () => getSpawnsByMapVisibleAt,
45
+ isSpawnVisibleAtGameClock: () => isSpawnVisibleAtGameClock,
44
46
  maps: () => maps_default,
45
47
  moves: () => moves_default,
46
48
  neutrals: () => neutrals_default,
49
+ parseGameClockToSeconds: () => parseGameClockToSeconds,
47
50
  pokemons: () => pokemons_default,
48
51
  spawns: () => spawns_default
49
52
  });
@@ -4924,6 +4927,26 @@ var UniteLib = (() => {
4924
4927
  function getSpawnsByMap(mapId) {
4925
4928
  return spawns_default.filter((s) => s.mapId === mapId);
4926
4929
  }
4930
+ function parseGameClockToSeconds(clock) {
4931
+ const parts = String(clock).trim().split(":");
4932
+ const m = parseInt(parts[0], 10) || 0;
4933
+ const s = parseInt(parts[1], 10) || 0;
4934
+ return m * 60 + s;
4935
+ }
4936
+ function isSpawnVisibleAtGameClock(spawn, gameClockSeconds) {
4937
+ const spawnSec = parseGameClockToSeconds(spawn.spawnTime);
4938
+ if (gameClockSeconds > spawnSec) return false;
4939
+ if (spawn.despawnTime != null && spawn.despawnTime !== "") {
4940
+ const despawnSec = parseGameClockToSeconds(spawn.despawnTime);
4941
+ if (gameClockSeconds <= despawnSec) return false;
4942
+ }
4943
+ return true;
4944
+ }
4945
+ function getSpawnsByMapVisibleAt(mapId, gameClockSeconds) {
4946
+ return getSpawnsByMap(mapId).filter(
4947
+ (s) => isSpawnVisibleAtGameClock(s, gameClockSeconds)
4948
+ );
4949
+ }
4927
4950
  function getNeutralById(id) {
4928
4951
  return neutrals_default.find((n) => n.id === id);
4929
4952
  }