feat(MaaCore): Copilot支持切换技能用法使用坐标 (#14818)

* feat: 支持切换技能用法使用坐标

* chore: Auto update by pre-commit hooks [skip changelog]

* fix: usage

* fix: const ref

* perf: capture

* fix: case define

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Status102
2025-11-23 15:55:13 +08:00
committed by GitHub
parent 6d1e3ca757
commit 1ad7b3a6a0
3 changed files with 41 additions and 13 deletions

View File

@@ -247,13 +247,36 @@ bool asst::BattleProcessTask::do_action(const battle::copilot::Action& action, s
}
break;
case ActionType::SkillUsage:
m_skill_usage[name] = action.modify_usage;
if (action.modify_usage == SkillUsage::Times) {
m_skill_times[name] = action.modify_times;
{
case ActionType::SkillUsage:
const auto set_usage = [this](const std::string& name, SkillUsage usage, int times) {
m_skill_usage[name] = usage;
if (usage == SkillUsage::Times) {
m_skill_times[name] = times;
}
};
if (!location.empty()) {
std::string drone_name;
if (!name.empty()) {
LogWarn << "Both name and location are set for SkillUsage action. Skip this step.";
break;
}
if (auto it = m_used_tiles.find(location); it == m_used_tiles.end()) {
LogInfo << "Tile hasn't used, register for drone" << location;
drone_name = std::format("drone_{}_{}", location.x, location.y);
register_deployed_oper(drone_name, location);
}
else {
drone_name = it->second;
}
set_usage(drone_name, action.modify_usage, action.modify_times);
}
else {
set_usage(name, action.modify_usage, action.modify_times);
}
ret = true;
break;
}
ret = true;
break;
case ActionType::Output:
// DoNothing