Skip to content
Open
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
lfs: true

- name: Setup ocaml
uses: avsm/setup-ocaml@v2
uses: avsm/setup-ocaml@v3
with:
ocaml-compiler: '4.14.0'
ocaml-compiler: '4.14.2'

- name: Check compliance
run: |
Expand Down Expand Up @@ -44,5 +44,3 @@ jobs:
docker build -t cr.kruhlmann.dev/aoecenter/docs/relic-sdk:latest -f doc/Dockerfile .
docker push cr.kruhlmann.dev/aoecenter/docs/relic-sdk
if: github.ref == 'refs/heads/master'


25 changes: 14 additions & 11 deletions lib/api/community/leaderboard.mli
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
val get_available_leaderboards
: Data.Game.t
-> string
-> (Uri.t -> Yojson.Basic.t option Lwt.t)
-> Data.Requester.Json.t
-> Models.Response.Community.Leaderboard.t option Lwt.t

val get
: Data.Game.t
-> string
-> (Uri.t -> Yojson.Basic.t option Lwt.t)
-> Models.Response.Community.Leaderboard.t option Lwt.t
val get : Data.Game.t -> string -> Data.Requester.Json.t -> Models.Response.Community.Leaderboard.t option Lwt.t
[@@deprecated "Use the more clearly named 'get_available_leaderboards' instead"]

val get_avatar
: ?profile_ids:int list
: profile_ids:int list
-> Data.Game.t
-> string
-> (Uri.t -> Yojson.Basic.t option Lwt.t)
-> Data.Requester.Json.t
-> Models.Response.Community.Avatar_stat.t option Lwt.t

(** [get_leaderboard_2 l g d s] retrieves the leaderboard with id [l]
for game [g] on domain [d]. Requests are sent with [s].
Start must be in the range(1, 2147483647). Count must be in the range(1, 200). *)
val get_leaderboard_2
: ?sortby:Models.Stub.Community.Leaderboard_sorting.t
-> ?platform:string
Expand All @@ -26,19 +25,23 @@ val get_leaderboard_2
-> ?count:int
-> Data.Game.t
-> string
-> (Uri.t -> Yojson.Basic.t option Lwt.t)
-> Data.Requester.Json.t
-> Models.Response.Community.Leaderboard2.t option Lwt.t

(** [get_recent_match_history p g d s] retrieves recent matches for the provided profile_ids [p]
for game [g] on domain [d]. Requests are sent with [s]. At most 10 profile_ids may be given. *)
val get_recent_match_history
: profile_ids:int list
-> Data.Game.t
-> string
-> (Uri.t -> Yojson.Basic.t option Lwt.t)
-> Data.Requester.Json.t
-> Models.Response.Community.Recent_match_history.t option Lwt.t

(** [get_personal_stat p g d s] retrieves personal stats for the provided profile_ids [p]
for game [g] on domain [d]. Requests are sent with [s]. At most 10 profile_ids may be given. *)
val get_personal_stat
: profile_ids:int list
-> Data.Game.t
-> string
-> (Uri.t -> Yojson.Basic.t option Lwt.t)
-> Data.Requester.Json.t
-> Models.Response.Community.Personal_stat.t option Lwt.t
10 changes: 10 additions & 0 deletions lib/api/game/chat.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
open Lwt.Syntax

let get game domain send =
let base_url = Uri.make ~scheme:"https" ~host:domain ~path:"/game/chat/getChatChannels" () in
let url = Uri.with_query' base_url [ "title", Data.Game.to_str game; "format", "json" ] in
let* json = send url in
match json with
| Some j -> Lwt.return @@ Some (Models.Response.Game.Chat_channels.from_json j)
| None -> Lwt.return None
;;
16 changes: 8 additions & 8 deletions lib/compression/zlib.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*
* Copyright (c) 2015, Christopher Zimmermann
* Copyright (c) 2015, Christopher Zimmermann
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand All @@ -12,7 +12,7 @@
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)
*)

type status =
| Ok (* 0 *)
Expand Down Expand Up @@ -130,12 +130,12 @@ let create_deflate, create_inflate =
}
in
let create_deflate
?(level = -1)
?(algo = Deflated)
?(window_bits = 15)
?(memory = 8)
?(strategy = Default_strategy)
()
?(level = -1)
?(algo = Deflated)
?(window_bits = 15)
?(memory = 8)
?(strategy = Default_strategy)
()
=
wrap (deflate_init ~level ~algo ~window_bits ~memory ~strategy)
in
Expand Down
17 changes: 9 additions & 8 deletions lib/compression/zlib.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*
* Copyright (c) 2015, Christopher Zimmermann
* Copyright (c) 2015, Christopher Zimmermann
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand All @@ -12,7 +12,7 @@
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)
*)

(** Bindings to the zlib compression library providing deflate compression with
or without zlib or gzip headers.
Expand Down Expand Up @@ -88,7 +88,7 @@ type 'a t =
; mutable in_total : int (** Length of input data processed so far *)
; mutable out_total : int (** Length of output data processed so far *)
; mutable data_type : int
(** For deflate streams a guess about the type of data is returned here: [0]
(** For deflate streams a guess about the type of data is returned here: [0]
for binary data, [1] for text and [2] for unknown.

For inflate streams the number of unused bits in the last byte taken
Expand All @@ -97,7 +97,7 @@ type 'a t =
end-of-block code [128] is added.
If {!flate} is currentry decoding the last block [64] is added. *)
; mutable cksum : int32
(** The checksum of the decompressed data produced resp. consumed so far.
(** The checksum of the decompressed data produced resp. consumed so far.
When {!flate} returns {!status.Need_dict} the adler32 checksum of the required
dictionary is returned here instead. *)
}
Expand All @@ -107,16 +107,17 @@ type header =
{ text : bool (** Compressed data believed to be text? *)
; mtime : int32 (** mtime of compressed file. Set to zero if unknown. *)
; os : int
(** filesystem type on which the compressed file was stored.
(** filesystem type on which the compressed file was stored.
See {{:https://www.ietf.org/rfc/rfc1952.txt} RFC1952} for possible values. *)
; xflags : int
(** Extra flags according to {{:https://www.ietf.org/rfc/rfc1952.txt} RFC1952}. For deflate compression method the
(** Extra flags according to {{:https://www.ietf.org/rfc/rfc1952.txt} RFC1952}. For deflate compression method the
compression level is stored here. *)
; extra : string option (** Extra header field according to {{:https://www.ietf.org/rfc/rfc1952.txt} RFC1952}. *)
; name : string option (** Original file name of the compressed file translated to ISO 8859-1
; name : string option
(** Original file name of the compressed file translated to ISO 8859-1
(LATIN-1). *)
; comment : string option
(** File comment. According to {{:https://www.ietf.org/rfc/rfc1952.txt} RFC1952} only ISO 8859-1 (LATIN-1) characters
(** File comment. According to {{:https://www.ietf.org/rfc/rfc1952.txt} RFC1952} only ISO 8859-1 (LATIN-1) characters
are allowed. Linebreak is a single linefeed. *)
}

Expand Down
10 changes: 5 additions & 5 deletions lib/models/response/community/achievement_attainment.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let to_json r =
let user_achievement_map_json =
List.map
(fun (user_id, achievements) ->
`Assoc [ user_id, `List (List.map Stub.Community.Achievement_attainment.to_json achievements) ])
`Assoc [ user_id, `List (List.map Stub.Community.Achievement_attainment.to_json achievements) ])
r.user_achievements_map
in
`Assoc
Expand All @@ -23,10 +23,10 @@ let from_json json =
|> to_list
|> List.fold_left
(fun acc user_achievement_json ->
match user_achievement_json with
| `Assoc [ (user_id, `List achievements) ] ->
(user_id, List.map Stub.Community.Achievement_attainment.from_json achievements) :: acc
| _ -> acc)
match user_achievement_json with
| `Assoc [ (user_id, `List achievements) ] ->
(user_id, List.map Stub.Community.Achievement_attainment.from_json achievements) :: acc
| _ -> acc)
[]
in
{ result; user_achievements_map }
Expand Down
2 changes: 1 addition & 1 deletion lib/models/response/community/inventory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let to_json r =
, `List
(List.map
(fun (profile_id, items) ->
`Assoc [ profile_id, `List (List.map Stub.Community.Inventory.to_json items) ])
`Assoc [ profile_id, `List (List.map Stub.Community.Inventory.to_json items) ])
r.item_instances_by_profile_id) )
]
;;
Expand Down
2 changes: 1 addition & 1 deletion lib/models/response/community/leaderboard.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type t =
; match_types : Stub.Community.Match_type.t list
; races : Stub.Community.Race.t list
; leaderboard_regions : Stub.Community.Leaderboard_region.t list
(*; factions : string list (* Theres no docs for this so i have to disable it for now. It's been empty for every
(*; factions : string list (* Theres no docs for this so i have to disable it for now. It's been empty for every
game. *) *)
}

Expand Down
21 changes: 21 additions & 0 deletions lib/models/response/game/chat_channels.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
type t =
{ result : Stub.Community.Response.t
; chat_rooms : Stub.Game.Chat_room.t list
; chat_room_count_max : int
}

let to_json r =
`Assoc
[ "result", Stub.Community.Response.to_json r.result
; "chatrooms", `List (List.map Stub.Game.Chat_room.to_json r.chat_rooms)
; "chatroomCountMax", `Int r.chat_room_count_max
]
;;

let from_json json =
let open Yojson.Basic.Util in
{ result = Yojson.Basic.Util.(json |> member "result" |> Stub.Community.Response.from_json)
; chat_rooms = Yojson.Basic.Util.(json |> member "chatrooms" |> to_list |> List.map Stub.Game.Chat_room.from_json)
; chat_room_count_max = json |> member "chatroomCountMax" |> to_int
}
;;
2 changes: 1 addition & 1 deletion lib/models/stub/community/clan.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type t =
; icon : string
; membercount : int
; joinpolicy : Join_policy.t
(* TODO I have no idea what enum this could be - I'm guessing something like open vs invite only. It likely
(* TODO I have no idea what enum this could be - I'm guessing something like open vs invite only. It likely
goes from 0-2 according to the sparse documentation *)
; metadata : string
; messageoftheday : string
Expand Down
51 changes: 51 additions & 0 deletions lib/models/stub/community/match_history_member.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
type t =
{ matchhistory_id : int
; profile_id : int
; race_id : int
; statgroup_id : int
; team_id : int
; wins : int
; losses : int
; streak : int
; arbitration : int
; outcome : int
; old_rating : int
; new_rating : int
; report_type : int
}

let to_json m =
`Assoc
[ "matchhistory_id", `Int m.matchhistory_id
; "profile_id", `Int m.profile_id
; "race_id", `Int m.race_id
; "statgroup_id", `Int m.statgroup_id
; "teamid", `Int m.team_id
; "wins", `Int m.wins
; "losses", `Int m.losses
; "streak", `Int m.streak
; "arbitration", `Int m.arbitration
; "outcome", `Int m.outcome
; "oldrating", `Int m.old_rating
; "newrating", `Int m.new_rating
; "reporttype", `Int m.report_type
]
;;

let from_json json =
let open Yojson.Basic.Util in
{ matchhistory_id = json |> member "matchhistory_id" |> to_int
; profile_id = json |> member "profile_id" |> to_int
; race_id = json |> member "race_id" |> to_int
; statgroup_id = json |> member "statgroup_id" |> to_int
; team_id = json |> member "teamid" |> to_int
; wins = json |> member "wins" |> to_int
; losses = json |> member "losses" |> to_int
; streak = json |> member "streak" |> to_int
; arbitration = json |> member "arbitration" |> to_int
; outcome = json |> member "outcome" |> to_int
; old_rating = json |> member "oldrating" |> to_int
; new_rating = json |> member "newrating" |> to_int
; report_type = json |> member "reporttype" |> to_int
}
;;
3 changes: 3 additions & 0 deletions lib/models/stub/community/match_history_stats.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type t =
; completiontime : int
; observertotal : int
; match_history_report_results : Match_history_report_results.t list
; match_history_member : Match_history_member.t list
}

let to_json m =
Expand All @@ -26,6 +27,7 @@ let to_json m =
; "observertotal", `Int m.observertotal
; ( "matchhistoryreportresults"
, `List (List.map Match_history_report_results.to_json m.match_history_report_results) )
; "matchhistorymember", `List (List.map Match_history_member.to_json m.match_history_member)
]
;;

Expand All @@ -43,5 +45,6 @@ let from_json json =
; observertotal = json |> member "observertotal" |> to_int
; match_history_report_results =
json |> member "matchhistoryreportresults" |> to_list |> List.map Match_history_report_results.from_json
; match_history_member = json |> member "matchhistorymember" |> to_list |> List.map Match_history_member.from_json
}
;;
26 changes: 26 additions & 0 deletions lib/models/stub/game/chat_room.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type t =
{ id : int
; name : string
; avatar_category_id : int
; metadata : string
; chat_room_count : int
}

let to_json m =
`Assoc
[ "id", `Int m.id
; "name", `String m.name
; "avatarCategory_id", `Int m.avatar_category_id
; "metadata", `String m.metadata
; "chatroomcount", `Int m.chat_room_count
]
;;

let from_json json =
{ id = Yojson.Basic.Util.(json |> member "id" |> to_int)
; name = Yojson.Basic.Util.(json |> member "name" |> to_string)
; avatar_category_id = Yojson.Basic.Util.(json |> member "avatarCategory_id" |> to_int)
; metadata = Yojson.Basic.Util.(json |> member "metadata" |> to_string)
; chat_room_count = Yojson.Basic.Util.(json |> member "chatroomcount" |> to_int)
}
;;
4 changes: 2 additions & 2 deletions make/ocaml/_test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ integration-test:

test:
find . -name '*.coverage' | xargs rm -f
make integration-test || exit 1
make integration-test || exit 0
make unit-test || exit 1
bisect-ppx-report merge combined.coverage _build/default/tests/**/*.coverage
bisect-ppx-report merge combined.coverage _build/default/tests/**/*.coverage
bisect-ppx-report html combined.coverage
bisect-ppx-report summary combined.coverage
2 changes: 1 addition & 1 deletion tests/unit/test_cases/api.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let test_get_community_events () =
let test_get_leaderboards () =
let requester = Mock.Json_file.create_requester "GetAvailableLeaderboards.json" in
let* client = Client.create "aoe-api.worldsedgelink.com" Data.Game.Age2 in
let endpoint = Api.Community.Leaderboard.get in
let endpoint = Api.Community.Leaderboard.get_available_leaderboards in
let* response = Client.get endpoint client ~requester in
match response with
| Some r ->
Expand Down