|
|
|
@@ -15,11 +15,11 @@ import (
|
|
|
|
|
// the game/social/lobby services emit events without importing the wire schema.
|
|
|
|
|
|
|
|
|
|
// YourTurn announces to userID that it is their turn in game gameID, with the turn's nominal
|
|
|
|
|
// deadline. opponentName, lastAction, lastWord and scoreLine enrich the out-of-app push (Stage
|
|
|
|
|
// 17): the player who just moved, their move kind, the main word of a scoring play (empty
|
|
|
|
|
// deadline. opponentName, lastAction, lastWord and scoreLine enrich the out-of-app push:
|
|
|
|
|
// the player who just moved, their move kind, the main word of a scoring play (empty
|
|
|
|
|
// otherwise) and the recipient-first running score line. Empty strings render the plain "your
|
|
|
|
|
// turn" text. moveCount is the post-move count, which the client compares against its cached
|
|
|
|
|
// game to detect a missed in-app move and fall back to a refetch (R4).
|
|
|
|
|
// game to detect a missed in-app move and fall back to a refetch.
|
|
|
|
|
func YourTurn(userID, gameID uuid.UUID, deadline time.Time, opponentName, lastAction, lastWord, scoreLine string, moveCount int) Intent {
|
|
|
|
|
b := flatbuffers.NewBuilder(128)
|
|
|
|
|
gid := b.CreateString(gameID.String())
|
|
|
|
@@ -41,9 +41,9 @@ func YourTurn(userID, gameID uuid.UUID, deadline time.Time, opponentName, lastAc
|
|
|
|
|
|
|
|
|
|
// GameOver announces to userID that game gameID finished. result is the outcome from userID's
|
|
|
|
|
// own perspective ("won"/"lost"/"draw") and scoreLine is the recipient-first final score; both
|
|
|
|
|
// feed the out-of-app "game over" push (Stage 17). game is the final post-game summary (the
|
|
|
|
|
// feed the out-of-app "game over" push. game is the final post-game summary (the
|
|
|
|
|
// adjusted scores after rack penalties and the winner flag), so an in-app client settles the
|
|
|
|
|
// finished game from the event without a refetch (R4).
|
|
|
|
|
// finished game from the event without a refetch.
|
|
|
|
|
func GameOver(userID, gameID uuid.UUID, result, scoreLine string, game GameSummary) Intent {
|
|
|
|
|
b := flatbuffers.NewBuilder(512)
|
|
|
|
|
gid := b.CreateString(gameID.String())
|
|
|
|
@@ -60,10 +60,10 @@ 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 (R4): 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
|
|
|
|
|
// bagLen is the bag size after the draw. The seat/action/score/total scalars repeat the move's
|
|
|
|
|
// summary for pre-R4 wire back-compat.
|
|
|
|
|
// summary for wire back-compat.
|
|
|
|
|
func OpponentMoved(userID, gameID uuid.UUID, move engine.MoveRecord, game GameSummary, bagLen int) Intent {
|
|
|
|
|
b := flatbuffers.NewBuilder(512)
|
|
|
|
|
gid := b.CreateString(gameID.String())
|
|
|
|
@@ -116,7 +116,7 @@ func Nudge(userID, gameID, fromUserID uuid.UUID) Intent {
|
|
|
|
|
|
|
|
|
|
// MatchFound tells userID that game gameID, which they are seated in, has started (an auto-match
|
|
|
|
|
// pairing or a robot substitution). state is the recipient's full initial view of the new game,
|
|
|
|
|
// so the client navigates straight in from the event with no follow-up fetch (R4).
|
|
|
|
|
// so the client navigates straight in from the event with no follow-up fetch.
|
|
|
|
|
func MatchFound(userID, gameID uuid.UUID, state PlayerState) Intent {
|
|
|
|
|
b := flatbuffers.NewBuilder(512)
|
|
|
|
|
gid := b.CreateString(gameID.String())
|
|
|
|
@@ -131,7 +131,7 @@ func MatchFound(userID, gameID uuid.UUID, state PlayerState) Intent {
|
|
|
|
|
// Notification is a lightweight "re-poll" signal to userID that something in their lobby
|
|
|
|
|
// changed. kind is a sub-discriminator (NotifyFriendRequest, NotifyFriendAdded,
|
|
|
|
|
// NotifyFriendDeclined, NotifyInvitation, NotifyGameStarted). It carries no payload; prefer the
|
|
|
|
|
// enriched constructors below, which let the client update its lobby without a refetch (R4).
|
|
|
|
|
// enriched constructors below, which let the client update its lobby without a refetch.
|
|
|
|
|
func Notification(userID uuid.UUID, kind string) Intent {
|
|
|
|
|
b := flatbuffers.NewBuilder(32)
|
|
|
|
|
k := b.CreateString(kind)
|
|
|
|
@@ -143,7 +143,7 @@ func Notification(userID uuid.UUID, kind string) Intent {
|
|
|
|
|
|
|
|
|
|
// NotificationAccount builds a lobby notification of one of the friend_* kinds carrying the
|
|
|
|
|
// account it concerns (the requester, the new friend or the decliner), so the client updates its
|
|
|
|
|
// requests/friends lists and the in-game "add friend" state without a refetch (R4).
|
|
|
|
|
// requests/friends lists and the in-game "add friend" state without a refetch.
|
|
|
|
|
func NotificationAccount(userID uuid.UUID, kind string, acc AccountRef) Intent {
|
|
|
|
|
b := flatbuffers.NewBuilder(128)
|
|
|
|
|
k := b.CreateString(kind)
|
|
|
|
@@ -157,7 +157,7 @@ func NotificationAccount(userID uuid.UUID, kind string, acc AccountRef) Intent {
|
|
|
|
|
|
|
|
|
|
// NotificationGameStarted builds the NotifyGameStarted notification carrying the recipient's
|
|
|
|
|
// initial view of the just-started invited game, so the client seeds its game cache and the
|
|
|
|
|
// lobby list without a refetch (R4).
|
|
|
|
|
// lobby list without a refetch.
|
|
|
|
|
func NotificationGameStarted(userID uuid.UUID, state PlayerState) Intent {
|
|
|
|
|
b := flatbuffers.NewBuilder(512)
|
|
|
|
|
k := b.CreateString(NotifyGameStarted)
|
|
|
|
@@ -170,7 +170,7 @@ func NotificationGameStarted(userID uuid.UUID, state PlayerState) Intent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NotificationInvitation builds the NotifyInvitation notification carrying the new invitation,
|
|
|
|
|
// so the client adds it to its lobby invitations list without a refetch (R4).
|
|
|
|
|
// so the client adds it to its lobby invitations list without a refetch.
|
|
|
|
|
func NotificationInvitation(userID uuid.UUID, inv InvitationSummary) Intent {
|
|
|
|
|
b := flatbuffers.NewBuilder(512)
|
|
|
|
|
k := b.CreateString(NotifyInvitation)
|
|
|
|
|