Skip to content

Commit

Permalink
Set valid actionId to JOIN_GAME events
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiuch committed Feb 25, 2018
1 parent ea6fc35 commit 5e2c4f5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function joinGame(gameId: GameId, user: User): JoinGameAction {
return {
type: 'JOIN_GAME',
payload: {
actionId: 0,
actionId: getActionId(0),
prevActionId: 0,
userId: user.id,
gameId,
Expand Down
2 changes: 1 addition & 1 deletion multiplayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ The action id is a local timestamp, separate for each player. Being a timestamp,

Caveat: To ensure action order consistency, the action id needs to be unique. So each player will ensure a new action's id is higher than the id of the previous action, in the highly unlikely event that two actions are dispatched in the same millisecond.

> **Quirk:** Player state is initiated with `lastActionId` equal to `0`, and `JOIN_GAME` actions also have `actionId` set to `0`.
> Player state is initiated with `lastActionId` equal to `0`, and `JOIN_GAME` actions also have `prevActionId` set to `0`.
2 changes: 1 addition & 1 deletion types/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type LoadGameAction = {
export type JoinGameAction = {
type: 'JOIN_GAME',
payload: {
actionId: 0,
actionId: ActionId,
prevActionId: 0,
gameId: GameId,
userId: UserId,
Expand Down

0 comments on commit 5e2c4f5

Please sign in to comment.