From aadc23c45b01b98e29d4a8bee91e6970a859b79e Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 14 Dec 2024 23:45:47 -0700 Subject: [PATCH] assignmentRotation impl --- cmd/server/.games.go.swp | Bin 24576 -> 24576 bytes cmd/server/games.go | 28 ++++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/cmd/server/.games.go.swp b/cmd/server/.games.go.swp index ff7eaa39071023671554b382e190fec69f7920eb..2fe1945e1951f9f03182544cfa2051f8ed3ba14d 100644 GIT binary patch delta 1231 zcmajdUr19?0LSrj^Y3!zhM8nVHzQ&Z!-X=jq{L_qH8jLBQ=9F!me(npN;N`-9`Z@* zQbd|mFKI-ednf`)Lae|*NDAtuh0**WL_?rk5I+J~jJ zby*e85;@mu6BLsWX~7!L9Xa06l`BM@qMp6FVPNN2iqxl>P3e|ceGz3{q!InmR*JT9 z(KbV~nbJc?O+6{e$qYSOLdD*FA+zj|+B%jB(T;jlVn22uAKS1I%OPRTAjCIJ;XR(< z0Y=b|%eaK&s6ZjIum-bex}htu%Fjt?x_D7z`C&s&I+472dvft(N zDB7#q)t-PH)Z_WbVUg`x7ag&1Trhme-?o+)-&zi8m9^K+F1HW^B%r6GXP=>Gf51-e zMkL@h*^b~M_TW1!r*R86(2pKmz)7emM=^?Ehrat9r;Hgx9j0AIa^6C^c0J*cqb60_ Q`$``{VbS#33V3bNJVPwtN@EU{LtZluB2p2*B zFhnkh2r3z@AQ0qUltJp=M9_TEn|e`@Z$vGk7X>L5^u5g}df;>X?z!jp{J7_?Fsl@1 zmBvJC-@$Gp9NH;_Ci3QIEt_4+(TSNry9xbS^uieO> z>;vbx_Bi14l73dlg>EHBH=@e$#SJ2-(TfN=(2lL}W*5Tgc)F zcB2_OJ~xPb#1aS(yu}-o zF@X_uVGqKn$13w!Kp6#`^~6Oi7W=UajaX%PPw)suT*f){V>{;8iM&PyuW$tsgdkX8 z!0wQzkdKJ-qABd{+n39wl9{xb$>)r8{LG15KAXxUV}H}4s+}pzIyRIYG>F>swWL{1 z{h!PlhSRyjr*x=lt&M5^yKyb&Zq29CX6Psv`bDjwMBH+ZaIUvp*xWMZ=NrNOC74h( z-UmdUV+>KORBN0|+Kk`%7Tcug@j>c+BG=$<4BGnMEr;4E4dN5!aR_v}~_a83(1~ZbI+yDRo diff --git a/cmd/server/games.go b/cmd/server/games.go index 1988379..71c0197 100644 --- a/cmd/server/games.go +++ b/cmd/server/games.go @@ -78,9 +78,11 @@ type ( } KillWords struct { - Global string - Assigned time.Time - Assignee string + Global string + + Assigned time.Time + Assignee string + Assignment Assignment } @@ -99,10 +101,10 @@ type ( } EventGameComplete struct{} EventAssignmentRotation struct { - Killer string - Killed string - KillWord string - Assignments map[string]Assignment + Killer string + Killed string + KillWord string + KillWords map[string]KillWords } ) @@ -169,11 +171,21 @@ func (games Games) GameState(ctx context.Context, id string) (GameState, error) result.Players[assignmentRotation.Killer] = killer } + for k, v := range result.Players { + v.KillWords = KillWords{} + result.Players[k] = v + } + + for k, v := range assignmentRotation.KillWords { + player := result.Players[k] + player.KillWords = v + result.Players[k] = player + } // TODO gather current assignees // TODO get victim's target // TODO assign victim's target to killer // TODO randomize everyone else so not the same as before AND not self - return fmt.Errorf("not impl: assignment rotation: %+v", assignmentRotation) + return nil default: return fmt.Errorf("unknown event type %d: %s", peek.Type, payload) }