diff --git a/DragaliaAPI.Shared.Test/Unit/MasterAssetTest.cs b/DragaliaAPI.Shared.Test/Unit/MasterAssetTest.cs index 8ac4ca1e6..af71bdb92 100644 --- a/DragaliaAPI.Shared.Test/Unit/MasterAssetTest.cs +++ b/DragaliaAPI.Shared.Test/Unit/MasterAssetTest.cs @@ -258,7 +258,8 @@ public void QuestData_Get_ReturnsExpectedProperties() PayEntityTargetType: PayTargetType.None, PayEntityType: 0, PayEntityId: 0, - PayEntityQuantity: 0 + PayEntityQuantity: 0, + IsSumUpTotalDamage: false ) ); diff --git a/DragaliaAPI.Shared/MasterAsset/Models/QuestData.cs b/DragaliaAPI.Shared/MasterAsset/Models/QuestData.cs index 6ee01db58..3a234281a 100644 --- a/DragaliaAPI.Shared/MasterAsset/Models/QuestData.cs +++ b/DragaliaAPI.Shared/MasterAsset/Models/QuestData.cs @@ -1,5 +1,7 @@ -using DragaliaAPI.Photon.Shared.Enums; +using System.Text.Json.Serialization; +using DragaliaAPI.Photon.Shared.Enums; using DragaliaAPI.Shared.Definitions.Enums; +using DragaliaAPI.Shared.Json; namespace DragaliaAPI.Shared.MasterAsset.Models; @@ -32,7 +34,8 @@ public record QuestData( PayTargetType PayEntityTargetType, EntityTypes PayEntityType, int PayEntityId, - int PayEntityQuantity + int PayEntityQuantity, + [property: JsonConverter(typeof(BoolIntJsonConverter))] bool IsSumUpTotalDamage ) { public IEnumerable AreaInfo => diff --git a/DragaliaAPI/Features/Dungeon/DungeonRecordController.cs b/DragaliaAPI/Features/Dungeon/DungeonRecordController.cs index f4f59779b..81d3d8f7e 100644 --- a/DragaliaAPI/Features/Dungeon/DungeonRecordController.cs +++ b/DragaliaAPI/Features/Dungeon/DungeonRecordController.cs @@ -186,6 +186,26 @@ await eventDropService.ProcessEventMaterialDrops( ) ); + EventDamageRanking? damageRanking = null; + if (session.QuestData.IsSumUpTotalDamage) + { + damageRanking = new() + { + event_id = session.QuestData.Gid, + own_damage_ranking_list = new List() + { + // TODO: track in database to determine if it's a new personal best + new AtgenOwnDamageRankingList() + { + chara_id = 0, + rank = 0, + damage_value = playRecord?.total_play_damage ?? 0, + is_new = false, + } + } + }; + } + await rewardService.GrantReward(new Entity(EntityTypes.Rupies, Quantity: coinDrop)); await rewardService.GrantReward(new Entity(EntityTypes.Mana, Quantity: manaDrop)); @@ -256,9 +276,10 @@ await eventDropService.ProcessEventMaterialDrops( is_best_clear_time = clear_time == newQuestData.BestClearTime, converted_entity_list = new List(), dungeon_skip_type = 0, - total_play_damage = 0, + total_play_damage = playRecord?.total_play_damage ?? 0, }, update_data_list = updateDataList, + event_damage_ranking = damageRanking, entity_result = new(), }; } diff --git a/DragaliaAPI/Models/Generated/Components.cs b/DragaliaAPI/Models/Generated/Components.cs index bb7c0ad77..4a5e76223 100644 --- a/DragaliaAPI/Models/Generated/Components.cs +++ b/DragaliaAPI/Models/Generated/Components.cs @@ -2808,11 +2808,13 @@ public AtgenOption() { } public class AtgenOwnDamageRankingList { public int rank { get; set; } - public int is_new { get; set; } + + [MessagePackFormatter(typeof(BoolToIntFormatter))] + public bool is_new { get; set; } public int chara_id { get; set; } public long damage_value { get; set; } - public AtgenOwnDamageRankingList(int rank, int is_new, int chara_id, long damage_value) + public AtgenOwnDamageRankingList(int rank, bool is_new, int chara_id, long damage_value) { this.rank = rank; this.is_new = is_new;