Commit 841307ec authored by Mo Firouz's avatar Mo Firouz Committed by Andrei Mihu
Browse files

Improved support for tournaments feature. (#240)

parent cd0ee5a9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -6,9 +6,15 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
## [Unreleased]
### Added
- New Go code runtime for custom functions and authoritative match handlers.
- New Tournaments feature.
- Runtime custom function triggers for leaderboard and tournament resets.
- Lua runtime AES-256 functions.
- Lua runtime token generator function now returns a second value representing the token's expiry.
- Add local cache for in-memory storage to the Lua runtime.

### Changed
- Improved Postgres compatibility on TIMESTAMPTZ types.

### Fixed
- Correctly merge new friend records when importing from Facebook.
- Log correct registered hook names at startup.
+1308 −336

File changed.

Preview size limit exceeded, changes collapsed.

+400 −0

File changed.

Preview size limit exceeded, changes collapsed.

+161 −3
Original line number Diff line number Diff line
@@ -282,6 +282,10 @@ service Nakama {
    option (google.api.http).post = "/v2/group/{group_id}/join";
  }

  rpc JoinTournament (JoinTournamentRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/tournament/{tournament_id}/join";
  }

  // Kick a set of users from a group.
  rpc KickGroupUsers (KickGroupUsersRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/group/{group_id}/kick";
@@ -368,11 +372,15 @@ service Nakama {
    option (google.api.http).get = "/v2/group/{group_id}/user";
  }

  // List leaderboard records
  // List leaderboard records.
  rpc ListLeaderboardRecords (ListLeaderboardRecordsRequest) returns (LeaderboardRecordList) {
    option (google.api.http).get = "/v2/leaderboard/{leaderboard_id}";
  }

  rpc ListLeaderboardRecordsAroundOwner (ListLeaderboardRecordsAroundOwnerRequest) returns (LeaderboardRecordList) {
    option (google.api.http).get = "/v2/leaderboard/{leaderboard_id}/owner/{owner_id}";
  }

  // Fetch list of running matches.
  rpc ListMatches (ListMatchesRequest) returns (MatchList) {
    option (google.api.http).get = "/v2/match";
@@ -393,6 +401,20 @@ service Nakama {
    };
  }

  // List current or upcoming tournaments.
  rpc ListTournaments (ListTournamentsRequest) returns (TournamentList) {
    option (google.api.http).get = "/v2/tournament";
  }

  // List tournament records.
  rpc ListTournamentRecords (ListTournamentRecordsRequest) returns (TournamentRecordList) {
    option (google.api.http).get = "/v2/tournament/{tournament_id}";
  }

  rpc ListTournamentRecordsAroundOwner (ListTournamentRecordsAroundOwnerRequest) returns (TournamentRecordList) {
    option (google.api.http).get = "/v2/tournament/{tournament_id}/owner/{owner_id}";
  }

  // List groups the current user belongs to.
  rpc ListUserGroups (ListUserGroupsRequest) returns (UserGroupList) {
    option (google.api.http).get = "/v2/user/{user_id}/group";
@@ -522,6 +544,14 @@ service Nakama {
      body: "*"
    };
  }

  // Write a record to a tournament.
  rpc WriteTournamentRecord (WriteTournamentRecordRequest) returns (LeaderboardRecord) {
    option (google.api.http) = {
      put: "/v2/tournament/{tournament_id}",
      body: "record"
    };
  }
}

// A user with additional account details. Always the current user.
@@ -892,10 +922,16 @@ message ImportFacebookFriendsRequest {

// Immediately join an open group, or request to join a closed one.
message JoinGroupRequest {
  // The group ID to join.
  // The group ID to join. The group must already exist.
  string group_id = 1;
}

// The request to join a tournament.
message JoinTournamentRequest {
  // The ID of the tournament to join. The tournament must already exist.
  string tournament_id = 1;
}

// Kick a set of users from a group.
message KickGroupUsersRequest {
  // The group ID to kick from.
@@ -928,6 +964,8 @@ message LeaderboardRecord {
  google.protobuf.Timestamp expiry_time = 10;
  // The rank of this record.
  int64 rank = 11;
  // The maximum number of score updates allowed by the owner.
  uint32 max_num_score = 12;
}

// A set of leaderboard records, may be part of a leaderboard records page or a batch of individual records.
@@ -984,6 +1022,16 @@ message ListGroupUsersRequest {
  string group_id = 1;
}

// List leaerboard records from a given leaderboard around the owner.
message ListLeaderboardRecordsAroundOwnerRequest {
  // The ID of the tournament to list for.
  string leaderboard_id = 1;
  // Max number of records to return. Between 1 and 100.
  google.protobuf.UInt32Value limit = 2;
  // The owner to retrieve records around.
  string owner_id = 3;
}

// List leaderboard records from a given leaderboard.
message ListLeaderboardRecordsRequest {
  // The ID of the leaderboard to list for.
@@ -1030,6 +1078,44 @@ message ListStorageObjectsRequest {
  string cursor = 4; // value from StorageObjectList.cursor.
}

// List tournament records from a given tournament around the owner.
message ListTournamentRecordsAroundOwnerRequest {
  // The ID of the tournament to list for.
  string tournament_id = 1;
  // Max number of records to return. Between 1 and 100.
  google.protobuf.UInt32Value limit = 2;
  // The owner to retrieve records around.
  string owner_id = 3;
}

// List tournament records from a given tournament.
message ListTournamentRecordsRequest {
  // The ID of the tournament to list for.
  string tournament_id = 1;
  // One or more owners to retrieve records for.
  repeated string owner_ids = 2;
  // Max number of records to return. Between 1 and 100.
  google.protobuf.Int32Value limit = 3;
  // A next or previous page cursor.
  string cursor = 4;
}

// List active/upcoming tournaments based on given filters.
message ListTournamentsRequest {
  // The start of the categories to include. Defaults to 0.
  google.protobuf.UInt32Value category_start = 1;
  // The end of the categories to include. Defaults to 128.
  google.protobuf.UInt32Value category_end = 2;
  // The start time for tournaments. Defaults to epoch.
  google.protobuf.UInt32Value start_time = 3;
  // The end time for tournaments. Defaults to +1 year from current Unix time.
  google.protobuf.UInt32Value end_time = 4;
  // Max number of records to return. Between 1 and 100.
  google.protobuf.Int32Value limit = 6;
  // A next page cursor for listings (optional).
  string cursor = 8;
}

// List the groups a user is part of, and their relationship to each.
message ListUserGroupsRequest {
  // ID of the user.
@@ -1178,6 +1264,60 @@ message StorageObjectList {
  string cursor = 2;
}

// A tournament on the server.
message Tournament {
  // The ID of the tournament.
  string id = 1;
  // The title for the tournament.
  string title = 2;
  // The description of the tournament. May be blank.
  string description = 3;
  // The category of the tournament. e.g. "vip" could be category 1.
  uint32 category = 4;
  // ASC or DESC sort mode of scores in the tournament.
  uint32 sort_order = 5;
  // The current number of players in the tournament.
  uint32 size = 6;
  // The maximum number of players for the tournament.
  uint32 max_size = 7;
  // The maximum score updates allowed per player for the current tournament.
  uint32 max_num_score = 8;
  // True if the tournament is active and can enter. A computed value.
  bool can_enter = 9;
  // The UNIX timestamp when the tournament stops being active until next reset. A computed value.
  uint32 end_active = 10;
  // The UNIX timestamp when the tournament is next playable. A computed value.
  uint32 next_reset = 11;
  // Additional information stored as a JSON object.
  string metadata = 12;
  // The UNIX time when the tournament was created.
  google.protobuf.Timestamp create_time = 13;
  // The UNIX time when the tournament will start.
  google.protobuf.Timestamp start_time = 14;
  // The UNIX time when the tournament will be stopped.
  google.protobuf.Timestamp end_time = 15;
}

// A list of tournaments.
message TournamentList {
  // The list of tournaments returned.
  repeated Tournament tournaments = 1;
  // A pagination cursor (optional).
  string cursor = 2;
}

// A set of tournament records which may be part of a tournament records page or a batch of individual records.
message TournamentRecordList {
  // A list of tournament records.
  repeated LeaderboardRecord records = 1;
  // A batched set of tournament records belonging to specified owners.
  repeated LeaderboardRecord owner_records = 2;
  // The cursor to send when retireving the next page (optional).
  string next_cursor = 3;
  // The cursor to send when retrieving the previous page (optional).
  string prev_cursor = 4;
}

// Update a user's account details.
message UpdateAccountRequest {
  // The username of the user's account.
@@ -1294,7 +1434,7 @@ message WriteLeaderboardRecordRequest {

  // The ID of the leaderboard to write to.
  string leaderboard_id = 1;
  // Record data.
  // Record input.
  LeaderboardRecordWrite record = 2;
}

@@ -1319,3 +1459,21 @@ message WriteStorageObjectsRequest {
  // The objects to store on the server.
  repeated WriteStorageObject objects = 1;
}

// A request to submit a score to a tournament.
message WriteTournamentRecordRequest {
  // Record values to write.
  message TournamentRecordWrite {
    // The score value to submit.
    int64 score = 1;
    // An optional secondary value.
    int64 subscore = 2;
    // A JSON object of additional properties (optional).
    string metadata = 3;
  }

  // The tournament ID to write the record for.
  string tournament_id = 1;
  // Record input.
  TournamentRecordWrite record = 2;
}
+405 −3

File changed.

Preview size limit exceeded, changes collapsed.

Loading