R6: refactor + docs reconciliation + de-staging #37

Merged
developer merged 6 commits from feature/r6-refactor-destage into development 2026-06-10 16:03:18 +00:00
5 changed files with 19 additions and 126 deletions
Showing only changes of commit 1079878654 - Show all commits
+1 -7
View File
@@ -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 // 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/ // 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 // 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 // bagLen is the bag size after the draw.
// summary for wire back-compat.
func OpponentMoved(userID, gameID uuid.UUID, move engine.MoveRecord, game GameSummary, bagLen int) Intent { func OpponentMoved(userID, gameID uuid.UUID, move engine.MoveRecord, game GameSummary, bagLen int) Intent {
b := flatbuffers.NewBuilder(512) b := flatbuffers.NewBuilder(512)
gid := b.CreateString(gameID.String()) gid := b.CreateString(gameID.String())
act := b.CreateString(move.Action.String())
moveOff := buildMoveRecord(b, move) moveOff := buildMoveRecord(b, move)
gameOff := buildGameView(b, game) gameOff := buildGameView(b, game)
fb.OpponentMovedEventStart(b) fb.OpponentMovedEventStart(b)
fb.OpponentMovedEventAddGameId(b, gid) 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.OpponentMovedEventAddMove(b, moveOff)
fb.OpponentMovedEventAddGame(b, gameOff) fb.OpponentMovedEventAddGame(b, gameOff)
fb.OpponentMovedEventAddBagLen(b, int32(bagLen)) fb.OpponentMovedEventAddBagLen(b, int32(bagLen))
+2 -4
View File
@@ -109,10 +109,8 @@ func TestOpponentMovedPayloadRoundTrips(t *testing.T) {
t.Fatalf("kind = %q", in.Kind) t.Fatalf("kind = %q", in.Kind)
} }
ev := fb.GetRootAsOpponentMovedEvent(in.Payload, 0) ev := fb.GetRootAsOpponentMovedEvent(in.Payload, 0)
// The summary scalars repeat the move. if string(ev.GameId()) != gid.String() {
if string(ev.GameId()) != gid.String() || ev.Seat() != 1 || string(ev.Action()) != "play" || ev.Score() != 24 || ev.Total() != 130 { t.Fatalf("game id = %q", ev.GameId())
t.Fatalf("scalars wrong: game=%q seat=%d action=%q score=%d total=%d",
ev.GameId(), ev.Seat(), ev.Action(), ev.Score(), ev.Total())
} }
// The delta: the move, the post-move summary and the bag size. // The delta: the move, the post-move summary and the bag size.
if ev.BagLen() != 42 { if ev.BagLen() != 42 {
+1 -6
View File
@@ -510,14 +510,9 @@ table GameOverEvent {
// OpponentMovedEvent carries a move another seat just committed as a delta the client applies to // 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 // 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, // 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 // status) and bag_len is the bag size after the draw.
// are the older summary, now redundant with move/game and kept only for wire back-compat.
table OpponentMovedEvent { table OpponentMovedEvent {
game_id:string; game_id:string;
seat:int;
action:string;
score:int;
total:int;
move:MoveRecord; move:MoveRecord;
game:GameView; game:GameView;
bag_len:int; bag_len:int;
+8 -64
View File
@@ -49,52 +49,8 @@ func (rcv *OpponentMovedEvent) GameId() []byte {
return nil 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 { func (rcv *OpponentMovedEvent) Move(obj *MoveRecord) *MoveRecord {
o := flatbuffers.UOffsetT(rcv._tab.Offset(14)) o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
if o != 0 { if o != 0 {
x := rcv._tab.Indirect(o + rcv._tab.Pos) x := rcv._tab.Indirect(o + rcv._tab.Pos)
if obj == nil { if obj == nil {
@@ -107,7 +63,7 @@ func (rcv *OpponentMovedEvent) Move(obj *MoveRecord) *MoveRecord {
} }
func (rcv *OpponentMovedEvent) Game(obj *GameView) *GameView { func (rcv *OpponentMovedEvent) Game(obj *GameView) *GameView {
o := flatbuffers.UOffsetT(rcv._tab.Offset(16)) o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
if o != 0 { if o != 0 {
x := rcv._tab.Indirect(o + rcv._tab.Pos) x := rcv._tab.Indirect(o + rcv._tab.Pos)
if obj == nil { if obj == nil {
@@ -120,7 +76,7 @@ func (rcv *OpponentMovedEvent) Game(obj *GameView) *GameView {
} }
func (rcv *OpponentMovedEvent) BagLen() int32 { func (rcv *OpponentMovedEvent) BagLen() int32 {
o := flatbuffers.UOffsetT(rcv._tab.Offset(18)) o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
if o != 0 { if o != 0 {
return rcv._tab.GetInt32(o + rcv._tab.Pos) return rcv._tab.GetInt32(o + rcv._tab.Pos)
} }
@@ -128,35 +84,23 @@ func (rcv *OpponentMovedEvent) BagLen() int32 {
} }
func (rcv *OpponentMovedEvent) MutateBagLen(n int32) bool { func (rcv *OpponentMovedEvent) MutateBagLen(n int32) bool {
return rcv._tab.MutateInt32Slot(18, n) return rcv._tab.MutateInt32Slot(10, n)
} }
func OpponentMovedEventStart(builder *flatbuffers.Builder) { func OpponentMovedEventStart(builder *flatbuffers.Builder) {
builder.StartObject(8) builder.StartObject(4)
} }
func OpponentMovedEventAddGameId(builder *flatbuffers.Builder, gameId flatbuffers.UOffsetT) { func OpponentMovedEventAddGameId(builder *flatbuffers.Builder, gameId flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(gameId), 0) 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) { 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) { 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) { func OpponentMovedEventAddBagLen(builder *flatbuffers.Builder, bagLen int32) {
builder.PrependInt32Slot(7, bagLen, 0) builder.PrependInt32Slot(3, bagLen, 0)
} }
func OpponentMovedEventEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { func OpponentMovedEventEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject() return builder.EndObject()
@@ -31,77 +31,39 @@ gameId(optionalEncoding?:any):string|Uint8Array|null {
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : 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 { 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; return offset ? (obj || new MoveRecord()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
} }
game(obj?:GameView):GameView|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; return offset ? (obj || new GameView()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
} }
bagLen():number { 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; return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
} }
static startOpponentMovedEvent(builder:flatbuffers.Builder) { static startOpponentMovedEvent(builder:flatbuffers.Builder) {
builder.startObject(8); builder.startObject(4);
} }
static addGameId(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset) { static addGameId(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, gameIdOffset, 0); 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) { 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) { 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) { static addBagLen(builder:flatbuffers.Builder, bagLen:number) {
builder.addFieldInt32(7, bagLen, 0); builder.addFieldInt32(3, bagLen, 0);
} }
static endOpponentMovedEvent(builder:flatbuffers.Builder):flatbuffers.Offset { static endOpponentMovedEvent(builder:flatbuffers.Builder):flatbuffers.Offset {