-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResponseUtils.cs
1031 lines (909 loc) · 40.4 KB
/
ResponseUtils.cs
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
using BeatLeader.Models;
// ReSharper disable once CheckNamespace
namespace BeatLeader.Utils;
public class ResponseUtils {
public enum FriendActivityType {
Achievement = 1,
MapLiked = 2,
MapRanked = 3,
MapPublished = 4
}
public static ScoreResponse RemoveLeaderboard(Score s, int i) {
return new ScoreResponse {
Id = s.Id,
BaseScore = s.BaseScore,
ModifiedScore = s.ModifiedScore,
PlayerId = s.PlayerId,
Accuracy = s.Accuracy,
Pp = s.Pp,
FcAccuracy = s.FcAccuracy,
FcPp = s.FcPp,
BonusPp = s.BonusPp,
Rank = s.Rank,
Weight = s.Weight,
Replay = s.Replay ?? "",
Modifiers = s.Modifiers ?? "",
BadCuts = s.BadCuts,
MissedNotes = s.MissedNotes,
BombCuts = s.BombCuts,
WallsHit = s.WallsHit,
Pauses = s.Pauses,
FullCombo = s.FullCombo,
Hmd = s.Hmd,
Controller = s.Controller,
MaxCombo = s.MaxCombo,
Timeset = s.Timeset ?? "",
ReplaysWatched = s.AnonimusReplayWatched + s.AuthorizedReplayWatched,
Timepost = s.Timepost,
LeaderboardId = s.LeaderboardId,
Platform = s.Platform,
Player = s.Player is not null
? new PlayerResponse {
Id = s.Player.Id,
Name = s.Player.Name,
Platform = s.Player.Platform,
Avatar = s.Player.Avatar,
Country = s.Player.Country,
Pp = s.Player.Pp,
Rank = s.Player.Rank,
CountryRank = s.Player.CountryRank,
Role = s.Player.Role,
Socials = s.Player.Socials,
PatreonFeatures = s.Player.PatreonFeatures,
ProfileSettings = s.Player.ProfileSettings,
ContextExtensions = s.Player.ContextExtensions?.Select(ce => new PlayerContextExtension {
Context = ce.Context,
Pp = ce.Pp,
AccPp = ce.AccPp,
TechPp = ce.TechPp,
PassPp = ce.PassPp,
PlayerId = ce.PlayerId,
Rank = ce.Rank,
Country = ce.Country,
CountryRank = ce.CountryRank
}).ToList(),
Clans = s.Player.Clans?.OrderBy(c => s.Player.ClanOrder.IndexOf(c.Tag, StringComparison.Ordinal))
.ThenBy(c => c.Id).Select(c => new ClanResponse { Id = c.Id, Tag = c.Tag, Color = c.Color })
}
: null,
ScoreImprovement = s.ScoreImprovement,
RankVoting = s.RankVoting,
Metadata = s.Metadata,
Country = s.Country,
Offsets = s.ReplayOffsets,
MaxStreak = s.MaxStreak
};
}
public static ScoreResponseWithAcc ToScoreResponseWithAcc(Score s, int i) {
return new ScoreResponseWithAcc {
Id = s.Id,
BaseScore = s.BaseScore,
ModifiedScore = s.ModifiedScore,
PlayerId = s.PlayerId,
Accuracy = s.Accuracy,
Pp = s.Pp,
FcAccuracy = s.FcAccuracy,
FcPp = s.FcPp,
BonusPp = s.BonusPp,
Rank = s.Rank,
Weight = s.Weight,
Replay = s.Replay ?? "",
Modifiers = s.Modifiers ?? "",
BadCuts = s.BadCuts,
MissedNotes = s.MissedNotes,
BombCuts = s.BombCuts,
WallsHit = s.WallsHit,
Pauses = s.Pauses,
FullCombo = s.FullCombo,
Hmd = s.Hmd,
Controller = s.Controller,
MaxCombo = s.MaxCombo,
Timeset = s.Timeset ?? "",
ReplaysWatched = s.AnonimusReplayWatched + s.AuthorizedReplayWatched,
Timepost = s.Timepost,
LeaderboardId = s.LeaderboardId,
Platform = s.Platform,
Player = s.Player is not null
? new PlayerResponse {
Id = s.Player.Id,
Name = s.Player.Name,
Platform = s.Player.Platform,
Avatar = s.Player.Avatar,
Country = s.Player.Country,
Pp = s.Player.Pp,
Rank = s.Player.Rank,
CountryRank = s.Player.CountryRank,
Role = s.Player.Role,
Socials = s.Player.Socials,
PatreonFeatures = s.Player.PatreonFeatures,
ProfileSettings = s.Player.ProfileSettings,
ContextExtensions = s.Player.ContextExtensions?.Select(ce => new PlayerContextExtension {
Context = ce.Context,
Pp = ce.Pp,
AccPp = ce.AccPp,
TechPp = ce.TechPp,
PassPp = ce.PassPp,
PlayerId = ce.PlayerId,
Rank = ce.Rank,
Country = ce.Country,
CountryRank = ce.CountryRank
}).ToList(),
Clans = s.Player.Clans?.OrderBy(c => s.Player.ClanOrder.IndexOf(c.Tag, StringComparison.Ordinal))
.ThenBy(c => c.Id).Select(c => new ClanResponse { Id = c.Id, Tag = c.Tag, Color = c.Color })
}
: null,
ScoreImprovement = s.ScoreImprovement,
RankVoting = s.RankVoting,
Metadata = s.Metadata,
Country = s.Country,
Offsets = s.ReplayOffsets,
MaxStreak = s.MaxStreak,
/* Fields of ResponseWithAcc */
AccLeft = s.AccLeft,
AccRight = s.AccRight
};
}
public static ScoreResponse RemoveLeaderboardCE(ScoreContextExtension s, int i)
=> new() {
Id = s.Id,
BaseScore = s.BaseScore,
ModifiedScore = s.ModifiedScore,
PlayerId = s.PlayerId,
Accuracy = s.Accuracy,
Pp = s.Pp,
FcAccuracy = s.Score!.FcAccuracy,
FcPp = s.Score.FcPp,
BonusPp = s.BonusPp,
Rank = s.Rank,
Weight = s.Weight,
Replay = s.Score.Replay!,
Modifiers = s.Modifiers!,
BadCuts = s.Score.BadCuts,
MissedNotes = s.Score.MissedNotes,
BombCuts = s.Score.BombCuts,
WallsHit = s.Score.WallsHit,
Pauses = s.Score.Pauses,
FullCombo = s.Score.FullCombo,
Hmd = s.Score.Hmd,
Controller = s.Score.Controller,
MaxCombo = s.Score.MaxCombo,
Timeset = s.Score.Timeset!,
ReplaysWatched = s.Score.AnonimusReplayWatched + s.Score.AuthorizedReplayWatched,
Timepost = s.Timeset,
LeaderboardId = s.LeaderboardId,
Platform = s.Score.Platform,
Player = s.Player is not null
? new PlayerResponse {
Id = s.Player.Id,
Name = s.Player.Name,
Platform = s.Player.Platform,
Avatar = s.Player.Avatar,
Country = s.Player.Country,
Pp = s.Player.Pp,
Rank = s.Player.Rank,
CountryRank = s.Player.CountryRank,
Role = s.Player.Role,
Socials = s.Player.Socials,
PatreonFeatures = s.Player.PatreonFeatures,
ProfileSettings = s.Player.ProfileSettings,
ContextExtensions = s.Player.ContextExtensions?.Select(ce => new PlayerContextExtension {
PlayerId = ce.PlayerId,
Context = ce.Context,
Pp = ce.Pp,
AccPp = ce.AccPp,
TechPp = ce.TechPp,
PassPp = ce.PassPp,
Rank = ce.Rank,
Country = ce.Country,
CountryRank = ce.CountryRank
}).ToList(),
Clans = s.Player.Clans?.OrderBy(c => s.Player.ClanOrder.IndexOf(c.Tag, StringComparison.Ordinal))
.ThenBy(c => c.Id).Select(c => new ClanResponse { Id = c.Id, Tag = c.Tag, Color = c.Color })
}
: null,
ScoreImprovement = s.ScoreImprovement,
RankVoting = s.Score.RankVoting,
Metadata = s.Score.Metadata,
Country = s.Score.Country,
Offsets = s.Score.ReplayOffsets,
MaxStreak = s.Score.MaxStreak
};
public static ScoreResponseWithAcc ToScoreCEResponseWithAcc(ScoreContextExtension s, int i)
=> new() {
Id = s.Id,
BaseScore = s.BaseScore,
ModifiedScore = s.ModifiedScore,
PlayerId = s.PlayerId,
Accuracy = s.Accuracy,
Pp = s.Pp,
FcAccuracy = s.Score!.FcAccuracy,
FcPp = s.Score.FcPp,
BonusPp = s.BonusPp,
Rank = s.Rank,
Weight = s.Weight,
Replay = s.Score.Replay!,
Modifiers = s.Modifiers!,
BadCuts = s.Score.BadCuts,
MissedNotes = s.Score.MissedNotes,
BombCuts = s.Score.BombCuts,
WallsHit = s.Score.WallsHit,
Pauses = s.Score.Pauses,
FullCombo = s.Score.FullCombo,
Hmd = s.Score.Hmd,
Controller = s.Score.Controller,
MaxCombo = s.Score.MaxCombo,
Timeset = s.Score.Timeset!,
ReplaysWatched = s.Score.AnonimusReplayWatched + s.Score.AuthorizedReplayWatched,
Timepost = s.Timeset,
LeaderboardId = s.LeaderboardId,
Platform = s.Score.Platform,
Player = s.Player is not null
? new PlayerResponse {
Id = s.Player.Id,
Name = s.Player.Name,
Platform = s.Player.Platform,
Avatar = s.Player.Avatar,
Country = s.Player.Country,
Pp = s.Player.Pp,
Rank = s.Player.Rank,
CountryRank = s.Player.CountryRank,
Role = s.Player.Role,
Socials = s.Player.Socials,
PatreonFeatures = s.Player.PatreonFeatures,
ProfileSettings = s.Player.ProfileSettings,
ContextExtensions = s.Player.ContextExtensions?.Select(ce => new PlayerContextExtension {
PlayerId = ce.PlayerId,
Context = ce.Context,
Pp = ce.Pp,
AccPp = ce.AccPp,
TechPp = ce.TechPp,
PassPp = ce.PassPp,
Rank = ce.Rank,
Country = ce.Country,
CountryRank = ce.CountryRank
}).ToList(),
Clans = s.Player.Clans?.OrderBy(c => s.Player.ClanOrder.IndexOf(c.Tag, StringComparison.Ordinal))
.ThenBy(c => c.Id).Select(c => new ClanResponse { Id = c.Id, Tag = c.Tag, Color = c.Color })
}
: null,
ScoreImprovement = s.ScoreImprovement,
RankVoting = s.Score.RankVoting,
Metadata = s.Score.Metadata,
Country = s.Score.Country,
Offsets = s.Score.ReplayOffsets,
MaxStreak = s.Score.MaxStreak,
/* Fields of ResponseWithAcc */
AccLeft = s.Score?.AccLeft ?? 0,
AccRight = s.Score?.AccRight ?? 0
};
public static ScoreResponseWithMyScore ScoreWithMyScore(Score s, int i) {
return new ScoreResponseWithMyScore {
Id = s.Id,
BaseScore = s.BaseScore,
ModifiedScore = s.ModifiedScore,
PlayerId = s.PlayerId,
Accuracy = s.Accuracy,
Pp = s.Pp,
FcAccuracy = s.FcAccuracy,
FcPp = s.FcPp,
BonusPp = s.BonusPp,
Rank = s.Rank,
Weight = s.Weight,
Replay = s.Replay!,
Modifiers = s.Modifiers!,
BadCuts = s.BadCuts,
MissedNotes = s.MissedNotes,
BombCuts = s.BombCuts,
WallsHit = s.WallsHit,
Pauses = s.Pauses,
FullCombo = s.FullCombo,
Hmd = s.Hmd,
Controller = s.Controller,
MaxCombo = s.MaxCombo,
Timeset = s.Timeset!,
ReplaysWatched = s.AnonimusReplayWatched + s.AuthorizedReplayWatched,
Timepost = s.Timepost,
LeaderboardId = s.LeaderboardId,
Platform = s.Platform,
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
Player = s.Player != null
? new PlayerResponse {
Id = s.Player.Id,
Name = s.Player.Name,
Platform = s.Player.Platform,
Avatar = s.Player.Avatar,
Country = s.Player.Country,
Pp = s.Player.Pp,
Rank = s.Player.Rank,
CountryRank = s.Player.CountryRank,
Role = s.Player.Role,
Socials = s.Player.Socials,
PatreonFeatures = s.Player.PatreonFeatures,
ProfileSettings = s.Player.ProfileSettings,
Clans = s.Player.Clans?.OrderBy(c => s.Player.ClanOrder.IndexOf(c.Tag, StringComparison.Ordinal))
.ThenBy(c => c.Id).Select(c => new ClanResponse { Id = c.Id, Tag = c.Tag, Color = c.Color })
}
: null,
ScoreImprovement = s.ScoreImprovement,
RankVoting = s.RankVoting,
Metadata = s.Metadata,
Country = s.Country,
Offsets = s.ReplayOffsets,
Leaderboard = new LeaderboardResponse {
Id = s.LeaderboardId,
Song = s.Leaderboard?.Song,
Difficulty = s.Leaderboard?.Difficulty != null
? new DifficultyResponse {
Id = s.Leaderboard.Difficulty.Id,
Value = s.Leaderboard.Difficulty.Value,
Mode = s.Leaderboard.Difficulty.Mode,
DifficultyName = s.Leaderboard.Difficulty.DifficultyName,
ModeName = s.Leaderboard.Difficulty.ModeName,
Status = s.Leaderboard.Difficulty.Status,
ModifierValues = s.Leaderboard.Difficulty.ModifierValues,
ModifiersRating = s.Leaderboard.Difficulty.ModifiersRating,
NominatedTime = s.Leaderboard.Difficulty.NominatedTime,
QualifiedTime = s.Leaderboard.Difficulty.QualifiedTime,
RankedTime = s.Leaderboard.Difficulty.RankedTime,
Stars = s.Leaderboard.Difficulty.Stars,
PredictedAcc = s.Leaderboard.Difficulty.PredictedAcc,
PassRating = s.Leaderboard.Difficulty.PassRating,
AccRating = s.Leaderboard.Difficulty.AccRating,
TechRating = s.Leaderboard.Difficulty.TechRating,
Type = s.Leaderboard.Difficulty.Type,
Njs = s.Leaderboard.Difficulty.Njs,
Nps = s.Leaderboard.Difficulty.Nps,
Notes = s.Leaderboard.Difficulty.Notes,
Bombs = s.Leaderboard.Difficulty.Bombs,
Walls = s.Leaderboard.Difficulty.Walls,
MaxScore = s.Leaderboard.Difficulty.MaxScore,
Duration = s.Leaderboard.Difficulty.Duration,
Requirements = s.Leaderboard.Difficulty.Requirements
}
: null
},
AccLeft = s.AccLeft,
AccRight = s.AccRight,
MaxStreak = s.MaxStreak,
ValidContexts = s.ValidContexts
};
}
public static PlayerResponse? ResponseFromPLayer(Player? p)
=> p is null
? null
: new PlayerResponse {
Id = p.Id,
Name = p.Name,
Platform = p.Platform,
Avatar = p.Avatar,
Country = p.Country,
Pp = p.Pp,
Rank = p.Rank,
CountryRank = p.CountryRank,
Role = p.Role,
Socials = p.Socials,
PatreonFeatures = p.PatreonFeatures,
ProfileSettings = p.ProfileSettings,
ContextExtensions = p.ContextExtensions,
Clans = p.Clans?.OrderBy(c => p.ClanOrder.IndexOf(c.Tag, StringComparison.Ordinal))
.ThenBy(c => c.Id).Select(c => new ClanResponse { Id = c.Id, Tag = c.Tag, Color = c.Color })
};
public static LeaderboardResponse ResponseFromLeaderboard(Leaderboard l) {
return new LeaderboardResponse {
Id = l.Id,
Song = l.Song,
Difficulty = new DifficultyResponse {
Id = l.Difficulty.Id,
Value = l.Difficulty.Value,
Mode = l.Difficulty.Mode,
DifficultyName = l.Difficulty.DifficultyName,
ModeName = l.Difficulty.ModeName,
Status = l.Difficulty.Status,
ModifierValues = l.Difficulty.ModifierValues,
ModifiersRating = l.Difficulty.ModifiersRating,
NominatedTime = l.Difficulty.NominatedTime,
QualifiedTime = l.Difficulty.QualifiedTime,
RankedTime = l.Difficulty.RankedTime,
Stars = l.Difficulty.Stars,
PredictedAcc = l.Difficulty.PredictedAcc,
PassRating = l.Difficulty.PassRating,
AccRating = l.Difficulty.AccRating,
TechRating = l.Difficulty.TechRating,
Type = l.Difficulty.Type,
Njs = l.Difficulty.Njs,
Nps = l.Difficulty.Nps,
Notes = l.Difficulty.Notes,
Bombs = l.Difficulty.Bombs,
Walls = l.Difficulty.Walls,
MaxScore = l.Difficulty.MaxScore,
Duration = l.Difficulty.Duration,
Requirements = l.Difficulty.Requirements
},
Scores = l.Scores.Select(RemoveLeaderboard).ToList(),
Plays = l.Plays,
Qualification = l.Qualification,
Reweight = l.Reweight,
Changes = l.Changes,
LeaderboardGroup = l.LeaderboardGroup?.Leaderboards?.Select(it =>
new LeaderboardGroupEntry {
Id = it.Id,
Status = it.Difficulty.Status,
Timestamp = it.Timestamp
}
)
};
}
public static PlayerResponseWithStats ResponseWithStatsFromPlayer(Player p) {
return new PlayerResponseWithStats {
Id = p.Id,
Name = p.Name,
Platform = p.Platform,
Avatar = p.Avatar,
Country = p.Country,
ScoreStats = p.ScoreStats,
Pp = p.Pp,
Rank = p.Rank,
CountryRank = p.CountryRank,
LastWeekPp = p.LastWeekPp,
LastWeekRank = p.LastWeekRank,
LastWeekCountryRank = p.LastWeekCountryRank,
Role = p.Role,
EventsParticipating = p.EventsParticipating,
PatreonFeatures = p.PatreonFeatures,
ProfileSettings = p.ProfileSettings,
Clans = p.Clans?.OrderBy(c => p.ClanOrder.IndexOf(c.Tag, StringComparison.Ordinal))
.ThenBy(c => c.Id).Select(c => new ClanResponse { Id = c.Id, Tag = c.Tag, Color = c.Color })
};
}
public static PlayerResponseFull? ResponseFullFromPlayerNullable(Player? p) {
if (p == null) return null;
return ResponseFullFromPlayer(p);
}
public static PlayerResponseFull ResponseFullFromPlayer(Player p) {
return new PlayerResponseFull {
Id = p.Id,
Name = p.Name,
Platform = p.Platform,
Avatar = p.Avatar,
Country = p.Country,
ScoreStats = p.ScoreStats,
MapperId = p.MapperId,
Banned = p.Banned,
Inactive = p.Inactive,
Bot = p.Bot,
ExternalProfileUrl = p.ExternalProfileUrl,
History = p.History,
Badges = p.Badges,
Changes = p.Changes,
Pp = p.Pp,
AccPp = p.AccPp,
TechPp = p.TechPp,
PassPp = p.PassPp,
Rank = p.Rank,
CountryRank = p.CountryRank,
LastWeekPp = p.LastWeekPp,
LastWeekRank = p.LastWeekRank,
LastWeekCountryRank = p.LastWeekCountryRank,
Role = p.Role,
Socials = p.Socials,
EventsParticipating = p.EventsParticipating,
PatreonFeatures = p.PatreonFeatures,
ProfileSettings = p.ProfileSettings,
ContextExtensions = p.ContextExtensions,
Clans = p.Clans?.OrderBy(c => p.ClanOrder.IndexOf(c.Tag, StringComparison.Ordinal))
.ThenBy(c => c.Id).Select(c => new ClanResponse { Id = c.Id, Tag = c.Tag, Color = c.Color })
};
}
public static DiffModResponse DiffModResponseFromDiffAndVotes(DifficultyDescription diff, float[] votes)
=> new() {
DifficultyName = diff.DifficultyName,
ModeName = diff.ModeName,
Stars = diff.Stars,
Status = diff.Status,
Type = diff.Type,
Votes = votes,
ModifierValues = diff.ModifierValues,
ModifiersRating = diff.ModifiersRating,
PassRating = diff.PassRating,
AccRating = diff.AccRating,
TechRating = diff.TechRating
};
public static T? PostProcessSettings<T>(T input) where T : PlayerResponse? {
if (input == null) return null;
input.ProfileSettings ??= new ProfileSettings();
PostProcessSettings(input.Role, input.ProfileSettings, input.PatreonFeatures);
return input;
}
public static void PostProcessSettings(string role, ProfileSettings? settings, PatreonFeatures? patreonFeatures, bool hideStarredFriends = true) {
if (settings != null && hideStarredFriends) {
settings.StarredFriends = "";
}
if (settings is { ProfileAppearance: null }) {
settings.ProfileAppearance = "topPp,averageRankedAccuracy,topPlatform,topHMD";
}
if (!role.Contains("sponsor")) {
if (settings != null) {
settings.Message = null;
}
if (patreonFeatures != null) {
patreonFeatures.Message = "";
}
}
if (settings != null) {
if (settings.EffectName?.Contains("Special") == true) {
if (!role.Contains("creator") &&
!role.Contains("rankedteam") &&
!role.Contains("qualityteam") &&
!role.Contains("juniorrankedteam") &&
!role.Contains("admin")) {
settings.EffectName = "";
}
} else if (settings.EffectName?.Contains("Tier1") == true) {
if (!role.Contains("tipper") &&
!role.Contains("supporter") &&
!role.Contains("sponsor") &&
!role.Contains("creator") &&
!role.Contains("rankedteam") &&
!role.Contains("qualityteam") &&
!role.Contains("juniorrankedteam") &&
!role.Contains("admin") &&
!role.Contains("booster")) {
settings.EffectName = "";
}
} else if (settings.EffectName?.Contains("Tier2") == true) {
if (!role.Contains("supporter") &&
!role.Contains("sponsor") &&
!role.Contains("creator") &&
!role.Contains("rankedteam") &&
!role.Contains("qualityteam") &&
!role.Contains("juniorrankedteam") &&
!role.Contains("admin")) {
settings.EffectName = "";
}
} else if (settings.EffectName?.Contains("Tier3") == true) {
if (!role.Contains("sponsor") &&
!role.Contains("creator") &&
!role.Contains("rankedteam") &&
!role.Contains("qualityteam") &&
!role.Contains("juniorrankedteam") &&
!role.Contains("admin")) {
settings.EffectName = "";
}
} else {
settings.EffectName = "";
}
if (!role.Contains("tipper") &&
!role.Contains("supporter") &&
!role.Contains("sponsor") &&
!role.Contains("creator") &&
!role.Contains("rankedteam") &&
!role.Contains("qualityteam") &&
!role.Contains("juniorrankedteam") &&
!role.Contains("admin")) {
settings.RightSaberColor = null;
settings.LeftSaberColor = null;
}
}
}
public class ClanResponse {
public int Id { get; set; }
public required string Tag { get; set; }
public required string Color { get; set; }
}
public class PlayerResponse {
public required string Id { get; set; }
public string Name { get; set; } = "";
public string Platform { get; set; } = "";
public string Avatar { get; set; } = "";
public string Country { get; set; } = "not set";
public bool Bot { get; set; }
public float Pp { get; set; }
public int Rank { get; set; }
public int CountryRank { get; set; }
public required string Role { get; set; }
public ICollection<PlayerSocial>? Socials { get; set; }
public ICollection<PlayerContextExtension>? ContextExtensions { get; set; }
public PatreonFeatures? PatreonFeatures { get; set; }
public ProfileSettings? ProfileSettings { get; set; }
public IEnumerable<ClanResponse>? Clans { get; set; }
public virtual void ToContext(PlayerContextExtension extension) {
Pp = extension.Pp;
Rank = extension.Rank;
CountryRank = extension.CountryRank;
}
}
public class PlayerResponseWithFriends : PlayerResponse {
public ICollection<string>? Friends { get; set; }
}
public class PlayerResponseWithStats : PlayerResponse {
public float AccPp { get; set; }
public float PassPp { get; set; }
public float TechPp { get; set; }
public PlayerScoreStats? ScoreStats { get; set; }
public float LastWeekPp { get; set; }
public int LastWeekRank { get; set; }
public int LastWeekCountryRank { get; set; }
public IEnumerable<EventPlayer>? EventsParticipating { get; set; }
public override void ToContext(PlayerContextExtension extension) {
Pp = extension.Pp;
AccPp = extension.AccPp;
TechPp = extension.TechPp;
PassPp = extension.PassPp;
Rank = extension.Rank;
CountryRank = extension.CountryRank;
ScoreStats = extension.ScoreStats;
LastWeekPp = extension.LastWeekPp;
LastWeekRank = extension.LastWeekRank;
LastWeekCountryRank = extension.LastWeekCountryRank;
}
}
public class PlayerResponseFull : PlayerResponseWithStats {
public int MapperId { get; set; }
public bool Banned { get; set; }
public bool Inactive { get; set; }
public Ban? BanDescription { get; set; }
public string ExternalProfileUrl { get; set; } = "";
public ICollection<PlayerScoreStatsHistory>? History { get; set; }
public ICollection<Badge>? Badges { get; set; }
public ICollection<ScoreResponseWithMyScore>? PinnedScores { get; set; }
public ICollection<PlayerChange>? Changes { get; set; }
}
public class ScoreSongResponse {
public required string Id { get; set; }
public required string Hash { get; set; }
public required string Cover { get; set; }
public required string Name { get; set; }
public string? SubName { get; set; }
public required string Author { get; set; }
public required string Mapper { get; set; }
}
public class ScoreResponseWithDifficulty : ScoreResponse {
public required DifficultyDescription Difficulty { get; set; }
public required ScoreSongResponse Song { get; set; }
}
public class SaverScoreResponse {
public int Id { get; set; }
public int BaseScore { get; set; }
public int ModifiedScore { get; set; }
public float Accuracy { get; set; }
public float Pp { get; set; }
public int Rank { get; set; }
public required string Modifiers { get; set; }
public required string LeaderboardId { get; set; }
public required string Timeset { get; set; }
public int Timepost { get; set; }
public required string Player { get; set; }
}
public class SaverContainerResponse {
public required string LeaderboardId { get; set; }
public bool Ranked { get; set; }
}
public class LeaderboardsResponse {
public required Song Song { get; set; }
public ICollection<LeaderboardsInfoResponse> Leaderboards { get; set; } = new List<LeaderboardsInfoResponse>();
}
public class LeaderboardsInfoResponse {
public required string Id { get; set; }
public required DifficultyResponse Difficulty { get; set; }
public RankQualification? Qualification { get; set; }
public RankUpdate? Reweight { get; set; }
public bool ClanRankingContested { get; set; }
public required Clan Clan { get; set; }
public void HideRatings() {
Difficulty.HideRatings();
}
}
public class LeaderboardsResponseWithScores : LeaderboardsResponse {
public new required ICollection<LeaderboardsInfoResponseWithScore> Leaderboards { get; set; }
}
public class LeaderboardsInfoResponseWithScore : LeaderboardsInfoResponse {
public ScoreResponseWithAcc? MyScore { get; set; }
}
public class ClanReturn {
public int Id { get; set; }
public required string Name { get; set; }
public required string Color { get; set; }
public required string Icon { get; set; }
public required string Tag { get; set; }
public required string LeaderID { get; set; }
public int PlayersCount { get; set; }
public float Pp { get; set; }
public float AverageRank { get; set; }
public float AverageAccuracy { get; set; }
public float RankedPoolPercentCaptured { get; set; }
public ICollection<Leaderboard> CapturedLeaderboards { get; set; } = new List<Leaderboard>();
public ICollection<string> Players { get; set; } = new List<string>();
public ICollection<string> PendingInvites { get; set; } = new List<string>();
}
public class BanReturn {
public required string Reason { get; set; }
public int Timeset { get; set; }
public int Duration { get; set; }
}
public class UserReturn {
public required PlayerResponseFull Player { get; set; }
public ClanReturn? Clan { get; set; }
public BanReturn? Ban { get; set; }
public ICollection<Clan> ClanRequest { get; set; } = new List<Clan>();
public ICollection<Clan> BannedClans { get; set; } = new List<Clan>();
public ICollection<Playlist>? Playlists { get; set; }
public ICollection<PlayerResponseFull>? Friends { get; set; }
public string? Login { get; set; }
public bool Migrated { get; set; }
public bool Patreoned { get; set; }
}
public class DifficultyDescriptionResponse {
public int Id { get; set; }
public int Value { get; set; }
public int Mode { get; set; }
public required string DifficultyName { get; set; }
public required string ModeName { get; set; }
public DifficultyStatus Status { get; set; }
public ModifiersMap? ModifierValues { get; set; } = new();
public ModifiersRating? ModifiersRating { get; set; }
public int NominatedTime { get; set; }
public int QualifiedTime { get; set; }
public int RankedTime { get; set; }
public float? Stars { get; set; }
public float? PassRating { get; set; }
public float? AccRating { get; set; }
public float? TechRating { get; set; }
public int Type { get; set; }
public float Njs { get; set; }
public float Nps { get; set; }
public int Notes { get; set; }
public int Bombs { get; set; }
public int Walls { get; set; }
public int MaxScore { get; set; }
public double Duration { get; set; }
public Requirements Requirements { get; set; }
}
public class DifficultyResponse {
public int Id { get; set; }
public int Value { get; set; }
public int Mode { get; set; }
public required string DifficultyName { get; set; }
public required string ModeName { get; set; }
public DifficultyStatus Status { get; set; }
public ModifiersMap? ModifierValues { get; set; } = new();
public ModifiersRating? ModifiersRating { get; set; }
public int NominatedTime { get; set; }
public int QualifiedTime { get; set; }
public int RankedTime { get; set; }
public float? Stars { get; set; }
public float? PredictedAcc { get; set; }
public float? PassRating { get; set; }
public float? AccRating { get; set; }
public float? TechRating { get; set; }
public int Type { get; set; }
public float Njs { get; set; }
public float Nps { get; set; }
public int Notes { get; set; }
public int Bombs { get; set; }
public int Walls { get; set; }
public int MaxScore { get; set; }
public double Duration { get; set; }
public Requirements Requirements { get; set; }
public void HideRatings() {
AccRating = null;
TechRating = null;
PassRating = null;
Stars = null;
ModifiersRating = null;
}
}
public class LeaderboardResponse {
public string? Id { get; set; }
public Song? Song { get; set; }
public DifficultyResponse? Difficulty { get; set; }
public List<ScoreResponse>? Scores { get; set; }
public IEnumerable<LeaderboardChange>? Changes { get; set; }
public RankQualification? Qualification { get; set; }
public RankUpdate? Reweight { get; set; }
public IEnumerable<LeaderboardGroupEntry>? LeaderboardGroup { get; set; }
public int Plays { get; set; }
public Clan? Clan { get; set; }
public bool ClanRankingContested { get; set; }
public void HideRatings() {
Difficulty?.HideRatings();
}
}
public class LeaderboardClanRankingResponse : LeaderboardResponse {
public ICollection<ClanRankingResponse>? ClanRanking { get; set; }
}
public class ClanRankingResponse {
public int Id { get; set; }
public required Clan Clan { get; set; }
public int LastUpdateTime { get; set; }
public float AverageRank { get; set; }
public float Pp { get; set; }
public float AverageAccuracy { get; set; }
public float TotalScore { get; set; }
public required string LeaderboardId { get; set; }
public required Leaderboard Leaderboard { get; set; }
public ICollection<ScoreResponse>? AssociatedScores { get; set; }
public int AssociatedScoresCount { get; set; }
}
public class LeaderboardGroupEntry {
public required string Id { get; set; }
public DifficultyStatus Status { get; set; }
public long Timestamp { get; set; }
}
public class LeaderboardInfoResponse {
public required string Id { get; set; }
public required Song Song { get; set; }
public required DifficultyResponse Difficulty { get; set; }
public int Plays { get; set; }
public int PositiveVotes { get; set; }
public int StarVotes { get; set; }
public int NegativeVotes { get; set; }
public float VoteStars { get; set; }
public Clan? Clan { get; set; }
public bool ClanRankingContested { get; set; }
public ScoreResponseWithAcc? MyScore { get; set; }
public RankQualification? Qualification { get; set; }
public RankUpdate? Reweight { get; set; }
public void HideRatings() {
Difficulty.HideRatings();
}
}
public class DiffModResponse {
public required string DifficultyName { get; set; }
public required string ModeName { get; set; }
public float? Stars { get; set; }
public DifficultyStatus Status { get; set; }
public int Type { get; set; }
public required float[] Votes { get; set; }
public ModifiersMap? ModifierValues { get; set; }
public ModifiersRating? ModifiersRating { get; set; }
public float? PassRating { get; set; }
public float? AccRating { get; set; }
public float? TechRating { get; set; }
public void HideRatings() {
AccRating = null;
TechRating = null;
PassRating = null;
Stars = null;
ModifiersRating = null;
}
}
public class CompactScore {
public int Id { get; set; }
public int BaseScore { get; set; }
public int ModifiedScore { get; set; }
public required string Modifiers { get; set; }
public bool FullCombo { get; set; }
public int MaxCombo { get; set; }
public int MissedNotes { get; set; }
public int BadCuts { get; set; }
public HMD Hmd { get; set; }
public ControllerEnum Controller { get; set; }
public float Accuracy { get; set; }
public float? Pp { get; set; }
public int EpochTime { get; set; }