grr how do trial
parent
58fae19522
commit
c6ffa12354
|
|
@ -242,6 +242,9 @@ type (
|
|||
EventCodenameAccusal struct {
|
||||
Type EventType
|
||||
Timestamp time.Time
|
||||
Prosecutor string
|
||||
Killer string
|
||||
Word string
|
||||
}
|
||||
EventCodenameTrial struct {
|
||||
Type EventType
|
||||
|
|
@ -367,6 +370,8 @@ func (games Games) GameState(ctx context.Context, id string) (GameState, error)
|
|||
return result, err
|
||||
}
|
||||
|
||||
var stateBeforeAccusal *GameState
|
||||
|
||||
for _, event := range events {
|
||||
switch e := event.(type) {
|
||||
case EventPlayerJoin:
|
||||
|
|
@ -401,9 +406,19 @@ func (games Games) GameState(ctx context.Context, id string) (GameState, error)
|
|||
result.Players[k] = player
|
||||
}
|
||||
case EventCodenameAccusal:
|
||||
if stateBeforeAccusal == nil {
|
||||
stateBeforeAccusal = &result
|
||||
result = *stateBeforeAccusal
|
||||
|
||||
return GameState{}, fmt.Errorf("not impl: accusal: %+v", e)
|
||||
}
|
||||
case EventCodenameTrial:
|
||||
if stateBeforeAccusal != nil {
|
||||
result = *stateBeforeAccusal
|
||||
stateBeforeAccusal = nil
|
||||
|
||||
return GameState{}, fmt.Errorf("not impl: trial: %+v", e)
|
||||
}
|
||||
case EventGameReset:
|
||||
return games.GameState(ctx, e.ID)
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue