bugfix if victim was targeting killer then killer cant target itself

main
Bel LaPointe 2024-12-15 13:03:37 -07:00
parent 598cb0684c
commit 8d73f97c3a
2 changed files with 20 additions and 3 deletions

View File

@ -415,7 +415,7 @@ func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWo
if _, ok := prev[killer]; !ok {
} else if victimState, ok := prev[victim]; !ok {
} else {
} else if killer != victimState.Assignee { // if victim was targeting killer, just randomize
m.assign(killer, victimState.Assignee)
}

View File

@ -56,7 +56,7 @@ func TestUserGameServer(t *testing.T) {
t.Fatal(err)
}
t.Run("started but no kills", func(t *testing.T) {
t.Run("just started", func(t *testing.T) {
state, err := ugs.State(ctx)
if err != nil {
t.Fatal(err)
@ -114,7 +114,24 @@ func TestUserGameServer(t *testing.T) {
}
})
t.Run("started with kills", func(t *testing.T) {
for i := 0; i < 3; i++ {
state, err := games.GameState(ctx, ugs.ID)
if err != nil {
t.Fatal(err)
}
killer := ugs.Session.ID
if i > 0 {
killer = state.Players[killer].KillWords.Assignee
}
victim := state.Players[killer].KillWords.Assignee
word := state.Players[victim].KillWords.Assignment.Public[0].Word
points := state.Players[victim].KillWords.Assignment.Public[0].Points
if err := games.CreateEventAssignmentRotation(ctx, gid, killer, victim, word, points); err != nil {
t.Fatal(err)
}
}
t.Run("after kills", func(t *testing.T) {
t.Error("not impl")
})