Skip to content

Commit

Permalink
Add stuff required server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Dec 4, 2024
1 parent 588fef9 commit 7a1e9cf
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 14 deletions.
8 changes: 8 additions & 0 deletions fluXis.Game/Map/MapEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,21 @@ public class MapEvents : IDeepCloneable<MapEvents>
&& TimeOffsetEvents.Count == 0
&& NoteEvents.Count == 0;

#region Server-Side Stuff

[JsonIgnore]
public string RawContent { get; set; } = "";

#endregion

public static T Load<T>(string content)
where T : MapEvents, new()
{
if (!content.Trim().StartsWith('{'))
return new T().loadLegacy(content) as T;

var events = content.Deserialize<T>();
events.RawContent = content;
return events.Sort() as T;
}

Expand Down
13 changes: 13 additions & 0 deletions fluXis.Game/Map/MapInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ public int MaxCombo
[JsonIgnore]
public string StoryboardHash { get; private set; }

#region Server-Side Stuff

[JsonIgnore]
public string RawContent { get; set; } = "";

[JsonIgnore]
public string FileName { get; set; } = "";

[JsonIgnore]
public int KeyCount => HitObjects.Max(x => x.Lane);

#endregion

public MapInfo(MapMetadata metadata)
: this()
{
Expand Down
4 changes: 2 additions & 2 deletions fluXis.Game/Online/API/Models/Chat/APIChatChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class APIChatChannel
public string Name { get; init; } = null!;

[JsonProperty("type")]
public ChannelType Type { get; init; }
public APIChannelType Type { get; init; }

[JsonProperty("count")]
public long UserCount { get; init; }
}

public enum ChannelType
public enum APIChannelType
{
Public = 0,
Private = 1
Expand Down
4 changes: 2 additions & 2 deletions fluXis.Game/Online/API/Models/Clubs/APIClub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class APIClub
public long MemberCount { get; set; }

[JsonProperty("colors")]
public List<GradientColor> Colors { get; set; } = new();
public List<APIGradientColor> Colors { get; set; } = new();

#region Optional

Expand All @@ -53,7 +53,7 @@ public static APIClub CreateUnknown(long id)
ID = id,
Name = "Unknown Club",
Tag = "UNK",
Colors = new List<GradientColor>
Colors = new List<APIGradientColor>
{
new() { Color = "#ffffff", Position = 0 },
new() { Color = "#ffffff", Position = 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace fluXis.Game.Online.API.Models.Other;

public class GradientColor
public class APIGradientColor
{
[JsonProperty("color")]
public string Color { get; set; } = "#ffffff";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public class APINamePaint
public string Name { get; set; } = "";

[JsonProperty("colors")]
public List<GradientColor> Colors { get; set; } = new();
public List<APIGradientColor> Colors { get; set; } = new();
}
2 changes: 1 addition & 1 deletion fluXis.Game/Utils/Extensions/APIExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class APIExtensions
public static ColourInfo CreateColorInfo(this APIClub club)
=> CreateColorInfo(club.Colors);

public static ColourInfo CreateColorInfo(this List<GradientColor> colors)
public static ColourInfo CreateColorInfo(this List<APIGradientColor> colors)
{
try
{
Expand Down
14 changes: 7 additions & 7 deletions fluXis.Game/Utils/MapUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static RealmMapFilters UpdateFilters(this RealmMapFilters filters, MapInf
filters.NoteCount++;
}

filters.NotesPerSecond = getNps(map.HitObjects);
filters.NotesPerSecond = GetNps(map.HitObjects);

foreach (var timingPoint in map.TimingPoints)
{
Expand All @@ -152,12 +152,15 @@ public static RealmMapFilters UpdateFilters(this RealmMapFilters filters, MapInf
filters.Effects |= MapEffectType.ScrollVelocity;

if (events != null)
filters.Effects = getEffects(events);
filters.Effects = GetEffects(events);

return filters;
}

private static MapEffectType getEffects(MapEvents events)
public static RealmMapFilters GetMapFilters(MapInfo map, MapEvents events)
=> new RealmMapFilters().UpdateFilters(map, events);

public static MapEffectType GetEffects(MapEvents events)
{
MapEffectType effects = 0;

Expand Down Expand Up @@ -206,10 +209,7 @@ private static MapEffectType getEffects(MapEvents events)
return effects;
}

public static RealmMapFilters GetMapFilters(MapInfo map, MapEvents events)
=> new RealmMapFilters().UpdateFilters(map, events);

private static float getNps(List<HitObject> hitObjects)
public static float GetNps(List<HitObject> hitObjects)
{
if (hitObjects.Count == 0) return 0;

Expand Down

0 comments on commit 7a1e9cf

Please sign in to comment.