-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
664 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
type t = | ||
{ result : Stub.Response.t | ||
; stat_groups : Stub.Stat_group.t list | ||
; leaderboard_stats : Stub.Leaderboard_stat.t list | ||
; rank_total : int | ||
} | ||
|
||
let to_json l = | ||
`Assoc | ||
[ "result", Stub.Response.to_json l.result | ||
; "statGroups", `List (List.map Stub.Stat_group.to_json l.stat_groups) | ||
; "leaderboardStats", `List (List.map Stub.Leaderboard_stat.to_json l.leaderboard_stats) | ||
; "rankTotal", `Int l.rank_total | ||
] | ||
;; | ||
|
||
let from_json json = | ||
let open Yojson.Basic.Util in | ||
{ result = json |> member "result" |> Stub.Response.from_json | ||
; stat_groups = json |> member "statGroups" |> to_list |> List.map Stub.Stat_group.from_json | ||
; leaderboard_stats = json |> member "leaderboardStats" |> to_list |> List.map Stub.Leaderboard_stat.from_json | ||
; rank_total = json |> member "rankTotal" |> to_int | ||
} | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
type t = | ||
| NumberOfWins | ||
| ByRating | ||
|
||
let from_int i = | ||
match i with | ||
| 0 -> NumberOfWins | ||
| 1 -> ByRating | ||
| _ -> failwith (Printf.sprintf "Invalid join policy integer: %d" i) | ||
;; | ||
|
||
let to_int = function NumberOfWins -> 0 | ByRating -> 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
type t = | ||
{ statgroup_id : int | ||
; leaderboard_id : int | ||
; wins : int | ||
; losses : int | ||
; streak : int | ||
; disputes : int | ||
; drops : int | ||
; rank : int | ||
; ranktotal : int | ||
; ranklevel : int | ||
; rating : int | ||
; regionrank : int | ||
; regionranktotal : int | ||
; lastmatchdate : int | ||
; highestrank : int | ||
; highestranklevel : int | ||
; highestrating : int | ||
} | ||
|
||
let to_json sg = | ||
`Assoc | ||
[ "statgroup_id", `Int sg.statgroup_id | ||
; "leaderboard_id", `Int sg.leaderboard_id | ||
; "wins", `Int sg.wins | ||
; "losses", `Int sg.losses | ||
; "streak", `Int sg.streak | ||
; "disputes", `Int sg.disputes | ||
; "drops", `Int sg.drops | ||
; "rank", `Int sg.rank | ||
; "ranktotal", `Int sg.ranktotal | ||
; "ranklevel", `Int sg.ranklevel | ||
; "rating", `Int sg.rating | ||
; "regionrank", `Int sg.regionrank | ||
; "regionranktotal", `Int sg.regionranktotal | ||
; "lastmatchdate", `Int sg.lastmatchdate | ||
; "highestrank", `Int sg.highestrank | ||
; "highestranklevel", `Int sg.highestranklevel | ||
; "highestrating", `Int sg.highestrating | ||
] | ||
;; | ||
|
||
let from_json json = | ||
let open Yojson.Basic.Util in | ||
{ statgroup_id = json |> member "statgroup_id" |> to_int | ||
; leaderboard_id = json |> member "leaderboard_id" |> to_int | ||
; wins = json |> member "wins" |> to_int | ||
; losses = json |> member "losses" |> to_int | ||
; streak = json |> member "streak" |> to_int | ||
; disputes = json |> member "disputes" |> to_int | ||
; drops = json |> member "drops" |> to_int | ||
; rank = json |> member "rank" |> to_int | ||
; ranktotal = json |> member "ranktotal" |> to_int | ||
; ranklevel = json |> member "ranklevel" |> to_int | ||
; rating = json |> member "rating" |> to_int | ||
; regionrank = json |> member "regionrank" |> to_int | ||
; regionranktotal = json |> member "regionranktotal" |> to_int | ||
; lastmatchdate = json |> member "lastmatchdate" |> to_int | ||
; highestrank = json |> member "highestrank" |> to_int | ||
; highestranklevel = json |> member "highestranklevel" |> to_int | ||
; highestrating = json |> member "highestrating" |> to_int | ||
} | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
type t = | ||
{ id : int | ||
; name : string | ||
; type_ : int | ||
; members : Avatar.t list | ||
} | ||
|
||
let to_json s = | ||
`Assoc | ||
[ "id", `Int s.id | ||
; "name", `String s.name | ||
; "type", `Int s.type_ | ||
; "members", `List (List.map Avatar.to_json s.members) | ||
] | ||
;; | ||
|
||
let from_json json = | ||
let open Yojson.Basic.Util in | ||
{ id = json |> member "id" |> to_int | ||
; name = json |> member "name" |> to_string | ||
; type_ = json |> member "type" |> to_int | ||
; members = json |> member "members" |> to_list |> List.map Avatar.from_json | ||
} | ||
;; |
Oops, something went wrong.