test usergameserver.State after game completes WOO
parent
fc899056e0
commit
5109dc9fdb
|
|
@ -208,7 +208,84 @@ func TestUserGameServer(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
if err := games.CreateEventGameComplete(ctx, gid); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Run("completed", func(t *testing.T) {
|
||||
t.Error("not impl")
|
||||
state, err := ugs.State(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !state.Started {
|
||||
t.Error("not started after complete")
|
||||
}
|
||||
|
||||
if state.Completed.IsZero() {
|
||||
t.Error("not complete after complete")
|
||||
}
|
||||
|
||||
for _, pid := range pids {
|
||||
p, ok := state.Players[pid]
|
||||
if !ok {
|
||||
t.Error(pid, "not in players")
|
||||
} else if p.Empty() {
|
||||
t.Error(pid, p)
|
||||
} else if p.KillWords.Assigned.IsZero() {
|
||||
t.Error("assigned is zero")
|
||||
}
|
||||
|
||||
if isSelf := pid == ugs.Session.ID; isSelf {
|
||||
if len(p.Kills) == 0 {
|
||||
t.Error("self never got a kill")
|
||||
} else if kill := p.Kills[0]; kill.Timestamp.IsZero() {
|
||||
t.Errorf("kill has no timestamp")
|
||||
} else if kill.Victim == "" {
|
||||
t.Errorf("kill has no victim")
|
||||
} else if kill.KillWord.Points == 0 {
|
||||
t.Errorf("dont know points of own kill at game review")
|
||||
} else if kill.KillWord.Word == "" {
|
||||
t.Errorf("dont know own kill word")
|
||||
}
|
||||
if p.KillWords.Global.Word == "" || p.KillWords.Global.Points == 0 {
|
||||
t.Error("self global missing field")
|
||||
}
|
||||
if p.KillWords.Assignee == "" {
|
||||
t.Error("assignee is empty")
|
||||
}
|
||||
if len(p.KillWords.Assignment.Public) == 0 {
|
||||
t.Error("self doesnt know its own public after game")
|
||||
}
|
||||
if len(p.KillWords.Assignment.Private) == 0 {
|
||||
t.Error("self doesnt know its own private after game")
|
||||
}
|
||||
} else {
|
||||
if len(p.Kills) == 0 {
|
||||
} else if kill := p.Kills[0]; kill.Timestamp.IsZero() {
|
||||
t.Errorf("kill has no timestamp")
|
||||
} else if kill.Victim == "" {
|
||||
t.Errorf("cannot know other's victim")
|
||||
} else if kill.KillWord.Points == 0 {
|
||||
t.Errorf("other's kill has no points")
|
||||
} else if kill.KillWord.Word == "" {
|
||||
t.Errorf("dont know other's kill word")
|
||||
}
|
||||
if p.KillWords.Global.Empty() {
|
||||
t.Error("cannot see not self global")
|
||||
}
|
||||
if p.KillWords.Assignee == "" {
|
||||
t.Error("cannot see other player's assignee")
|
||||
}
|
||||
if len(p.KillWords.Assignment.Public) == 0 {
|
||||
t.Error("cannot see other player's public")
|
||||
}
|
||||
if state.Players[ugs.Session.ID].KillWords.Assignee == pid && len(p.KillWords.Assignment.Private) == 0 {
|
||||
t.Error("cannot see assignee's private")
|
||||
} else if state.Players[ugs.Session.ID].KillWords.Assignee != pid && len(p.KillWords.Assignment.Private) == 0 {
|
||||
t.Error("cannot see not assignee's private after game")
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue