This repository was archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeaderboardAPI.Script.txt
1541 lines (1381 loc) · 57.3 KB
/
LeaderboardAPI.Script.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Component : Leaderboard API
*/
#Const Version "2021-04-27"
#Const ScriptName "Libs/Nadeo/TMNext/TrackMania/API/LeaderboardAPI.Script.txt"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Libraries
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
#Include "MathLib" as ML
#Include "TextLib" as TL
#Include "Libs/Nadeo/MenuLibs/Common/Manialink/ManiaView2.Script.txt" as MV
#Include "Libs/Nadeo/CommonLibs/Common/Http.Script.txt" as Http
#Include "Libs/Nadeo/TMNext/TrackMania/Structures/CampaignStruct.Script.txt" as CampaignStruct
#Include "Libs/Nadeo/TMNext/TrackMania/Config.Script.txt" as Config
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Constants
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
#Const C_Name "lib-api-leaderboard" //< Component name
#Const P "LibLeaderboardAPI_" //< Prefix use to differentiate functions/variables in the script
#Const C_GroupUid_PersonalBest "Personal_Best" //< Used in leaderboards to get the personal best instead of the seasonal best
#Const C_API_Leaderboard "/api/token/leaderboard/group"
#Const C_API_Trophy "/api/token/leaderboard/trophy"
#Const C_API_TrophyServer "/api/leaderboard/trophy"
#Const C_API_ServerSurrounding "/api/leaderboard/group/:GroupUid/map/:MapUid/surround/:NbBefore/:NbAfter"
#Const C_RouteParameter_GroupUid "GroupUid"
#Const C_RouteParameter_ClubId "ClubId"
#Const C_RouteParameter_MapUid "MapUid"
#Const C_RouteParameter_NbBefore "NbBefore"
#Const C_RouteParameter_NbAfter "NbAfter"
#Const C_QueryParameter_Score "score"
#Const C_QueryParameter_Scores "scores"
#Const C_QueryParameter_Offset "offset"
#Const C_QueryParameter_Length "length"
#Const C_Route_GetPlayerRankings "/:GroupUid"
#Const C_Route_GetTopRankings "/:GroupUid/top"
#Const C_Route_GetPlayerRankingInClub "/:GroupUid/club/:ClubId"
#Const C_Route_GetTopRankingsInClub "/:GroupUid/club/:ClubId/top"
#Const C_Route_GetPlayerAllMapsRankings "/:GroupUid/map"
#Const C_Route_GetPlayerAllMapsRankingsInClub "/:GroupUid/map/club/:ClubId"
#Const C_Route_GetPlayerAllMapsRankingsMultiGroups "/map"
#Const C_Route_GetPlayerAllMapsRankingsInClubMultiGroups "/map/club/:ClubId"
#Const C_Route_GetPlayerMapRankings "/:GroupUid/map/:MapUid"
#Const C_Route_GetMapTopRankings "/:GroupUid/map/:MapUid/top"
#Const C_Route_GetPlayersCloseToMedals "/:GroupUid/map/:MapUid/medals"
#Const C_Route_GetSurroundingRankings "/:GroupUid/map/:MapUid/surround/:NbBefore/:NbAfter"
#Const C_Route_GetPlayerMapRankingInClub "/:GroupUid/map/:MapUid/club/:ClubId"
#Const C_Route_GetMapTopRankingsInClub "/:GroupUid/map/:MapUid/club/:ClubId/top"
#Const C_Route_GetMapSurroundingRankingsInClub "/:GroupUid/map/:MapUid/club/:ClubId/surround/:NbBefore/:NbAfter"
#Const C_Route_GetMapLevels "/:GroupUid/map/:MapUid/level"
#Const C_Route_GetMyTrophyRanking ""
#Const C_Route_GetPlayersTrophyRanking "/player"
#Const C_Route_GetPlayersTrophyRankingServer "/player"
#Const C_Headers [
"Accept" => "application/json",
"Content-Type" => "application/json"
]
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Structs
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
#Struct LibLeaderboardAPI_K_HttpScore {
Integer score;
}
#Struct LibLeaderboardAPI_K_HttpRank {
Integer position;
Integer length;
}
#Struct LibLeaderboardAPI_K_HttpRankZone {
Text zoneId;
Text zoneName;
LibLeaderboardAPI_K_HttpRank ranking;
}
#Struct LibLeaderboardAPI_K_HttpTop {
Text accountId;
Text zoneId;
Text zoneName;
Integer position;
Text sp;
}
#Struct LibLeaderboardAPI_K_HttpPlayerScore {
Text groupUid;
Integer clubId;
Text sp;
Integer position;
}
#Struct LibLeaderboardAPI_K_HttpTopLeaderboard {
Text zoneId;
Text zoneName;
LibLeaderboardAPI_K_HttpTop[] top;
}
#Struct LibLeaderboardAPI_K_HttpTopScore {
Text accountId;
Text zoneId;
Text zoneName;
Integer position;
Integer score;
}
#Struct LibLeaderboardAPI_K_HttpTopScoreLeaderboard {
Text zoneId;
Text zoneName;
LibLeaderboardAPI_K_HttpTopScore[] top;
}
#Struct LibLeaderboardAPI_K_HttpLevel {
Text zoneId;
Text zoneName;
LibLeaderboardAPI_K_HttpTopScore[] level;
}
#Struct LibLeaderboardAPI_K_MapGroupUid {
Text mapUid;
Text groupUid;
}
#Struct LibLeaderboardAPI_K_MapGroupUidList {
LibLeaderboardAPI_K_MapGroupUid[] maps;
}
// ~~~~~~~~~~~~~~~~ //
// Request responses
// ~~~~~~~~~~~~~~~~ //
#Struct LibLeaderboardAPI_K_HttpGetPlayerRankings {
Text groupUid;
Text sp;
LibLeaderboardAPI_K_HttpRankZone[] zones;
}
#Struct LibLeaderboardAPI_K_HttpGetTopRankings {
Text groupUid;
LibLeaderboardAPI_K_HttpTopLeaderboard[] tops;
}
#Struct LibLeaderboardAPI_K_HttpGetTopRankingsInClub {
Text groupUid;
Integer clubId;
Integer length;
LibLeaderboardAPI_K_HttpTop[] top;
}
#Struct LibLeaderboardAPI_K_HttpGetPlayerMapRankings {
Text groupUid;
Text mapUid;
Integer score;
LibLeaderboardAPI_K_HttpRankZone[] zones;
}
#Struct LibLeaderboardAPI_K_HttpGetMapTopRankings {
Text groupUid;
Text mapUid;
LibLeaderboardAPI_K_HttpTopScoreLeaderboard[] tops;
}
#Struct LibLeaderboardAPI_K_HttpPlayerCloseToMedal {
Text medal;
Text accountId;
Text zoneId;
Text zoneName;
Integer score;
}
#Struct LibLeaderboardAPI_K_HttpGetPlayersCloseToMedals {
Text groupUid;
Text mapUid;
LibLeaderboardAPI_K_HttpPlayerCloseToMedal[] medals;
}
#Struct LibLeaderboardAPI_K_HttpGetSurroundingRankings {
Text groupUid;
Text mapUid;
LibLeaderboardAPI_K_HttpTopScoreLeaderboard[] tops;
}
#Struct LibLeaderboardAPI_K_HttpGetPlayerMapRankingInClub {
Text groupUid;
Text mapUid;
Integer clubId;
Integer score;
Integer position;
}
#Struct LibLeaderboardAPI_K_HttpGetMapTopRankingsInClub {
Text groupUid;
Text mapUid;
Integer clubId;
Integer length;
LibLeaderboardAPI_K_HttpTopScore[] top;
}
#Struct LibLeaderboardAPI_K_HttpGetMapSurroundingRankingsInClub {
Text groupUid;
Text mapUid;
Integer clubId;
LibLeaderboardAPI_K_HttpTopScore[] top;
}
#Struct LibLeaderboardAPI_K_HttpGetMapLevels {
Text groupUid;
Text mapUid;
LibLeaderboardAPI_K_HttpLevel[] levels;
}
#Struct LibLeaderboardAPI_K_HttpGetPlayerTrophyRanking {
Integer countPoint;
Text accountId;
Integer echelon;
LibLeaderboardAPI_K_HttpRankZone[] zones;
}
#Struct LibLeaderboardAPI_K_HttpGetPlayersTrophyRanking {
LibLeaderboardAPI_K_HttpGetPlayerTrophyRanking[] rankings;
Integer length;
}
// ~~~~~~~~~~~~~~~~ //
// Processed responses
// ~~~~~~~~~~~~~~~~ //
#Struct LibLeaderboardAPI_K_ResponseFromGetTopRankingsInClub {
Integer ClubId;
Integer Length;
CampaignStruct::LibCampaignStruct_K_Top[] TopRankings;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings {
Text LeaderboardGroupUid;
Text MapUid;
Integer Score;
CampaignStruct::LibCampaignStruct_K_Ranking[] Rankings;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub {
Text LeaderboardGroupUid;
Text MapUid;
Integer ClubId;
Integer Score;
Integer Position;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetMapTopRankings {
Text LeaderboardGroupUid;
CampaignStruct::LibCampaignStruct_K_MapTopRanking[] TopRankings;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetPlayersCloseToMedals {
Text LeaderboardGroupUid;
Text MapUid;
CampaignStruct::LibCampaignStruct_K_PlayerCloseToMedal[] Medals;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetSurroundingRankings {
Text LeaderboardGroupUid;
CampaignStruct::LibCampaignStruct_K_TopScore[][Text] TopsByZone;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetMapLevels {
Text LeaderboardGroupUid;
Text MapUid;
CampaignStruct::LibCampaignStruct_K_TopScore[][Text] LevelsByZone;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetMapTopRankingsInClub {
Text LeaderboardGroupUid;
Integer Length;
CampaignStruct::LibCampaignStruct_K_TopScore[] Tops;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetMapSurroundingRankingsInClub {
Text LeaderboardGroupUid;
CampaignStruct::LibCampaignStruct_K_TopScore[] Tops;
}
// Serveur surrouding API
#Struct LibLeaderboardAPI_K_BodyGetServerSurroundingPlayer {
Text accountId;
Integer score;
}
#Struct LibLeaderboardAPI_K_BodyGetServerSurrounding {
LibLeaderboardAPI_K_BodyGetServerSurroundingPlayer[] listPlayer;
}
#Struct LibLeaderboardAPI_K_HttpSurround {
Text accountId;
LibLeaderboardAPI_K_HttpTopScore[] surround;
}
#Struct LibLeaderboardAPI_K_HttpResponseFromGetServerSurrounding {
Text groupUid;
Text mapUid;
LibLeaderboardAPI_K_HttpTopScore[] top;
LibLeaderboardAPI_K_HttpSurround[] surround;
}
#Struct LibLeaderboardAPI_K_Top {
Integer Position;
Text AccountId;
Integer Score;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetServerSurrounding {
Text MapUid;
LibLeaderboardAPI_K_Top[] WorldTops;
LibLeaderboardAPI_K_Top[][Text] PlayersTops;
}
#Struct LibLeaderboardAPI_K_TrophyPlayer {
Text accountId;
}
#Struct LibLeaderboardAPI_K_BodyGetPlayersTrophyRanking {
LibLeaderboardAPI_K_TrophyPlayer[] listPlayer;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetPlayerTrophyRanking {
Text AccountId;
Integer Points;
Integer Echelon;
CampaignStruct::LibCampaignStruct_K_Ranking[] Ranking;
}
#Struct LibLeaderboardAPI_K_ResponseFromGetPlayersTrophyRanking {
LibLeaderboardAPI_K_ResponseFromGetPlayerTrophyRanking[] Players;
Integer Total;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Functions
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings of the player in a group
*
* @param _GroupUid The group Uid to fetch
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerRankings(Text _GroupUid) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerRankings, [C_RouteParameter_GroupUid => _GroupUid]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayerRankings request
CampaignStruct::LibCampaignStruct_K_CampaignRanking GetResponseFromGetPlayerRankings(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetPlayerRankings HttpGetPlayerRankings;
HttpGetPlayerRankings.fromjson(Http::GetResult(_Request));
declare CampaignStruct::LibCampaignStruct_K_CampaignRanking CampaignRanking;
CampaignRanking.SP = HttpGetPlayerRankings.sp;
declare CampaignStruct::LibCampaignStruct_K_Ranking[] PlayerRankings;
foreach (RankZone in HttpGetPlayerRankings.zones) {
PlayerRankings.add(
CampaignStruct::LibCampaignStruct_K_Ranking {
ZoneId = RankZone.zoneId,
ZoneName = RankZone.zoneName,
Position = RankZone.ranking.position,
Length = RankZone.ranking.length
}
);
}
CampaignRanking.Rankings = PlayerRankings;
return CampaignRanking;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the top rankings of a group
*
* @param _GroupUid The group Uid to fetch
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetTopRankings(Text _GroupUid) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetTopRankings, [C_RouteParameter_GroupUid => _GroupUid]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetTopRankings request
CampaignStruct::LibCampaignStruct_K_TopRanking[] GetResponseFromGetTopRankings(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetTopRankings HttpGetTopRankings;
HttpGetTopRankings.fromjson(Http::GetResult(_Request));
declare CampaignStruct::LibCampaignStruct_K_TopRanking[] TopRankings;
foreach (TopLeaderboard in HttpGetTopRankings.tops) {
declare CampaignStruct::LibCampaignStruct_K_Top[] Tops = [];
foreach (Top in TopLeaderboard.top) {
Tops.add(
CampaignStruct::LibCampaignStruct_K_Top {
AccountId = Top.accountId,
ZoneId = Top.zoneId,
Position = Top.position,
SP = Top.sp
}
);
}
TopRankings.add(
CampaignStruct::LibCampaignStruct_K_TopRanking {
ZoneName = TopLeaderboard.zoneName,
Tops = Tops
}
);
}
return TopRankings;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the top rankings of a group for a specific club
*
* @param _GroupUid The group Uid to fetch
* @param _ClubId The club Id to fetch
* @param _Offset The offset to start the ranking
* @param _Length The length of the ranking
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetTopRankingsInClub(Text _GroupUid, Integer _ClubId, Integer _Offset, Integer _Length) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetTopRankingsInClub, [C_RouteParameter_GroupUid => _GroupUid, C_RouteParameter_ClubId => ""^_ClubId]);
declare Text QueryString = Http::CreateQueryString([
C_QueryParameter_Offset => ""^_Offset,
C_QueryParameter_Length => ""^_Length
]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^QueryString, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetTopRankingsInClub request
LibLeaderboardAPI_K_ResponseFromGetTopRankingsInClub GetResponseFromGetTopRankingsInClub(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetTopRankingsInClub HttpGetTopRankingsInClub;
HttpGetTopRankingsInClub.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetTopRankingsInClub TopRankingsInClub;
TopRankingsInClub.ClubId = HttpGetTopRankingsInClub.clubId;
TopRankingsInClub.Length = HttpGetTopRankingsInClub.length;
foreach (Top in HttpGetTopRankingsInClub.top) {
TopRankingsInClub.TopRankings.add(
CampaignStruct::LibCampaignStruct_K_Top {
AccountId = Top.accountId,
ZoneId = Top.zoneId,
Position = Top.position,
SP = Top.sp
}
);
}
return TopRankingsInClub;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the ranking of the player of a group for a specific club
*
* @param _GroupUid The group Uid to fetch
* @param _ClubId The club Id to fetch
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerRankingInClub(Text _GroupUid, Integer _ClubId) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerRankingInClub, [C_RouteParameter_GroupUid => _GroupUid, C_RouteParameter_ClubId => ""^_ClubId]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayerRankingInClub request
CampaignStruct::LibCampaignStruct_K_Top GetResponseFromGetPlayerRankingInClub(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpPlayerScore HttpPlayerScore;
HttpPlayerScore.fromjson(Http::GetResult(_Request));
return CampaignStruct::LibCampaignStruct_K_Top {
Position = HttpPlayerScore.position,
SP = HttpPlayerScore.sp
};
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings of the player in every maps of a group
*
* @param _GroupUid The group Uid to fetch
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerAllMapsRankings(Text _GroupUid) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerAllMapsRankings, [C_RouteParameter_GroupUid => _GroupUid]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings of the player in every maps of a group
*
* @param _GroupUid The group Uid to fetch
* @param _CurrentScores New player's score to estimate current player's rank (MapUid => Score)
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerAllMapsRankings(Text _GroupUid, Integer[Text] _CurrentScores) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerAllMapsRankings, [C_RouteParameter_GroupUid => _GroupUid]);
declare Text QueryString = Http::CreateQueryString(C_QueryParameter_Scores, _CurrentScores);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^QueryString, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayerAllMapsRankings request
LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings[Text] GetResponseFromGetPlayerAllMapsRankings(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetPlayerMapRankings[Text] HttpGetPlayerAllMapsRankings;
HttpGetPlayerAllMapsRankings.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings[Text] PlayerAllMapsRankings;
foreach (MapUid => HttpGetPlayerMapRankings in HttpGetPlayerAllMapsRankings) {
declare CampaignStruct::LibCampaignStruct_K_Ranking[] Rankings;
foreach (RankZone in HttpGetPlayerMapRankings.zones) {
Rankings.add(
CampaignStruct::LibCampaignStruct_K_Ranking {
ZoneId = RankZone.zoneId,
ZoneName = RankZone.zoneName,
Position = RankZone.ranking.position,
Length = RankZone.ranking.length
}
);
}
PlayerAllMapsRankings[MapUid] = LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings {
LeaderboardGroupUid = HttpGetPlayerMapRankings.groupUid,
MapUid = HttpGetPlayerMapRankings.mapUid,
Score = HttpGetPlayerMapRankings.score,
Rankings = Rankings
};
}
return PlayerAllMapsRankings;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings of the player in every maps of several groups
*
* @param _MapGroupUidList The group and map uid of each map
* @param _CurrentScores New player's score to estimate current player's rank (MapUid => Score)
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerMapGroupUidListRankings(Text[Text] _MapGroupUidList, Integer[Text] _CurrentScores) {
declare Text QueryString = Http::CreateQueryString(C_QueryParameter_Scores, _CurrentScores);
declare LibLeaderboardAPI_K_MapGroupUidList MapGroupUidList;
foreach (MapUid => GroupUid in _MapGroupUidList) {
if (MapUid != "" && GroupUid != "") {
MapGroupUidList.maps.add(LibLeaderboardAPI_K_MapGroupUid {
mapUid = MapUid,
groupUid = GroupUid
});
}
}
return Http::CreatePost(Config::Get().APIBaseUrl^C_API_Leaderboard^C_Route_GetPlayerAllMapsRankingsMultiGroups^QueryString, MapGroupUidList.tojson(), C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayerMapGroupUidListRankings request
LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings[] GetResponseFromGetPlayerMapGroupUidListRankings(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetPlayerMapRankings[] HttpGetPlayerAllMapsRankings;
HttpGetPlayerAllMapsRankings.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings[] PlayerAllMapsRankings;
foreach (HttpGetPlayerMapRankings in HttpGetPlayerAllMapsRankings) {
declare CampaignStruct::LibCampaignStruct_K_Ranking[] Rankings;
foreach (RankZone in HttpGetPlayerMapRankings.zones) {
Rankings.add(
CampaignStruct::LibCampaignStruct_K_Ranking {
ZoneId = RankZone.zoneId,
ZoneName = RankZone.zoneName,
Position = RankZone.ranking.position,
Length = RankZone.ranking.length
}
);
}
PlayerAllMapsRankings.add(LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings {
LeaderboardGroupUid = HttpGetPlayerMapRankings.groupUid,
MapUid = HttpGetPlayerMapRankings.mapUid,
Score = HttpGetPlayerMapRankings.score,
Rankings = Rankings
});
}
return PlayerAllMapsRankings;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings of the player in a club for every maps of a group
*
* @param _GroupUid The group Uid to fetch
* @param _ClubId The club Id to fetch
* @param _Scores Player's score to estimate current player's rank (MapUid => Score)
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerAllMapsRankingsInAClub(Text _GroupUid, Integer _ClubId, Integer[Text] _Scores) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerAllMapsRankingsInClub, [C_RouteParameter_GroupUid => _GroupUid, C_RouteParameter_ClubId => ""^_ClubId]);
declare Text QueryString = Http::CreateQueryString(C_QueryParameter_Scores, _Scores);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^QueryString, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayerAllMapsRankingsInAClub request
LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub[Text] GetResponseFromGetPlayerAllMapsRankingsInAClub(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetPlayerMapRankingInClub[Text] HttpGetPlayerAllMapsRankingsInClub;
HttpGetPlayerAllMapsRankingsInClub.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub[Text] PlayerAllMapsRankingsInClub;
foreach (MapUid => HttpGetPlayerMapRankings in HttpGetPlayerAllMapsRankingsInClub) {
PlayerAllMapsRankingsInClub[MapUid] = LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub {
LeaderboardGroupUid = HttpGetPlayerMapRankings.groupUid,
MapUid = HttpGetPlayerMapRankings.mapUid,
ClubId = HttpGetPlayerMapRankings.clubId,
Score = HttpGetPlayerMapRankings.score,
Position = HttpGetPlayerMapRankings.position
};
}
return PlayerAllMapsRankingsInClub;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings of the player in a club for every maps of several group
*
* @param _MapGroupUidList The group and map uid of each map
* @param _ClubId The club Id to fetch
* @param _Scores Player's score to estimate current player's rank (MapUid => Score)
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerMapGroupUidListRankingsInAClub(Text[Text] _MapGroupUidList, Integer _ClubId, Integer[Text] _Scores) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerAllMapsRankingsInClubMultiGroups, [C_RouteParameter_ClubId => ""^_ClubId]);
declare Text QueryString = Http::CreateQueryString(C_QueryParameter_Scores, _Scores);
declare LibLeaderboardAPI_K_MapGroupUidList MapGroupUidList;
foreach (MapUid => GroupUid in _MapGroupUidList) {
if (MapUid != "" && GroupUid != "") {
MapGroupUidList.maps.add(LibLeaderboardAPI_K_MapGroupUid {
mapUid = MapUid,
groupUid = GroupUid
});
}
}
return Http::CreatePost(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^QueryString, MapGroupUidList.tojson(), C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayerMapGroupUidListRankingsInAClub request
LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub[] GetResponseFromGetPlayerMapGroupUidListRankingsInAClub(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetPlayerMapRankingInClub[] HttpGetPlayerAllMapsRankingsInClub;
HttpGetPlayerAllMapsRankingsInClub.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub[] PlayerAllMapsRankingsInClub;
foreach (HttpGetPlayerMapRankings in HttpGetPlayerAllMapsRankingsInClub) {
PlayerAllMapsRankingsInClub.add(LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub {
LeaderboardGroupUid = HttpGetPlayerMapRankings.groupUid,
MapUid = HttpGetPlayerMapRankings.mapUid,
ClubId = HttpGetPlayerMapRankings.clubId,
Score = HttpGetPlayerMapRankings.score,
Position = HttpGetPlayerMapRankings.position
});
}
return PlayerAllMapsRankingsInClub;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings of the player on a single map of a group
*
* @param _GroupUid The group Uid to fetch
* @param _MapUid The uid of the map
* @param _Score Find the estimated ranking of the player if they do this score
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerMapRankings(Text _GroupUid, Text _MapUid, Integer _Score) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerMapRankings, [C_RouteParameter_GroupUid => _GroupUid, C_RouteParameter_MapUid => _MapUid]);
declare Text QueryString = Http::CreateQueryString([
C_QueryParameter_Score => ""^_Score
]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^QueryString, C_Headers);
}
Http::LibCommonHttp_K_Request GetPlayerMapRankings(Text _GroupUid, Text _MapUid) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerMapRankings, [C_RouteParameter_GroupUid => _GroupUid, C_RouteParameter_MapUid => _MapUid]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayerMapRankings request
LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings GetResponseFromGetPlayerMapRankings(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetPlayerMapRankings HttpGetPlayerMapRankings;
HttpGetPlayerMapRankings.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankings MapRankings;
foreach (RankZone in HttpGetPlayerMapRankings.zones) {
MapRankings.Rankings.add(
CampaignStruct::LibCampaignStruct_K_Ranking {
ZoneId = RankZone.zoneId,
ZoneName = RankZone.zoneName,
Position = RankZone.ranking.position,
Length = RankZone.ranking.length
}
);
}
MapRankings.LeaderboardGroupUid = HttpGetPlayerMapRankings.groupUid;
MapRankings.MapUid = HttpGetPlayerMapRankings.mapUid;
MapRankings.Score = HttpGetPlayerMapRankings.score;
return MapRankings;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get top rankings of a map
*
* @param _GroupUid The group Uid to fetch
* @param _MapUid The map to fetch
* @param _Score The current score on the map
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetMapTopRankings(Text _GroupUid, Text _MapUid, Integer _Score) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetMapTopRankings, [
C_RouteParameter_GroupUid => _GroupUid,
C_RouteParameter_MapUid => _MapUid
]);
declare Text[Text] QueryArray;
if (_Score > 0) {
QueryArray[C_QueryParameter_Score] = ""^_Score;
}
declare Text Query = Http::CreateQueryString(QueryArray);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^Query, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetMapTopRankings request
LibLeaderboardAPI_K_ResponseFromGetMapTopRankings GetResponseFromGetMapTopRankings(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetMapTopRankings HttpGetMapTopRankings;
HttpGetMapTopRankings.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetMapTopRankings MapTopRankings;
foreach (MapTopLeaderboard in HttpGetMapTopRankings.tops) {
declare CampaignStruct::LibCampaignStruct_K_TopScore[] MapTops = [];
foreach (MapTop in MapTopLeaderboard.top) {
MapTops.add(
CampaignStruct::LibCampaignStruct_K_TopScore {
AccountId = MapTop.accountId,
ZoneId = MapTop.zoneId,
Position = MapTop.position,
Score = MapTop.score
}
);
}
MapTopRankings.TopRankings.add(
CampaignStruct::LibCampaignStruct_K_MapTopRanking {
ZoneName = MapTopLeaderboard.zoneName,
Tops = MapTops
}
);
}
MapTopRankings.LeaderboardGroupUid = HttpGetMapTopRankings.groupUid;
return MapTopRankings;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to retrieve players near map's medals
*
* @param _GroupUid The group Uid to fetch
* @param _MapUid The map to fetch
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayersCloseToMedals(Text _GroupUid, Text _MapUid) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayersCloseToMedals, [
C_RouteParameter_GroupUid => _GroupUid,
C_RouteParameter_MapUid => _MapUid
]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayersCloseToMedals request
LibLeaderboardAPI_K_ResponseFromGetPlayersCloseToMedals GetResponseFromGetPlayersCloseToMedals(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetPlayersCloseToMedals HttpGetPlayersCloseToMedals;
HttpGetPlayersCloseToMedals.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetPlayersCloseToMedals PlayersCloseToMedals;
foreach (PlayerCloseToMedal in HttpGetPlayersCloseToMedals.medals) {
PlayersCloseToMedals.Medals.add(CampaignStruct::LibCampaignStruct_K_PlayerCloseToMedal {
Medal = PlayerCloseToMedal.medal,
AccountId = PlayerCloseToMedal.accountId,
ZoneId = PlayerCloseToMedal.zoneId,
ZoneName = PlayerCloseToMedal.zoneName,
Score = PlayerCloseToMedal.score
});
}
PlayersCloseToMedals.LeaderboardGroupUid = HttpGetPlayersCloseToMedals.groupUid;
PlayersCloseToMedals.MapUid = HttpGetPlayersCloseToMedals.mapUid;
return PlayersCloseToMedals;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings surrounding the player in a map
* @ADV This is replaced by C_Route_GetMapLevels, but I leave it here, just in case.
*
* @param _GroupUid The group Uid to fetch
* @param _MapUid The Uid of the map to fetch
* @param _NbBefore The number of rankings to get before the player's rank
* @param _NbAfter The number of rankings to get after the player's rank
* @param _Score The current score on the map
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetSurroundingRankings(Text _GroupUid, Text _MapUid, Integer _NbBefore, Integer _NbAfter, Integer _Score) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetSurroundingRankings, [
C_RouteParameter_GroupUid => _GroupUid,
C_RouteParameter_MapUid => _MapUid,
C_RouteParameter_NbBefore => ""^_NbBefore,
C_RouteParameter_NbAfter => ""^_NbAfter
]);
declare Text[Text] QueryArray;
if (_Score > 0) {
QueryArray[C_QueryParameter_Score] = ""^_Score;
}
declare Text Query = Http::CreateQueryString(QueryArray);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^Query, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetSurroundingRankings request
LibLeaderboardAPI_K_ResponseFromGetSurroundingRankings GetResponseFromGetSurroundingRankings(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetSurroundingRankings HttpGetSurroundingRankings;
HttpGetSurroundingRankings.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetSurroundingRankings SurroundingRankings;
SurroundingRankings.LeaderboardGroupUid = HttpGetSurroundingRankings.groupUid;
foreach (TopZone in HttpGetSurroundingRankings.tops) {
if (!SurroundingRankings.TopsByZone.existskey(TopZone.zoneName)) {
SurroundingRankings.TopsByZone[TopZone.zoneName] = [];
}
foreach (Top in TopZone.top) {
SurroundingRankings.TopsByZone[TopZone.zoneName].add(
CampaignStruct::LibCampaignStruct_K_TopScore {
AccountId = Top.accountId,
ZoneId = Top.zoneId,
Position = Top.position,
Score = Top.score
}
);
}
}
return SurroundingRankings;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the levels of the player in a map
*
* @param _GroupUid The group Uid to fetch
* @param _MapUid The Uid of the map to fetch
* @param _Score The current score on the map
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetMapLevels(Text _GroupUid, Text _MapUid, Integer _Score) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetMapLevels, [
C_RouteParameter_GroupUid => _GroupUid,
C_RouteParameter_MapUid => _MapUid
]);
declare Text[Text] QueryArray;
if (_Score > 0) {
QueryArray[C_QueryParameter_Score] = ""^_Score;
}
declare Text Query = Http::CreateQueryString(QueryArray);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^Query, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetMapLevels request
LibLeaderboardAPI_K_ResponseFromGetMapLevels GetResponseFromGetMapLevels(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetMapLevels HttpGetMapLevels;
HttpGetMapLevels.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetMapLevels ResponseMapLevels;
ResponseMapLevels.LeaderboardGroupUid = HttpGetMapLevels.groupUid;
ResponseMapLevels.MapUid = HttpGetMapLevels.mapUid;
foreach (Level in HttpGetMapLevels.levels) {
if (!ResponseMapLevels.LevelsByZone.existskey(Level.zoneName)) {
ResponseMapLevels.LevelsByZone[Level.zoneName] = [];
}
foreach (TopLevel in Level.level) {
ResponseMapLevels.LevelsByZone[Level.zoneName].add(
CampaignStruct::LibCampaignStruct_K_TopScore {
AccountId = TopLevel.accountId,
Position = TopLevel.position,
Score = TopLevel.score
}
);
}
}
return ResponseMapLevels;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the ranking of a player in a map for a specific club
*
* @param _GroupUid The group Uid to fetch
* @param _MapUid The map to fetch
* @param _ClubId The club Id to fetch
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetPlayerMapRankingInClub(Text _GroupUid, Text _MapUid, Integer _ClubId) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetPlayerMapRankingInClub, [
C_RouteParameter_GroupUid => _GroupUid,
C_RouteParameter_MapUid => _MapUid,
C_RouteParameter_ClubId => ""^_ClubId
]);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetPlayerMapRankingInClub request
LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub GetResponseFromGetPlayerMapRankingInClub(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetPlayerMapRankingInClub HttpGetPlayerMapRankingInClub;
HttpGetPlayerMapRankingInClub.fromjson(Http::GetResult(_Request));
return LibLeaderboardAPI_K_ResponseFromGetPlayerMapRankingsInClub {
LeaderboardGroupUid = HttpGetPlayerMapRankingInClub.groupUid,
MapUid = HttpGetPlayerMapRankingInClub.mapUid,
ClubId = HttpGetPlayerMapRankingInClub.clubId,
Score = HttpGetPlayerMapRankingInClub.score,
Position = HttpGetPlayerMapRankingInClub.position
};
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the top rankings of a map for a specific club
*
* @param _GroupUid The group Uid to fetch
* @param _MapUid The map to fetch
* @param _ClubId The club Id to fetch
* @param _Score The current score on the map
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetMapTopRankingsInClub(Text _GroupUid, Text _MapUid, Integer _ClubId, Integer _Score) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetMapTopRankingsInClub, [
C_RouteParameter_GroupUid => _GroupUid,
C_RouteParameter_MapUid => _MapUid,
C_RouteParameter_ClubId => ""^_ClubId
]);
declare Text[Text] QueryArray;
if (_Score > 0) {
QueryArray[C_QueryParameter_Score] = ""^_Score;
}
declare Text Query = Http::CreateQueryString(QueryArray);
return Http::CreateGet(Config::Get().APIBaseUrl^C_API_Leaderboard^Route^Query, C_Headers);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response to the GetMapTopRankingsInClub request
LibLeaderboardAPI_K_ResponseFromGetMapTopRankingsInClub GetResponseFromGetMapTopRankingsInClub(Http::LibCommonHttp_K_Request _Request) {
declare LibLeaderboardAPI_K_HttpGetMapTopRankingsInClub HttpGetMapTopRankingsInClub;
HttpGetMapTopRankingsInClub.fromjson(Http::GetResult(_Request));
declare LibLeaderboardAPI_K_ResponseFromGetMapTopRankingsInClub MapTopRankingsInClub;
foreach (Top in HttpGetMapTopRankingsInClub.top) {
MapTopRankingsInClub.Tops.add(
CampaignStruct::LibCampaignStruct_K_TopScore {
AccountId = Top.accountId,
ZoneId = Top.zoneId,
Position = Top.position,
Score = Top.score
}
);
}
MapTopRankingsInClub.LeaderboardGroupUid = HttpGetMapTopRankingsInClub.groupUid;
MapTopRankingsInClub.Length = HttpGetMapTopRankingsInClub.length;
return MapTopRankingsInClub;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the rankings from a club surrounding the player in a map
*
* @param _GroupUid The group Uid to fetch
* @param _MapUid The Uid of the map to fetch
* @param _ClubId The id of the club to fetch
* @param _NbBefore The number of rankings to get before the player's rank
* @param _NbAfter The number of rankings to get after the player's rank
* @param _Score The current score on the map
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetMapSurroundingRankingsInClub(Text _GroupUid, Text _MapUid, Integer _ClubId, Integer _NbBefore, Integer _NbAfter, Integer _Score) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetMapSurroundingRankingsInClub, [
C_RouteParameter_GroupUid => _GroupUid,
C_RouteParameter_MapUid => _MapUid,