on 05c1914 help sign in
bridge/src/lib/child.js
20 lines 522 B history raw
1const MIN_GALAXY = 0
2const MIN_STAR = Math.pow(2, 8)
3const MIN_PLANET = Math.pow(2, 16)
4const MAX_GALAXY = MIN_STAR - 1
5const MAX_STAR = MIN_PLANET - 1
7const randomStarName = galaxy =>
8 (Math.floor(Math.random() * MAX_GALAXY) + 1) * MIN_STAR + galaxy
10const randomPlanetName = star =>
11 (Math.floor(Math.random() * MAX_STAR) + 1) * (MAX_STAR + 1) + star
13const getSpawnCandidate = point =>
14 point >= MIN_GALAXY && point < MIN_STAR
15 ? randomStarName(point)
16 : randomPlanetName(point)
18export {
19 getSpawnCandidate