Compare commits
No commits in common. "a09b5cc9d1d7bc878b2a2df5e5b3b4d7f12efbf1" and "fe6242cbbfadacd53616f58c6dd0ec8837988bf5" have entirely different histories.
a09b5cc9d1
...
fe6242cbbf
@ -186,21 +186,3 @@ async def _(get_input: InputGetter, set_output: OutputSetter):
|
|||||||
output[choice] = True
|
output[choice] = True
|
||||||
|
|
||||||
set_output(output)
|
set_output(output)
|
||||||
|
|
||||||
|
|
||||||
@arbiter.mode("anarchy", allow_multitouch=False)
|
|
||||||
async def _(get_input: InputGetter, set_output: OutputSetter):
|
|
||||||
while True:
|
|
||||||
await asyncio.sleep(settings.democracy_vote_cycle)
|
|
||||||
|
|
||||||
inputs: list[Input] = await get_input()
|
|
||||||
|
|
||||||
the_input = random.choice(inputs)
|
|
||||||
|
|
||||||
if not the_input:
|
|
||||||
set_output(EMPTY_INPUT)
|
|
||||||
continue
|
|
||||||
|
|
||||||
output = {button: the_input[button] for button in Button}
|
|
||||||
|
|
||||||
set_output(output)
|
|
||||||
|
@ -27,9 +27,6 @@
|
|||||||
--button-color: lightgrey;
|
--button-color: lightgrey;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
line-height: var(--button-height);
|
line-height: var(--button-height);
|
||||||
|
@ -10,15 +10,13 @@ const Client = () => {
|
|||||||
const [socket, setSocket] = useState<WebSocket>();
|
const [socket, setSocket] = useState<WebSocket>();
|
||||||
const [buttonMap, setButtonMap] = useState<ButtonMap>(defaultButtonMap);
|
const [buttonMap, setButtonMap] = useState<ButtonMap>(defaultButtonMap);
|
||||||
|
|
||||||
const updateButtonEvent = (button: ButtonType, buttonState: "down" | "up") =>
|
const updateButtonEvent = (button: ButtonType, state: "down" | "up") =>
|
||||||
() => setButtonMap((m) => {
|
() => setButtonMap((m) => {
|
||||||
const newMap = { ...m, [button]: (buttonState === "down") };
|
const newMap = { ...m, [button]: (state === "down") };
|
||||||
const multitouch = !!state.allowMultitouch;
|
if (mapToBitvector(newMap).reduce((a,b) => a+b, 0) > 1) {
|
||||||
const multiInput = mapToBitvector(newMap).reduce((a,b) => a+b, 0) > 1;
|
|
||||||
if (!multiInput || multitouch) {
|
|
||||||
return newMap;
|
|
||||||
} else {
|
|
||||||
return m;
|
return m;
|
||||||
|
} else {
|
||||||
|
return newMap;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ span {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.timer {
|
.timer {
|
||||||
width: 75px;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
@ -44,47 +43,19 @@ span {
|
|||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-around;
|
justify-content: space-between;
|
||||||
padding: 0px 10px;
|
padding: 0px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vote {
|
.vote {
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.vote .bar {
|
|
||||||
color: white;
|
|
||||||
font-size: 24pt;
|
font-size: 24pt;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
gap: 30px;
|
||||||
border-radius: 5px;
|
|
||||||
background-color: #3a3a3a;
|
|
||||||
max-width: 200px;
|
|
||||||
width: var(--vote-percentage, 0px);
|
|
||||||
}
|
}
|
||||||
.vote .percentage {
|
|
||||||
font-weight: bold;
|
|
||||||
line-height: 100%;
|
|
||||||
align-items: center;
|
|
||||||
display: inline-flex;
|
|
||||||
}
|
|
||||||
.vote .bar-wrap {
|
|
||||||
width: 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voting {
|
.voting {
|
||||||
background: #040404;
|
|
||||||
border-radius: 20px;
|
|
||||||
padding: 4px;
|
|
||||||
gap: 2px;
|
|
||||||
margin: 15%;
|
margin: 15%;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { CSSProperties, useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
|
import './Client.css';
|
||||||
import './TVMode.css';
|
import './TVMode.css';
|
||||||
import { ButtonType, buttonTypeList, WGPPState } from './types';
|
import { ButtonType, buttonTypeList, WGPPState } from './types';
|
||||||
|
|
||||||
@ -26,11 +27,7 @@ const TVMode = () => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const totalCount = useMemo(() => buttonTypeList.reduce((acc, v) => (state?.votes?.[v] ?? 0) + acc, 0), [state]);
|
const totalCount = useMemo(() => buttonTypeList.reduce((acc, v) => (state?.votes?.[v] ?? 0) + acc, 0), [state]);
|
||||||
const voteList = useMemo(() =>
|
const voteList = useMemo(() => buttonTypeList.map(b => [b, state?.votes?.[b] ?? 0] as [ButtonType, number]).sort((a, b) => b[1] - a[1]), [state]);
|
||||||
buttonTypeList
|
|
||||||
.map(b => [b, state?.votes?.[b] ?? 0] as [ButtonType, number])
|
|
||||||
//.sort((a, b) => b[1] - a[1])
|
|
||||||
, [state]);
|
|
||||||
|
|
||||||
return <div className="stream">
|
return <div className="stream">
|
||||||
{state === undefined ?
|
{state === undefined ?
|
||||||
@ -38,22 +35,14 @@ const TVMode = () => {
|
|||||||
<div>
|
<div>
|
||||||
<span className={`mode mode-${state.mode}`}>{state.mode}</span>
|
<span className={`mode mode-${state.mode}`}>{state.mode}</span>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div>
|
<span className="subtitle">next: {state.nextMode}</span>
|
||||||
<span>
|
|
||||||
next:
|
|
||||||
</span>
|
|
||||||
<span className={`subtitle mode-${state.nextMode}`}>{state.nextMode}</span>
|
|
||||||
</div>
|
|
||||||
<span className="timer">{Math.round(state.timeUntilNextMode ?? 0)}s ⏱️</span>
|
<span className="timer">{Math.round(state.timeUntilNextMode ?? 0)}s ⏱️</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="voting">
|
<div className="voting">
|
||||||
{voteList.flatMap(([b, numVotes], index) => {
|
{voteList.flatMap(([b, numVotes], index) => {
|
||||||
const percentage = numVotes === 0 ? 0 : Math.round(numVotes / totalCount * 100);
|
const percentage = numVotes === 0 ? "" : Math.round(numVotes / totalCount * 100) + "%";
|
||||||
return <div className="vote" style={{ "--vote-percentage": percentage + "%" } as CSSProperties} key={index}>
|
return <div className="vote" key={index}>
|
||||||
<div className="bar-wrap">
|
<span>{b}</span><span>{percentage}</span>
|
||||||
<div className="bar" style={{ "--vote-percentage": percentage + "%" } as CSSProperties} >{b}</div>
|
|
||||||
</div>
|
|
||||||
<span className="percentage">{percentage === 0 ? "" : `${percentage}%`}</span>
|
|
||||||
</div>;
|
</div>;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user