gitignore

main
bel 2024-12-14 23:41:28 -07:00
parent 0aefff5b82
commit 15118df95c
2 changed files with 16 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/cmd/server/server

View File

@ -6,6 +6,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"slices"
"time" "time"
) )
@ -100,6 +101,7 @@ type (
EventAssignmentRotation struct { EventAssignmentRotation struct {
Killer string Killer string
Killed string Killed string
KillWord string
Assignments map[string]Assignment Assignments map[string]Assignment
} }
) )
@ -155,10 +157,22 @@ func (games Games) GameState(ctx context.Context, id string) (GameState, error)
if err := json.Unmarshal(payload, &assignmentRotation); err != nil { if err := json.Unmarshal(payload, &assignmentRotation); err != nil {
return err return err
} }
if killer, ok := result.Players[assignmentRotation.Killer]; !ok {
} else if victim, ok := result.Players[assignmentRotation.Killed]; !ok {
} else {
killer.Kills = append(killer.Kills, Kill{
Timestamp: timestamp,
Victim: assignmentRotation.Killed,
Public: slices.Contains(victim.KillWords.Assignment.Public, assignmentRotation.KillWord),
})
result.Players[assignmentRotation.Killer] = killer
}
// TODO gather current assignees // TODO gather current assignees
// TODO get victim's target // TODO get victim's target
// TODO assign victim's target to killer // TODO assign victim's target to killer
// TODO randomize everyone else so not the same as before // TODO randomize everyone else so not the same as before AND not self
return fmt.Errorf("not impl: assignment rotation: %+v", assignmentRotation) return fmt.Errorf("not impl: assignment rotation: %+v", assignmentRotation)
default: default:
return fmt.Errorf("unknown event type %d: %s", peek.Type, payload) return fmt.Errorf("unknown event type %d: %s", peek.Type, payload)