add layers for new image and new game

This commit is contained in:
Zutatensuppe 2021-05-21 00:43:02 +02:00
parent e9b209edf1
commit bdd061dd1a
18 changed files with 551 additions and 99 deletions

View file

@ -8,6 +8,9 @@ export type EncodedPlayer = Array<any>
export type EncodedPiece = Array<any>
export type EncodedPieceShape = number
// TODO: maybe something other than string in the future
export type Category = string
interface GameRng {
obj: Rng
type?: string
@ -22,6 +25,19 @@ interface Game {
rng: GameRng
}
export interface Image {
file: string
url: string
category: Category
title: string
}
export interface GameSettings {
tiles: number
image: Image
scoreMode: ScoreMode
}
export interface Puzzle {
tiles: Array<EncodedPiece>
data: PuzzleData

View file

@ -148,6 +148,18 @@ const hash = (str: string): number => {
return hash;
}
function asQueryArgs(data: any) {
const q = []
for (let k in data) {
const pair = [k, data[k]].map(encodeURIComponent)
q.push(pair.join('='))
}
if (q.length === 0) {
return ''
}
return `?${q.join('&')}`
}
export default {
hash,
uniqId,
@ -165,4 +177,6 @@ export default {
decodeGame,
coordByTileIdx,
asQueryArgs,
}