wip
parent
163bf2b405
commit
2d4cb394de
|
|
@ -2,6 +2,7 @@ package v01
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"mayhem-party/src/device/input/wrap"
|
"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) {
|
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
|
// TODO: what do? could make 'em RPC endpoints that calls itself
|
||||||
/*
|
/*
|
||||||
**somebody needed to assign words to players
|
--somebody needed to assign words to players
|
||||||
**alias field so i can swap zach and taco without losing taco
|
--alias field so i can swap zach and taco without losing taco
|
||||||
**dont have to if i let quiet affect TTS ...
|
--dont have to if i let quiet affect TTS ...
|
||||||
* is that gonna turn into a side effect?
|
- 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
|
.meta.alias it is
|
||||||
* everybody always knows their word to discourage others if in first
|
- everybody always knows their word to discourage others if in first
|
||||||
**what penalty if i say me?
|
--what penalty if i say me?
|
||||||
* no play is ONE universal dis-incentive...
|
- no play is ONE universal dis-incentive...
|
||||||
* what other goofy disincentive?
|
- what other goofy disincentive?
|
||||||
* shuffle the world?
|
- shuffle the world?
|
||||||
* on both failed and self vote
|
- on both failed and self vote
|
||||||
* track last vote for cooldown and stt disable tha person
|
- track last vote for cooldown and stt disable tha person
|
||||||
* admin ui things
|
- admin ui things
|
||||||
**swap 2 players
|
--swap 2 players
|
||||||
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ users:
|
||||||
bel:
|
bel:
|
||||||
player: 0
|
player: 0
|
||||||
message: "hi"
|
message: "hi"
|
||||||
|
alias: driver
|
||||||
|
tsms: 1
|
||||||
|
lastlag: 2
|
||||||
players:
|
players:
|
||||||
- buttons:
|
- buttons:
|
||||||
up: "w"
|
up: "w"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue