改为josn object[]传输

This commit is contained in:
罗家欣
2023-04-20 21:44:24 +08:00
parent 4b2557782e
commit 54b87d33f1
4 changed files with 36 additions and 24 deletions

View File

@@ -9629,7 +9629,8 @@
],
"next": [
"OperBoxRoleTab"
]
],
"maxTimes": 3
},
"OperBoxRoleTab": {
"action": "DoNothing",

View File

@@ -59,19 +59,18 @@ void asst::OperBoxRecognitionTask::callback_analyze_result(bool done)
// 获取识别干员名
const auto own_oper_names = get_own_oper_names();
// 未拥有干员名
std::unordered_set<std::string> n_own_oper_names;
n_own_oper_names.clear();
for (const auto& oper : all_oper_names) {
if (own_oper_names.find(oper) == own_oper_names.end()) n_own_oper_names.insert(oper);
}
json::value info = basic_info_with_what("OperInfo");
auto& details = info["details"];
details["done"] = done;
details["have"] = json::array(own_oper_names);
details["nhave"] = json::array(n_own_oper_names);
details["all"] = json::array(all_oper_names);
auto& box_oper = details["operbox"];
for (const auto& name : all_oper_names) {
box_oper.array_emplace(json::object {
{ "id", BattleData.get_id(name) },
{ "name", name },
{ "own", (own_oper_names.find(name) != own_oper_names.end()) }
});
}
callback(AsstMsg::SubTaskExtraInfo, info);
}

View File

@@ -10,6 +10,7 @@ namespace asst
std::string id;
int level = 0; //等级
int elite = 0; //精英度
bool own = false;
};
class OperBoxImageAnalyzer final : public AbstractImageAnalyzer
{

View File

@@ -375,37 +375,48 @@ namespace MaaWpfGui.ViewModels.UI
public bool OperBoxParse(JObject details)
{
string result = string.Empty;
/*已拥有干员*/
JArray operOwn = (JArray)details["have"];
/*未拥有干员,包含预备干员等*/
JArray operNotOwn = (JArray)details["nhave"];
/*移除未实装干员*/
foreach (var name in VirtuallyOpers)
JArray operBoxs = (JArray)details["operbox"];
List<string> operHave = new List<string>();
List<string> operNotHave = new List<string>();
foreach (JObject operBox in operBoxs.Cast<JObject>())
{
operNotOwn.Where(i => i.Type == JTokenType.String && (string)i == name).ToList().ForEach(i => i.Remove());
if ((bool)operBox["own"])
{
/*已拥有干员*/
operHave.Add((string)operBox["name"]);
}
else
{
/*未拥有干员,包含预备干员等*/
operNotHave.Add((string)operBox["name"]);
}
}
result = "已拥有:" + operOwn.Count.ToString() + "名,未拥有:" + operNotOwn.Count.ToString() + "名;" + "\n\n";
/*移除未实装干员*/
operNotHave = operNotHave.Except(second: VirtuallyOpers).ToList();
result = "已拥有:" + operHave.Count.ToString() + "名,未拥有:" + operNotHave.Count.ToString() + "名;" + "\n\n";
result += "以下干员未拥有:\n\t";
int count = 0;
foreach (var name in operNotOwn)
foreach (var name in operNotHave)
{
result += name + "\t";
if (count++ == 3)
{
result += "\n";
count= 0;
result += "\n\t";
count = 0;
}
}
result += "\n\n以下干员已拥有\n\n\t";
count = 0;
foreach (var name in operOwn)
foreach (var name in operHave)
{
result += name + "\t";
if (count++ == 3)
{
result += "\n";
result += "\n\t";
count = 0;
}
}