diff --git a/docs/战斗流程协议.md b/docs/战斗流程协议.md index 75b8e21c39..83277980f7 100644 --- a/docs/战斗流程协议.md +++ b/docs/战斗流程协议.md @@ -13,12 +13,20 @@ "skill": 3, // 技能序号。可选,默认 1,取值范围 [1, 3] - "skill_usage": 0 // 技能用法。可选,默认 0 + "skill_usage": 0, // 技能用法。可选,默认 -1 + // -1 - 不自动使用(依赖 "actions" 字段) // 0 - 好了就用,有多少次用多少次(例如干员 棘刺 3 技能、桃金娘 1 技能等) // 1 - 好了就用,仅使用一次(例如干员 山 2 技能) // 2 - 自动判断使用时机(画饼.jpg) - // 3 - 不自动使用(依赖 "actions" 字段) - // 如果是全自动的技能,随便填哪个都一样,也可以不填 + // 如果是全自动的技能,填 -1 + + "requirements": { // 练度要求。可选,默认为空 + "elite": 2, // 精英化等级。可选,默认为 0, 不要求精英化等级 + "level": 90, // 干员等级。可选,默认为 0 + "skill_level": 10, // 技能等级。可选,默认为 0 + "module": 1, // 模组编号。可选,默认为 0 + "potentiality": 1 // 潜能要求。可选,默认为 0 + } }, ], "opers_groups": [ @@ -86,8 +94,7 @@ "desc": { // 描述,可选,保留字段。 // 后期完成了作业分享平台后,可能直接展示该字段给其他用户看 "title": "低练度高成功率作业", - "details": "对练度要求很低balabala……", - "requirements": "棘刺精二、任意群奶、……" + "details": "对练度要求很低balabala……" }, } ``` diff --git a/resource/battle/GA-EX8-raid.json b/resource/battle/GA-EX8-raid.json index be5f155676..95ec1a5571 100644 --- a/resource/battle/GA-EX8-raid.json +++ b/resource/battle/GA-EX8-raid.json @@ -2,22 +2,25 @@ "minimum_required": "v4.0", "desc": { "title": "《AI 都比我打得好》", - "details": "https://www.bilibili.com/video/BV1zS4y1U76j", - "requirements": "" + "details": "作业抄自 https://www.bilibili.com/video/BV1zS4y1U76j" }, "stage_name": "千层蛋糕", "opers": [ { - "name": "银灰" + "name": "银灰", + "skill": 3 }, { - "name": "凯尔希" + "name": "凯尔希", + "skill": 3 }, { - "name": "史尔特尔" + "name": "史尔特尔", + "skill": 3 }, { - "name": "泥岩" + "name": "泥岩", + "skill": 2 } ], "actions": [ diff --git a/src/MeoAssistant/AsstBattleDef.h b/src/MeoAssistant/AsstBattleDef.h index 1d88e3706f..fe3aca7f2a 100644 --- a/src/MeoAssistant/AsstBattleDef.h +++ b/src/MeoAssistant/AsstBattleDef.h @@ -12,17 +12,17 @@ namespace asst { enum class BattleSkillUsage // 干员技能使用方法 { + NotUse = -1, // 不自动使用 Possibly = 0, // 有就用,例如干员 棘刺 3 技能 Once = 1, // 只用一次,例如干员 银灰 2技能 InTime = 2, // 关键时刻使用,自动判断使用时机,例如干员 假日威龙陈 3 技能 - NotUse = 3, // 不自动使用 OnceUsed }; struct BattleDeployOper // 干员 { std::string name; int skill = 1; // 技能序号,取值范围 [1, 3] - BattleSkillUsage skill_usage = BattleSkillUsage::Possibly; + BattleSkillUsage skill_usage = BattleSkillUsage::NotUse; }; enum class BattleDeployDirection diff --git a/src/MeoAssistant/BattleConfiger.cpp b/src/MeoAssistant/BattleConfiger.cpp index 6f5183b527..16c2dcc67a 100644 --- a/src/MeoAssistant/BattleConfiger.cpp +++ b/src/MeoAssistant/BattleConfiger.cpp @@ -18,7 +18,7 @@ bool asst::BattleConfiger::parse(const json::value& json) BattleDeployOper oper; oper.name = oper_info.at("name").as_string(); oper.skill = oper_info.get("skill", 1); - oper.skill_usage = static_cast(oper_info.get("skill_usage", 0)); + oper.skill_usage = static_cast(oper_info.get("skill_usage", -1)); oper_vec.emplace_back(std::move(oper)); } battle_actions.opers_groups.emplace(std::move(group_name), std::move(oper_vec)); @@ -30,7 +30,7 @@ bool asst::BattleConfiger::parse(const json::value& json) BattleDeployOper oper; oper.name = oper_info.at("name").as_string(); oper.skill = oper_info.get("skill", 1); - oper.skill_usage = static_cast(oper_info.get("skill_usage", 0)); + oper.skill_usage = static_cast(oper_info.get("skill_usage", -1)); // 单个干员的,干员名直接作为组名 std::string group_name = oper.name; diff --git a/src/MeoAssistant/BattleProcessTask.cpp b/src/MeoAssistant/BattleProcessTask.cpp index 21b3cf9c8e..dcc57721c0 100644 --- a/src/MeoAssistant/BattleProcessTask.cpp +++ b/src/MeoAssistant/BattleProcessTask.cpp @@ -28,7 +28,7 @@ bool asst::BattleProcessTask::_run() ; } - for (const auto& action : m_actions.actions) { + for (const auto& action : m_actions_group.actions) { do_action(action); } @@ -60,7 +60,7 @@ bool asst::BattleProcessTask::get_stage_info() return false; } - m_actions = battle.get_actions(m_stage_name); + m_actions_group = battle.get_actions(m_stage_name); return true; } @@ -75,6 +75,7 @@ bool asst::BattleProcessTask::analyze_opers_preview() // TODO: 干员头像出来之后,还要过 2 秒左右才可以点击,这里可能还要加个延时 battle_pause(); + auto opers = oper_analyzer.get_opers(); for (size_t i = 0; i != opers.size(); ++i) { @@ -100,6 +101,21 @@ bool asst::BattleProcessTask::analyze_opers_preview() } opers.at(i).name = oper_name; + // 找出这个干员是哪个组里的,以及他的技能用法等 + for (const auto& [group_name, deploy_opers] : m_actions_group.opers_groups) { + auto iter = std::find_if(deploy_opers.cbegin(), deploy_opers.cend(), + [&](const BattleDeployOper& deploy) -> bool { + return deploy.name == oper_name; + }); + // 没找到,可能是召唤物等新出现的;可能是干员名识别错了(这种情况处理不了,不管了) + if (iter == deploy_opers.cend()) { + m_group_to_oper_mapping.emplace(group_name, BattleDeployOper{ group_name }); + } + else { + m_group_to_oper_mapping.emplace(group_name, *iter); + } + } + m_cur_opers_info.emplace(std::move(oper_name), std::move(opers.at(i))); // 干员特别多的时候,任意干员被点开,都会导致下方的干员图标被裁剪和移动。所以这里需要重新识别一下 @@ -205,6 +221,7 @@ bool asst::BattleProcessTask::update_opers_info() name_analyzer.sort_result_by_score(); oper_name = name_analyzer.get_result().front().text; } + m_group_to_oper_mapping[oper_name] = BattleDeployOper{ oper_name }; battle_pause(); cancel_selection(); } @@ -277,10 +294,10 @@ bool asst::BattleProcessTask::oper_deploy(const BattleAction& action) do { update_opers_info(); - // TODO,临时调试方案。正式版本这里需要对 group_name -> oper_name 做一个转换 - iter = m_cur_opers_info.find(action.group_name); + const std::string& name = m_group_to_oper_mapping[action.group_name].name; + iter = m_cur_opers_info.find(name); if (iter == m_cur_opers_info.cend()) { - Log.info("battle opers group", action.group_name, "not found"); + Log.info("battle opers group", name, "not found"); } } while (iter == m_cur_opers_info.cend() || !iter->second.available); @@ -335,9 +352,10 @@ bool asst::BattleProcessTask::oper_deploy(const BattleAction& action) bool asst::BattleProcessTask::oper_retreat(const BattleAction& action) { - auto iter = m_used_opers_loc.find(action.group_name); + const std::string& name = m_group_to_oper_mapping[action.group_name].name; + auto iter = m_used_opers_loc.find(name); if (iter == m_used_opers_loc.cend()) { - Log.error(action.group_name, " not used"); + Log.error(name, " not used"); return false; } Point pos = m_normal_tile_info[iter->second].pos; @@ -348,9 +366,10 @@ bool asst::BattleProcessTask::oper_retreat(const BattleAction& action) bool asst::BattleProcessTask::use_skill(const BattleAction& action) { - auto iter = m_used_opers_loc.find(action.group_name); + const std::string& name = m_group_to_oper_mapping[action.group_name].name; + auto iter = m_used_opers_loc.find(name); if (iter == m_used_opers_loc.cend()) { - Log.error(action.group_name, " not used"); + Log.error(name, " not used"); return false; } diff --git a/src/MeoAssistant/BattleProcessTask.h b/src/MeoAssistant/BattleProcessTask.h index e6c6ae9940..d3f209d691 100644 --- a/src/MeoAssistant/BattleProcessTask.h +++ b/src/MeoAssistant/BattleProcessTask.h @@ -37,7 +37,8 @@ namespace asst std::unordered_map m_side_tile_info; std::unordered_map m_normal_tile_info; - BattleActionsGroup m_actions; + BattleActionsGroup m_actions_group; + std::unordered_map m_group_to_oper_mapping; /* 实时更新的数据 */ int m_kills = 0;