master
bel 2023-03-26 23:35:10 -06:00
parent 163bf2b405
commit 2d4cb394de
2 changed files with 64 additions and 17 deletions

View File

@ -2,6 +2,7 @@ package v01
import (
"encoding/json"
"fmt"
"io"
"log"
"mayhem-party/src/device/input/wrap"
@ -137,24 +138,67 @@ func (v01 *V01) serveGlobalQueryRefresh(r *http.Request) {
}
func (v01 *V01) serveGM(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/gm/rpc/publicStatus":
panic("TODO")
case "/gm/rpc/markMessageRead":
v01.cfg.Quiet = true
for k, v := range v01.cfg.Users {
v.Alias = v.Message
v.Message = ""
v01.cfg.Users[k] = v
}
v01.cfg.Users["broadcast"].Message = fmt.Sprintf("SOMEONE SAID %q", strings.ToUpper(r.URL.Query().Get("message")))
case "/gm/rpc/mustSwapElseShuffle":
getUserNameFor := func(like string) string {
if _, ok := r.cfg.Users[like]; ok {
return like
}
for k, v := range r.cfg.Users {
if v.Alias == like {
return k
}
}
return ""
}
userA := getUserNameFor(r.URL.Query("a"))
userB := getUserNameFor(r.URL.Query("b"))
if userA == "" || userB == "" {
http.Error(w, "who?", http.StatusBadRequest)
return
}
if userA == userB {
r.URL.Path = "/gm/rpc/shuffle"
v01.serveGM(w, r)
}
a := r.cfg.Users[userA]
b := r.cfg.Users[userB]
a.Player, b.Player = b.Player, a.Player
r.cfg.Users[userA] = a
r.cfg.Users[userB] = b
r.cfg.Quiet = false
bc := r.cfg.Users["broadcast"]
bc.Message = ""
r.cfg.Users["broadcast"] = bc
default:
http.NotFound(w, r)
}
// TODO: what do? could make 'em RPC endpoints that calls itself
/*
**somebody needed to assign words to players
**alias field so i can swap zach and taco without losing taco
**dont have to if i let quiet affect TTS ...
* is that gonna turn into a side effect?
**note for server side meta, because thats flexible and supports other stuff like heartbeat
.meta.messagelog actually kinda solves it but how to stash... cant hook into PATCH
.meta.lastseen is still #worth
.meta.alias it is
* everybody always knows their word to discourage others if in first
**what penalty if i say me?
* no play is ONE universal dis-incentive...
* what other goofy disincentive?
* shuffle the world?
* on both failed and self vote
* track last vote for cooldown and stt disable tha person
* admin ui things
**swap 2 players
--somebody needed to assign words to players
--alias field so i can swap zach and taco without losing taco
--dont have to if i let quiet affect TTS ...
- is that gonna turn into a side effect?
.meta.alias it is
- everybody always knows their word to discourage others if in first
--what penalty if i say me?
- no play is ONE universal dis-incentive...
- what other goofy disincentive?
- shuffle the world?
- on both failed and self vote
- track last vote for cooldown and stt disable tha person
- admin ui things
--swap 2 players
*/
}

View File

@ -5,6 +5,9 @@ users:
bel:
player: 0
message: "hi"
alias: driver
tsms: 1
lastlag: 2
players:
- buttons:
up: "w"