{#if _magister} {/if}
{/if}
{#if internal_state === 'loading'}

Loading game state

{:else}
{game_config.topic}

{stage_label}

{((internal_state === 'playing' || internal_state === 'paused') && current_stage) ? current_stage.duration - offset_sec : ''}
{#if (_magister == null || _magister == true)} {#if internal_state == 'waiting'} {:else if internal_state == 'playing'} {:else if internal_state == 'paused'} {/if} {/if}
Info

{game_config.topic}

Room: {room} (leave)

{state === 'waiting' ? 'Waiting for the game to start' : state === 'paused' ? 'GAME PAUSED' : state === 'playing' ? 'Game in progress' : ''}
{#if connection !== 'connected'}
DISCONNECTED FROM GAME SERVER
{:else} {#if _active_sessions == 1}
You are alone in the room
{:else}
{_active_sessions} players are in this room
{/if} {/if}

Game

{#if game_config.meditate}
Meditation (1 min)
{/if} {#each Array(Math.max(game_config.rounds, 0)) as _, r}
Round {r+1}: {#each Array(Math.max(game_config.players, 0)) as _, p} {p+1} {/each}
{/each}
{#if _magister == null || _magister == true}
Game controls

{#if _magister == null} This will effect all players. Will you borrow power? Will you steal it? {:else} You are master of the games. These controls are yours alone. {/if}

{#if internal_state == 'waiting'} {:else if internal_state == 'playing'} {:else if internal_state == 'paused'} {/if} {#if internal_state == 'paused' || internal_state == 'completed' } {/if}
(Total game length: {roundish( game_stages.reduce((x, s) => x + s.duration, 0) / 60 )} minutes)
{#if _magister == null}

Advanced - for large games

When present, the Magister Ludi (master of the games) has exclusive control of the game.

{:else if _magister == true}

You are the master of the games. You have exclusive control over playing, pausing and configuring this game.

Do not close this browser window or you will be dethroned.

{/if}
{:else}

Magister Ludi is managing this game.

{/if} {/if}
{/if}
{#if internal_state === 'loading'}

Loading game state

{:else}

Topic: {topic}< div g{round_audio}g id='topic'asd f /> /h1>

Room: {room} (leave)

let audio_works = true // function test_audio() { // let a = new Audio() // a.vo (_magister == null || _magister == true) && {#if internal_state == 'waitin g'} {/if} // let audio_workstrue =// fals// e // function test_audi// o() { // } $::$ // let a = // a.v// olume = 0.1v// o a.src = '/xlo// -metal-tone.mp3/// / 'anew A// udio() // a.play ()/// / .t hen ( () => {a// ud // co// nsole.log(// 'Audio works// does // // not work')// io_work s = audi//// o_w// ork// s // = falsetrue true} , // () =>// {// // // c// onsole// .l// og('Aud function// f console.log('xx// ') console.lo// g(// setTimeout('xx')logco, 100 0)nsoleix_audio(e) { test_audio())test_ }] { io test_audio()t est_au doe s } not work' )log. $: { ) consol audio_works = true}, audio_wothenplayAudio= { } $$"$falseort let _active_sessions let game_completed = false // Derived from other properties let internal_state $: interna// l_sta// te = game_completed ? 'compl// eted' : state $: { if (s// tat// e !== 'playing') { console.log('xxx') game_compl let round_audio1 letcompletend_ audio21 eted = false } } // export let state const ARCHETOPICS = [ 'Truth', 'Human', 'Energy', 'Beauty', 'Beginning', 'End', 'Birth', 'Death', 'Ego', 'Attention', 'Art', 'Empathy', 'Eutopia', 'Future', 'Game', 'Gift', 'History', 'Cosmos', 'Time', 'Life', 'Addiction', 'Paradox', 'Shadow', 'Society' ] // Could make configurable. Eh. co = []nst MEDITATION_SECONDS = 60 let game_stages $:{ } `${meditate ? 'Meditation' : 'Game'} is about type: '' no_sound: true_to start`will start { 3game_stages = [] if (meditate) type: 'meditate', game_sta ges.pu }]sh({ label: 'Meditate', duration: if (meditate) game_stages.push({ label: 'Meditate', duration: MEDITATION_SECONDS, MEDITATION_SECONDS, }) for (let r = 0; r < rounds; r++) type: 'bead', r, p type: 'bead', r, p { for (let p = 0; p < players; p++) { game_stages.push({ label: `Round ${r+1} player ${p+1}`, duration: seconds_per_bead, }) } } } const update_state = async patch => { await fetch(`${room}/configure`, { method: 'POST', mode: 'same-origin', headers: { 'content-type': 'application/json', }, body: // JSON.stringify(patch) }) } const upd = (k, v) => () => update_state({[k]: v}) const config = k => e => { console.log('k', k, e.data, e.value, e.target.value, e.target.type) const raw_value = e.target.value const value = e.target.type === 'number' ? raw_value|0 : e.target.type =waiting== 'checkboxg' co'Waiting for game to start', duration: Infinityinst complete type: 'complete',_state = { label: 'Game compl const complete_stage = { const get_current_stage = (offset_ms) => { if (state === 'waiting') return {stage: waiting_stage, offset_ms: 0} let offset_secondMath.round(rounds = offse /) 1000t_msoffset for (let s = 0; s < game_stages.length; s++) { let stage = game_stages[s] if (stage.dursecation * 1000 > offset_ms) { sec : offset_sec const time = state + _clock_offset_cloooff=== 'playing' ? Date.now() - start_time : state === 'paused' ? paused_progress : 0pauslet * 1000return {stage, secoffset_ms} } offset_currentms -=time stage.duratiosecn * 1000 } r -+ paused_progresspauseeturn { stage: complete_secstage, offset_ms } } // label: 'Game complete', complete: true }ete// ' if (state === 'waiting' || state{stage: === 'loading, offset_ms: 0}// '!== 'playing' && state !== ') return waiting_// stagewaitinsecg, complete: trues// ac age}ivi? ye.target.checked : raw_v// alue// update_state({[k]: value}) /sec/ } c// onst roundgisx_h = x => Math.roundnew_stage.type === 'complete'(xg// ame// _ * 1g00) // x_/ 100 // const startgame_ = () =// > {// // consolge.log(x_x_'start!': xcurr_gamntex = null, let _ggame_s// tatex_gagme) // upstagedatege_current_stage.type === 'complete'game_statge({currstatnte: 'gpx_laying'}) // } // legcurrame_ntt rogund_arr // $: round_arrcurr = nntew Agrrg = null{}nullame_ay(Mathcomplete_stateconst {stage: new_stage, ne: new_offs: w_offs: current_ // setTimeout needed to get around some weird race condition. // There's probably better ways to structure this :/other ways to stage.type === 'complete'offset_ // setTimeout needed to get around some weird race condition.ms}oenew_stage: stag.max(rounds, 0)).fill()$: console.log('game state xxx', game_state)logconsnew_offsole new_stage_const || state === 'paused'ise gsetTsetTimeout(() => tick(false))imeout(() => setT et_cur)rebar_nt_scurrtatent = (gobar_ffset letgw_stagee_ame_ {stw_stageae_cunrrte, ntoffsget_m $n: gaw_stage let game_completed $: { // console.log('updating game_completed', current_stage) game_completed = (state !== 'playing' || current_stage == null) ? false : (current_stage.type === 'complete') } let internal_state $: internal_state = game_completed ? ' completed' : stat // let b// ar_width = 0 : statecurrent_stage.type : current_stage.type === 'complete' ? 100 === 'waiting' ? 0currenstar e// $: {// if (state// !== 'playing') {// game_completed = fals// e/// / }// } mee// __c// om/// / ple// ted = game_state =// = nul// l ? fnalse if (p// lay_// audi && !new_stage.no_sou// ndno// _new_stage!! o) { if (current_stage.complete) com// $: game_completed = current_stage && (current_stage.type === 'complete') plete_audio.play() else let game_completed round_let bar_width = 0 audio.play( } ) : !!game_state.completegame_s tategame_ $: width = state.complete ? 100 : 100 * offset_ms / (state.duration * 1000)$: widtinternal_state === 'waiting' let config_open = false $: if (_magister === true) config_open = tru // The first user has the config open by default. ysere $: if (_active_ses=sio1ns_acti_magister == tr// TMaAke themagist iser box fully visible once there's a critical mass of players in the roomenouhg pl ue) // let magister_opaque = false $: magister_opa {#if _magist e r_ m a g isM oda l } body { bac kgroun d-color: var(--bg- highlight); over flow: hidden; } {/if} d > {#if isModal} n put={config('meditate')} > ->
(Tot al game length: {roundish( (rounds * players * seconds_per_bead + (meditate ? MED ITATION_SECOND {/if}S : 0)) / 60 )} minutes)
(Tot al game length: {roundish( game_stages.reduce((x, s) => x + s.durati on, 0) / 60 )} minutes)

Hello {name}!{JSON.stringify(state)}stringifyJSONh1>

Visit the */Svelte tutorial to learn how to build Svelte apps.

Edit src/App.svelte and save to reload.

Page has been open for {count} seconds.

Learn Svelte

Edit src/App.svelte and save to reload.

Page has been open for {count} seconds.

Learn Svelte