using System; namespace TheGame { public class SaveInstance { public string InstanceId { get; set; } public float GameTime { get; set; } public DateTime SaveDate { get; set; } public string DisplayName { get; set; } public bool IsAutoSave { get; set; } = false; public SaveInstance() { InstanceId = Guid.NewGuid().ToString("N")[..8]; // 8-tecken ID SaveDate = DateTime.Now; DisplayName = $"Save {SaveDate:HH:mm:ss}"; } public SaveInstance(float gameTime, string displayName = "", bool isAutoSave = false) { InstanceId = Guid.NewGuid().ToString("N")[..8]; GameTime = gameTime; SaveDate = DateTime.Now; IsAutoSave = isAutoSave; if (string.IsNullOrEmpty(displayName)) { if (isAutoSave) { DisplayName = $"Auto-save {SaveDate:HH:mm:ss}"; } else { DisplayName = $"Save {SaveDate:HH:mm:ss}"; } } else { DisplayName = displayName; } } public string GetFormattedGameTime() { int hours = (int)(GameTime / 3600); int minutes = (int)((GameTime % 3600) / 60); int seconds = (int)(GameTime % 60); return $"{hours:D2}:{minutes:D2}:{seconds:D2}"; } public override string ToString() { return $"{DisplayName} - {GetFormattedGameTime()} ({SaveDate:yyyy-MM-dd HH:mm:ss})"; } } }