feat: 合并本次掉落和掉落统计

This commit is contained in:
DavidWang19
2022-10-20 17:38:26 +01:00
parent 4c948b0485
commit f2788a3463
2 changed files with 18 additions and 23 deletions

View File

@@ -137,15 +137,10 @@ void asst::StageDropsTaskPlugin::drop_info_callback()
{
LogTraceFunction;
std::vector<json::value> drops_vec;
std::unordered_map<std::string, int> cur_drops_count;
for (const auto& drop : m_cur_drops) {
json::value info;
info["itemId"] = drop.item_id;
info["quantity"] = drop.quantity;
m_drop_stats[drop.item_id] += drop.quantity;
info["itemName"] = drop.item_name;
info["dropType"] = drop.drop_type_name;
drops_vec.emplace_back(std::move(info));
cur_drops_count.emplace(drop.item_id, drop.quantity);
}
std::vector<json::value> stats_vec;
@@ -154,7 +149,13 @@ void asst::StageDropsTaskPlugin::drop_info_callback()
info["itemId"] = id;
const std::string& name = ItemData.get_item_name(id);
info["itemName"] = name.empty() ? id : name;
info["quantity"] = count;
info["totalQuantity"] = count;
if (auto iter = cur_drops_count.find(id); iter != cur_drops_count.end()) {
info["addQuantity"] = iter->second;
}
else {
info["addQuantity"] = 0;
}
stats_vec.emplace_back(std::move(info));
}
//// 排个序,数量多的放前面
@@ -167,7 +168,6 @@ void asst::StageDropsTaskPlugin::drop_info_callback()
json::value& details = info["details"];
details["stars"] = m_stars;
details["stats"] = json::array(std::move(stats_vec));
details["drops"] = json::array(std::move(drops_vec));
json::value& stage = details["stage"];
stage["stageCode"] = m_stage_code;
if (!m_stage_code.empty()) {

View File

@@ -14,6 +14,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -726,25 +727,19 @@ namespace MeoAsstGui
{
case "StageDrops":
{
string cur_drops = string.Empty;
JArray drops = (JArray)subTaskDetails["drops"];
foreach (var item in drops)
{
string itemName = item["itemName"].ToString();
int count = (int)item["quantity"];
cur_drops += $"{itemName} : {count}\n";
}
cur_drops = cur_drops.EndsWith("\n") ? cur_drops.TrimEnd('\n') : Localization.GetString("NoDrop");
mainModel.AddLog(Localization.GetString("Drop") + "\n" + cur_drops);
string all_drops = string.Empty;
JArray statistics = (JArray)subTaskDetails["stats"];
foreach (var item in statistics)
{
string itemName = item["itemName"].ToString();
int count = (int)item["quantity"];
all_drops += $"{itemName} : {count}\n";
int totalQuantity = (int)item["totalQuantity"];
int addQuantity = (int)item["addQuantity"];
all_drops += $"{itemName} : {totalQuantity}";
if (addQuantity > 0)
{
all_drops += $" (+{addQuantity})";
}
all_drops += "\n";
}
all_drops = all_drops.EndsWith("\n") ? all_drops.TrimEnd('\n') : Localization.GetString("NoDrop");