Skip to content

Instantly share code, notes, and snippets.

@corbanbrook
Created August 19, 2019 20:55
Show Gist options
  • Save corbanbrook/f064c9a5ca722697884dd5bd0d082b5b to your computer and use it in GitHub Desktop.
Save corbanbrook/f064c9a5ca722697884dd5bd0d082b5b to your computer and use it in GitHub Desktop.
import {
getUrlFlag,
getUrlFloat,
getUrlInt,
getUrlParam
} from './utils/location'
const asStringUnion = <T extends string>(arr: T[]) => arr
const flags = asStringUnion([
'skipCardSelection',
'renderDefaultLayer',
'fakeUsers',
'debugColliders',
'bgFlash',
'fakeXP',
'debug-preload',
'debug-vs',
'fakeFindOpponent',
'skipTurnChangeOverlays',
'disableText',
'resetToolTips',
'disableToolTips',
'midground',
'fpsCam',
'debugLights',
'debugPerformanceWarning',
'debugTextureResolution',
'hideCursor'
])
const params = asStringUnion([
'mode',
'assetsUrl',
'playerAlias',
'session',
'deck',
'avatar',
'cards',
'keywords',
'export',
'type',
'texture',
'textureMode'
])
const queryParams = {
...flags.reduce<{ [key in typeof flags[number]]: boolean }>(
(acc, x) => {
acc[x] = getUrlFlag(x)
return acc
},
{} as any
),
...params.reduce<{ [key in typeof params[number]]: string | null }>(
(acc, x) => {
acc[x] = getUrlParam(x)
return acc
},
{} as any
),
islandSpin: getUrlFloat('islandSpin', 0),
dayPercent: getUrlFloat('dayPercent', 0, 0, 1),
size: getUrlFloat('size', 1),
speed: getUrlFloat('speed', -1),
camDamping: getUrlFloat('camDamping', 0, 0, 0.999),
quick: getUrlInt('quick', 100000, 4000, 100000)
}
export default queryParams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment