Skip to content

Commit

Permalink
Add total damage to end screen of satan (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
SapiensAnatis authored Jul 25, 2023
1 parent c7bb34f commit eaea11d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
3 changes: 2 additions & 1 deletion DragaliaAPI.Shared.Test/Unit/MasterAssetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ public void QuestData_Get_ReturnsExpectedProperties()
PayEntityTargetType: PayTargetType.None,
PayEntityType: 0,
PayEntityId: 0,
PayEntityQuantity: 0
PayEntityQuantity: 0,
IsSumUpTotalDamage: false
)
);

Expand Down
7 changes: 5 additions & 2 deletions DragaliaAPI.Shared/MasterAsset/Models/QuestData.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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> AreaInfo =>
Expand Down
23 changes: 22 additions & 1 deletion DragaliaAPI/Features/Dungeon/DungeonRecordController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AtgenOwnDamageRankingList>()
{
// 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));

Expand Down Expand Up @@ -256,9 +276,10 @@ await eventDropService.ProcessEventMaterialDrops(
is_best_clear_time = clear_time == newQuestData.BestClearTime,
converted_entity_list = new List<ConvertedEntityList>(),
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(),
};
}
Expand Down
6 changes: 4 additions & 2 deletions DragaliaAPI/Models/Generated/Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit eaea11d

Please sign in to comment.