mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 02:23:01 +08:00
feat: 合并本次掉落和掉落统计
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user