Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 8x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 8x | import { HoyoAPIError } from '../../error'
import { HonkaiRegion, HonkaiRegionKeyType } from './hi.interface'
/**
* Gets the Honkai region from a given UID.
* @function
* @param {number} uid - The UID to get the Honkai region for.
* @returns {HonkaiRegion} - The Honkai region for the given UID.
* @throws {HoyoAPIError} - If the UID is invalid.
*/
export function getHi3Region(uid: number): HonkaiRegion {
let key: string
/* c8 ignore start */
if (uid > 10_000_000 && uid < 100_000_000) {
key = 'ASIA'
} else if (uid > 100_000_000 && uid < 200_000_000) {
key = 'USA'
} else if (uid > 200_000_000 && uid < 300_000_000) {
key = 'EURO'
} else {
throw new HoyoAPIError(`Given UID ${uid} is invalid !`)
}
/* c8 ignore stop */
return HonkaiRegion[key as HonkaiRegionKeyType]
}
|