Skip to content

Guesses, votes and teams

View as Markdown

Players answer a StreamArena game in one of three ways: a guess (free text), a vote (a number) or a team word. A game declares which ones it uses in inputs, and the first one sets the "how to play" line on stream.

Input Viewers type Use it for
guess Free text, like dune Naming a film, a photo, an emoji puzzle
vote A number, like 1 or 2 Two or three options, one right answer
team A team word, like !cats Two or more sides racing each other

chat.expect(answers) is the one-line version: loose matching, faster answers score more, the first right answer gets a bonus, and each player scores once.

chat.expect(item.title, { points: 1000, min: 200, first: 250 })

For your own rules, use chat.onAnswer() and mark winners with player.correct(points):

chat.onAnswer((player, text, { at, platform, secret }) => {
if (text.matches(item.answers)) player.correct(1000 - at * 40)
})

chat.vote(options) returns a poll with live bars. Players type 1, 2 or 3, or tap on their phone, and the last vote counts. Call close() before poll.score(), so late YouTube votes still count.

higher-or-lower.js
async round({ item, show, chat, phone, house, timer, close, reveal }) {
const opts = [item.a, item.b]
const poll = chat.vote(opts).render(show.html('<div class="tally"></div>'))
phone.prompt({ text: item.q, input: 'vote', options: opts })
house.vote(item.answer)
await timer(20)
await close()
poll.score(item.answer, { points: 500, fast: 300 })
await reveal(opts[item.answer])
}

chat.teams() takes the team words, and onPull() fires on every counted message. Each player counts at most once every half second.

tug-of-war.js
async round({ chat, timer, reveal }) {
const teams = chat.teams([
{ id: 'cats', words: ['cats', '!cats'] },
{ id: 'dogs', words: ['dogs', '!dogs'] },
])
teams.onPull((team) => moveRope(team.id))
await timer(45)
const c = teams.counts()
await reveal(c.cats > c.dogs ? 'Cats win' : 'Dogs win')
}

phone.prompt() sets what phone players see this round. It defaults to the game's first input.

phone.prompt({ text: 'Which is older?', input: 'vote', options: ['Statue of Liberty', 'Eiffel Tower'] })