Avatar icecube ❄️
Ho praticamente finito skribbl, ecco a voi, giocate:

game creation:
  • select options
  • select players (optional)
  • create room
  • op can start game when enough people

events:
  • right-guess -> (username: string)
  • close-guess -> (accuracy: number)
  • choosing-word -> (userId: string)
  • choose-word -> (words: string[])
  • word-hint -> (letter: char, position: number)
  • draw -> (timestamp: number)
  • guess -> (timestamp: number)
  • ended-turn -> (turnPoints: Record<string, number>, secretWord: string, timestamp: number)

redis:
  • points: Record<string, number>
  • hints: string[]
  • allowedWords: string[]
  • turn: number
  • secretWord: string
  • drawerId: string
  • phase: "choosing" | "playing" | "ended"

public-redis:
  • turnPoints: Record<string, number>
  • points: Record<string, number>
  • turn: number
  • drawerId: string
  • phase: "choosing" | "playing" | "ended"
  • hints: string[]

drawerId(turn):
  • return user.id of who should draw given turn and game settings

drawerId(t):
  • will calculate turn given timestamp t and game settings and return drawerId(turn)

timings:
  • W: word choosing time
  • P: playing time
  • E: ended turn time

game loop:
  • set redis.phase = "choosing"
  • reset redis.turnPoints
  • reset redis.hints
  • increment redis.turn
  • set redis.allowedWords = random_words()
  • set redis.drawerId = drawerId(redis.turn)
  • send to redis.drawerId: (choose-word, redis.allowedWords)
  • send to everyone else: (choosing-word, redis.drawerId)

  • until redis.secretWord == null and passedTime < W:

  • if redis.secretWord == null: set redis.secretWord = redis.allowedWords[random()]

  • send to redis.drawerId: (new-drawer-turn, redis.turn, now)
  • send to everyone else: (new-guesser-turn, redis.turn, now)
  • set redis.phase = "playing"

  • wait P

  • send to all: (ended-turn, redis.turnPoints, redis.secretWord, now)
  • set redis.phase = "ended"
  • add redis.turnPoints to redis.points

  • wait E

get state endpoint:
  • return public-redis

on wbs chosen word:
  • forbid if user.id != redis.drawerId
  • forbid if chosen word not in redis.allowedWords
  • set redis.secretWord to chosen word

on client new comment:
  • add comment to firestore
  • call wbs guess

on wbs guess:
  • send to all, if guess == redis.secretWord: (right-guess, user.username)
  • send to user.id, if guess != redis.secretWord: (close-guess, accuracy(guess))
  • increment redis.turnPoints[user.id]

ui reflection:
  • drawer-turn -> disabled comments, enabled canvas
  • guesser-turn -> enabled comments, disabled canvas
  • choose-word -> pop-up to choose words
  • choosing-word -> pop-up saying who is choosing word
  • ended-turn -> pop-up with point calculations

firestore game state:
  • strokes

on draw:
  • if redis.drawerId != user.id forbid operation

preview states:
  • watch
  • play
  • join
  • ended
4
11 dic 2025 alle 11:17 (modificato)

Eliminato

Eliminato

@icecube

❄️ OP

Eliminato