Puzzles
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Common;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Common.BasicPuzzle;
|
||||
|
||||
[MessagePackObject]
|
||||
public class PuzzleEntryResponse
|
||||
{
|
||||
[JsonPropertyName("puzzle_id")] [JsonConverter(typeof(StringifiedIntConverter))] [Key("puzzle_id")]
|
||||
public int PuzzleId { get; set; }
|
||||
|
||||
[JsonPropertyName("puzzle_difficulty")] [JsonConverter(typeof(StringifiedIntConverter))] [Key("puzzle_difficulty")]
|
||||
public int PuzzleDifficulty { get; set; }
|
||||
|
||||
[JsonPropertyName("is_cleared")] [Key("is_cleared")]
|
||||
public bool IsCleared { get; set; }
|
||||
|
||||
[JsonPropertyName("is_additional")] [Key("is_additional")]
|
||||
public bool IsAdditional { get; set; }
|
||||
|
||||
[JsonPropertyName("is_playable")] [Key("is_playable")]
|
||||
public bool IsPlayable { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("release_condition_text_id")] [Key("release_condition_text_id")]
|
||||
public string ReleaseConditionTextId { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Common;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Common.BasicPuzzle;
|
||||
|
||||
[MessagePackObject]
|
||||
public class PuzzleGroupResponse
|
||||
{
|
||||
[JsonPropertyName("puzzle_master_id")] [JsonConverter(typeof(StringifiedIntConverter))] [Key("puzzle_master_id")]
|
||||
public int PuzzleMasterId { get; set; }
|
||||
|
||||
[JsonPropertyName("puzzle_data")] [Key("puzzle_data")]
|
||||
public List<PuzzleEntryResponse> PuzzleData { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("puzzle_chara_id")] [JsonConverter(typeof(StringifiedIntConverter))] [Key("puzzle_chara_id")]
|
||||
public int PuzzleCharaId { get; set; }
|
||||
|
||||
[JsonPropertyName("puzzle_difficulty_name_list")] [Key("puzzle_difficulty_name_list")]
|
||||
public Dictionary<string, string> PuzzleDifficultyNameList { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("is_all_cleared")] [Key("is_all_cleared")]
|
||||
public bool IsAllCleared { get; set; }
|
||||
|
||||
[JsonPropertyName("chara_id")] [JsonConverter(typeof(StringifiedIntConverter))] [Key("chara_id")]
|
||||
public int CharaId { get; set; }
|
||||
|
||||
[JsonPropertyName("sort_type")] [JsonConverter(typeof(StringifiedIntConverter))] [Key("sort_type")]
|
||||
public int SortType { get; set; }
|
||||
|
||||
[JsonPropertyName("basic_title_text_id")] [Key("basic_title_text_id")]
|
||||
public string BasicTitleTextId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("is_mission_target")] [Key("is_mission_target")]
|
||||
public bool IsMissionTarget { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Common;
|
||||
|
||||
/// <summary>Serializes int as a JSON string ("123"), deserializes from either form. Several
|
||||
/// /basic_puzzle/* fields use this on the wire (puzzle_master_id, total_count, reward_type, etc.).</summary>
|
||||
public sealed class StringifiedIntConverter : JsonConverter<int>
|
||||
{
|
||||
public override int Read(ref Utf8JsonReader r, Type _, JsonSerializerOptions __) =>
|
||||
r.TokenType switch
|
||||
{
|
||||
JsonTokenType.String when int.TryParse(r.GetString(), out var v) => v,
|
||||
JsonTokenType.Number => r.GetInt32(),
|
||||
_ => 0
|
||||
};
|
||||
public override void Write(Utf8JsonWriter w, int v, JsonSerializerOptions _) =>
|
||||
w.WriteStringValue(v.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Same for long. Reward ids fit in int but the client uses long internally.</summary>
|
||||
public sealed class StringifiedLongConverter : JsonConverter<long>
|
||||
{
|
||||
public override long Read(ref Utf8JsonReader r, Type _, JsonSerializerOptions __) =>
|
||||
r.TokenType switch
|
||||
{
|
||||
JsonTokenType.String when long.TryParse(r.GetString(), out var v) => v,
|
||||
JsonTokenType.Number => r.GetInt64(),
|
||||
_ => 0
|
||||
};
|
||||
public override void Write(Utf8JsonWriter w, long v, JsonSerializerOptions _) =>
|
||||
w.WriteStringValue(v.ToString());
|
||||
}
|
||||
Reference in New Issue
Block a user