refactor(Core): put Difficulty and GameMode into enums

This commit is contained in:
2026-06-17 07:34:58 +02:00
parent 4ddc039936
commit eeb3868f3e
4 changed files with 25 additions and 7 deletions
+4 -4
View File
@@ -120,7 +120,7 @@ public class WorldsController(DataContext context, CookiePlayerData playerData)
DaysLeft = realm.Subscription.Ended ? -1 : 0, DaysLeft = realm.Subscription.Ended ? -1 : 0,
WorldType = realm.WorldType, WorldType = realm.WorldType,
IsHardcore = realm.ActiveSlot.Settings.Contains("hardcore"), IsHardcore = realm.ActiveSlot.Settings.Contains("hardcore"),
GameMode = realm.ActiveSlot.Options.GameMode, GameMode = (int)realm.ActiveSlot.Options.GameMode,
ActiveSlot = -1, ActiveSlot = -1,
ActiveVersion = realm.ActiveSlot.Options.Version, ActiveVersion = realm.ActiveSlot.Options.Version,
Compatibility = nameof(RealmCompatibility.UNVERIFIABLE) Compatibility = nameof(RealmCompatibility.UNVERIFIABLE)
@@ -203,8 +203,8 @@ public class WorldsController(DataContext context, CookiePlayerData playerData)
{ {
SpawnProtection = slot.Options.SpawnProtection, SpawnProtection = slot.Options.SpawnProtection,
ForceGeeMode = slot.Options.ForceGameMode, ForceGeeMode = slot.Options.ForceGameMode,
Difficulty = slot.Options.Difficulty, Difficulty = (int)slot.Options.Difficulty,
GameMode = slot.Options.GameMode, GameMode = (int)slot.Options.GameMode,
SlotName = slot.Options.SlotName, SlotName = slot.Options.SlotName,
Version = slot.Options.Version, Version = slot.Options.Version,
Compatibility = playerData.Version == slot.Options.Version Compatibility = playerData.Version == slot.Options.Version
@@ -219,7 +219,7 @@ public class WorldsController(DataContext context, CookiePlayerData playerData)
DaysLeft = realm.Subscription.DaysLeft, DaysLeft = realm.Subscription.DaysLeft,
WorldType = realm.WorldType, WorldType = realm.WorldType,
IsHardcore = realm.ActiveSlot.Settings.Contains("hardcore"), IsHardcore = realm.ActiveSlot.Settings.Contains("hardcore"),
GameMode = realm.ActiveSlot.Options.GameMode, GameMode = (int)realm.ActiveSlot.Options.GameMode,
ActiveSlot = realm.ActiveSlot.SlotId, ActiveSlot = realm.ActiveSlot.SlotId,
ActiveVersion = realm.ActiveSlot.Options.Version, ActiveVersion = realm.ActiveSlot.Options.Version,
Compatibility = nameof(RealmCompatibility.UNVERIFIABLE), Compatibility = nameof(RealmCompatibility.UNVERIFIABLE),
+3 -2
View File
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Core.Enums;
namespace Core.Entities; namespace Core.Entities;
@@ -7,8 +8,8 @@ public class SlotOptions
public int Id { get; set; } public int Id { get; set; }
public int SpawnProtection { get; set; } public int SpawnProtection { get; set; }
public bool ForceGameMode { get; set; } public bool ForceGameMode { get; set; }
public int Difficulty { get; set; } public SlotOptionsDifficulty Difficulty { get; set; }
public int GameMode { get; set; } public SlotOptionsGameMode GameMode { get; set; }
public string SlotName { get; set; } = null!; public string SlotName { get; set; } = null!;
public required string Version { get; set; } public required string Version { get; set; }
[JsonIgnore] public int SlotId { get; set; } [JsonIgnore] public int SlotId { get; set; }
+9
View File
@@ -0,0 +1,9 @@
namespace Core.Enums;
public enum SlotOptionsDifficulty
{
Peaceful,
Easy,
Normal,
Hard
}
+8
View File
@@ -0,0 +1,8 @@
namespace Core.Enums;
public enum SlotOptionsGameMode
{
Survival,
Creative,
Adventure
}