Skip to content

Commit

Permalink
Add IsLocked, IsSubLevel, and IsCopyable to GameLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Sep 5, 2023
1 parent 0fe4b2f commit 39bb054
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Refresh.GameServer/Database/GameDatabaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected GameDatabaseProvider(IDateTimeProvider time)
this._time = time;
}

protected override ulong SchemaVersion => 84;
protected override ulong SchemaVersion => 85;

protected override string Filename => "refreshGameServer.realm";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public class ApiGameLevelResponse : IApiResponse, IDataConvertableFrom<ApiGameLe
public required int Hearts { get; set; }
public required int UniquePlays { get; set; }
public required bool TeamPicked { get; set; }
public required GameLevelType LevelType { get; set; }
public required bool IsLocked { get; set; }
public required bool IsSubLevel { get; set; }
public required bool IsCopyable { get; set; }

public static ApiGameLevelResponse? FromOld(GameLevel? level)
{
Expand Down Expand Up @@ -61,6 +65,10 @@ public class ApiGameLevelResponse : IApiResponse, IDataConvertableFrom<ApiGameLe
TeamPicked = level.TeamPicked,
RootLevelHash = level.RootResource,
GameVersion = level.GameVersion,
LevelType = level.LevelType,
IsCopyable = level.IsCopyable,
IsLocked = level.IsLocked,
IsSubLevel = level.IsSubLevel,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public class GameLevelRequest
[XmlElement("resource")] public List<string> XmlResources { get; set; } = new();
[XmlElement("leveltype")] public string? LevelType { get; set; } = "";

[XmlElement("initiallyLocked")] public bool IsLocked { get; set; }
[XmlElement("isSubLevel")] public bool IsSubLevel { get; set; }
[XmlElement("shareable")] public int IsCopyable { get; set; }

public GameLevel ToGameLevel(GameUser publisher) =>
new()
{
Expand All @@ -58,5 +62,8 @@ public GameLevel ToGameLevel(GameUser publisher) =>
SkillRewards = this.SkillRewards.ToArray(),
Publisher = publisher,
LevelType = GameLevelTypeExtensions.FromGameString(this.LevelType),
IsLocked = this.IsLocked,
IsSubLevel = this.IsSubLevel,
IsCopyable = this.IsCopyable == 1,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public class GameLevelResponse : IDataConvertableFrom<GameLevelResponse, GameLev
[XmlElement("playerCount")] public int PlayerCount { get; set; }

[XmlElement("leveltype")] public required string LevelType { get; set; }

[XmlElement("initiallyLocked")] public bool IsLocked { get; set; }
[XmlElement("isSubLevel")] public bool IsSubLevel { get; set; }
[XmlElement("shareable")] public int IsCopyable { get; set; }

public static GameLevelResponse? FromOldWithExtraData(GameLevel? old, GameDatabaseContext database, MatchService matchService, GameUser user)
{
Expand Down Expand Up @@ -95,6 +99,9 @@ public class GameLevelResponse : IDataConvertableFrom<GameLevelResponse, GameLev
SkillRewards = old.SkillRewards.ToList(),
TeamPicked = old.TeamPicked,
LevelType = old.LevelType.ToGameString(),
IsCopyable = old.IsCopyable ? 1 : 0,
IsLocked = old.IsLocked,
IsSubLevel = old.IsSubLevel,
};

if (old.Publisher == null)
Expand Down
4 changes: 4 additions & 0 deletions Refresh.GameServer/Types/Levels/GameLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public GameLevelType LevelType

// ReSharper disable once InconsistentNaming
internal int _LevelType { get; set; }

public bool IsLocked { get; set; }
public bool IsSubLevel { get; set; }
public bool IsCopyable { get; set; }

#nullable disable
public IList<GameComment> LevelComments { get; }
Expand Down

0 comments on commit 39bb054

Please sign in to comment.