R6(c): drop dead opponent_moved scalars (seat/action/score/total)
These pre-R4 summary scalars on OpponentMovedEvent were redundant with the move/game delta and read by nobody — the UI codec and mock take only move/game/bag_len, and the gateway forwards the push payload verbatim. Removed from scrabble.fbs, the notify emit (notify/events.go) and the round-trip test; regenerated the FB Go + TS bindings. No prod data, so the wire-slot renumber is free and there is no DB change.
This commit is contained in:
@@ -62,20 +62,14 @@ func GameOver(userID, gameID uuid.UUID, result, scoreLine string, game GameSumma
|
||||
// OpponentMoved tells userID that move was just committed in game gameID, carrying it as a delta
|
||||
// the client applies to its cached game without a refetch: move is the decoded play/pass/
|
||||
// exchange, game is the post-move summary (per-seat scores, to_move, move_count, status) and
|
||||
// bagLen is the bag size after the draw. The seat/action/score/total scalars repeat the move's
|
||||
// summary for wire back-compat.
|
||||
// bagLen is the bag size after the draw.
|
||||
func OpponentMoved(userID, gameID uuid.UUID, move engine.MoveRecord, game GameSummary, bagLen int) Intent {
|
||||
b := flatbuffers.NewBuilder(512)
|
||||
gid := b.CreateString(gameID.String())
|
||||
act := b.CreateString(move.Action.String())
|
||||
moveOff := buildMoveRecord(b, move)
|
||||
gameOff := buildGameView(b, game)
|
||||
fb.OpponentMovedEventStart(b)
|
||||
fb.OpponentMovedEventAddGameId(b, gid)
|
||||
fb.OpponentMovedEventAddSeat(b, int32(move.Player))
|
||||
fb.OpponentMovedEventAddAction(b, act)
|
||||
fb.OpponentMovedEventAddScore(b, int32(move.Score))
|
||||
fb.OpponentMovedEventAddTotal(b, int32(move.Total))
|
||||
fb.OpponentMovedEventAddMove(b, moveOff)
|
||||
fb.OpponentMovedEventAddGame(b, gameOff)
|
||||
fb.OpponentMovedEventAddBagLen(b, int32(bagLen))
|
||||
|
||||
@@ -109,10 +109,8 @@ func TestOpponentMovedPayloadRoundTrips(t *testing.T) {
|
||||
t.Fatalf("kind = %q", in.Kind)
|
||||
}
|
||||
ev := fb.GetRootAsOpponentMovedEvent(in.Payload, 0)
|
||||
// The summary scalars repeat the move.
|
||||
if string(ev.GameId()) != gid.String() || ev.Seat() != 1 || string(ev.Action()) != "play" || ev.Score() != 24 || ev.Total() != 130 {
|
||||
t.Fatalf("scalars wrong: game=%q seat=%d action=%q score=%d total=%d",
|
||||
ev.GameId(), ev.Seat(), ev.Action(), ev.Score(), ev.Total())
|
||||
if string(ev.GameId()) != gid.String() {
|
||||
t.Fatalf("game id = %q", ev.GameId())
|
||||
}
|
||||
// The delta: the move, the post-move summary and the bag size.
|
||||
if ev.BagLen() != 42 {
|
||||
|
||||
@@ -510,14 +510,9 @@ table GameOverEvent {
|
||||
// OpponentMovedEvent carries a move another seat just committed as a delta the client applies to
|
||||
// its cached game without a refetch: move is the decoded play/pass/exchange (the same record
|
||||
// game.history returns), game is the post-move summary (per-seat scores, to_move, move_count,
|
||||
// status) and bag_len is the bag size after the draw. The leading seat/action/score/total scalars
|
||||
// are the older summary, now redundant with move/game and kept only for wire back-compat.
|
||||
// status) and bag_len is the bag size after the draw.
|
||||
table OpponentMovedEvent {
|
||||
game_id:string;
|
||||
seat:int;
|
||||
action:string;
|
||||
score:int;
|
||||
total:int;
|
||||
move:MoveRecord;
|
||||
game:GameView;
|
||||
bag_len:int;
|
||||
|
||||
@@ -49,52 +49,8 @@ func (rcv *OpponentMovedEvent) GameId() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) Seat() int32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt32(o + rcv._tab.Pos)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) MutateSeat(n int32) bool {
|
||||
return rcv._tab.MutateInt32Slot(6, n)
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) Action() []byte {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
|
||||
if o != 0 {
|
||||
return rcv._tab.ByteVector(o + rcv._tab.Pos)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) Score() int32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt32(o + rcv._tab.Pos)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) MutateScore(n int32) bool {
|
||||
return rcv._tab.MutateInt32Slot(10, n)
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) Total() int32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(12))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt32(o + rcv._tab.Pos)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) MutateTotal(n int32) bool {
|
||||
return rcv._tab.MutateInt32Slot(12, n)
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) Move(obj *MoveRecord) *MoveRecord {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(14))
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
||||
if obj == nil {
|
||||
@@ -107,7 +63,7 @@ func (rcv *OpponentMovedEvent) Move(obj *MoveRecord) *MoveRecord {
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) Game(obj *GameView) *GameView {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(16))
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
||||
if obj == nil {
|
||||
@@ -120,7 +76,7 @@ func (rcv *OpponentMovedEvent) Game(obj *GameView) *GameView {
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) BagLen() int32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(18))
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt32(o + rcv._tab.Pos)
|
||||
}
|
||||
@@ -128,35 +84,23 @@ func (rcv *OpponentMovedEvent) BagLen() int32 {
|
||||
}
|
||||
|
||||
func (rcv *OpponentMovedEvent) MutateBagLen(n int32) bool {
|
||||
return rcv._tab.MutateInt32Slot(18, n)
|
||||
return rcv._tab.MutateInt32Slot(10, n)
|
||||
}
|
||||
|
||||
func OpponentMovedEventStart(builder *flatbuffers.Builder) {
|
||||
builder.StartObject(8)
|
||||
builder.StartObject(4)
|
||||
}
|
||||
func OpponentMovedEventAddGameId(builder *flatbuffers.Builder, gameId flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(gameId), 0)
|
||||
}
|
||||
func OpponentMovedEventAddSeat(builder *flatbuffers.Builder, seat int32) {
|
||||
builder.PrependInt32Slot(1, seat, 0)
|
||||
}
|
||||
func OpponentMovedEventAddAction(builder *flatbuffers.Builder, action flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(action), 0)
|
||||
}
|
||||
func OpponentMovedEventAddScore(builder *flatbuffers.Builder, score int32) {
|
||||
builder.PrependInt32Slot(3, score, 0)
|
||||
}
|
||||
func OpponentMovedEventAddTotal(builder *flatbuffers.Builder, total int32) {
|
||||
builder.PrependInt32Slot(4, total, 0)
|
||||
}
|
||||
func OpponentMovedEventAddMove(builder *flatbuffers.Builder, move flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(5, flatbuffers.UOffsetT(move), 0)
|
||||
builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(move), 0)
|
||||
}
|
||||
func OpponentMovedEventAddGame(builder *flatbuffers.Builder, game flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(6, flatbuffers.UOffsetT(game), 0)
|
||||
builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(game), 0)
|
||||
}
|
||||
func OpponentMovedEventAddBagLen(builder *flatbuffers.Builder, bagLen int32) {
|
||||
builder.PrependInt32Slot(7, bagLen, 0)
|
||||
builder.PrependInt32Slot(3, bagLen, 0)
|
||||
}
|
||||
func OpponentMovedEventEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
return builder.EndObject()
|
||||
|
||||
@@ -31,77 +31,39 @@ gameId(optionalEncoding?:any):string|Uint8Array|null {
|
||||
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
|
||||
seat():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
action():string|null
|
||||
action(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
|
||||
action(optionalEncoding?:any):string|Uint8Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
|
||||
score():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
total():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 12);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
move(obj?:MoveRecord):MoveRecord|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 14);
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? (obj || new MoveRecord()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
}
|
||||
|
||||
game(obj?:GameView):GameView|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 16);
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? (obj || new GameView()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
}
|
||||
|
||||
bagLen():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 18);
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
static startOpponentMovedEvent(builder:flatbuffers.Builder) {
|
||||
builder.startObject(8);
|
||||
builder.startObject(4);
|
||||
}
|
||||
|
||||
static addGameId(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(0, gameIdOffset, 0);
|
||||
}
|
||||
|
||||
static addSeat(builder:flatbuffers.Builder, seat:number) {
|
||||
builder.addFieldInt32(1, seat, 0);
|
||||
}
|
||||
|
||||
static addAction(builder:flatbuffers.Builder, actionOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(2, actionOffset, 0);
|
||||
}
|
||||
|
||||
static addScore(builder:flatbuffers.Builder, score:number) {
|
||||
builder.addFieldInt32(3, score, 0);
|
||||
}
|
||||
|
||||
static addTotal(builder:flatbuffers.Builder, total:number) {
|
||||
builder.addFieldInt32(4, total, 0);
|
||||
}
|
||||
|
||||
static addMove(builder:flatbuffers.Builder, moveOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(5, moveOffset, 0);
|
||||
builder.addFieldOffset(1, moveOffset, 0);
|
||||
}
|
||||
|
||||
static addGame(builder:flatbuffers.Builder, gameOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(6, gameOffset, 0);
|
||||
builder.addFieldOffset(2, gameOffset, 0);
|
||||
}
|
||||
|
||||
static addBagLen(builder:flatbuffers.Builder, bagLen:number) {
|
||||
builder.addFieldInt32(7, bagLen, 0);
|
||||
builder.addFieldInt32(3, bagLen, 0);
|
||||
}
|
||||
|
||||
static endOpponentMovedEvent(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
|
||||
Reference in New Issue
Block a user