feat.增加一个自动抄作业-修改技能用法的字段

This commit is contained in:
MistEO
2022-03-27 23:47:13 +08:00
parent 8562193117
commit d1d29b537a
5 changed files with 54 additions and 23 deletions

View File

@@ -29,7 +29,7 @@
}
},
],
"opers_groups": [
"groups": [
{
"name": "任意正常群奶", // 群组名,必选
// 自己随便取名字,与下面 deploy 中的 name 对应起来就行
@@ -50,9 +50,9 @@
],
"actions": [ // 战斗中的操作。有序,执行完前一个才会去执行下一个。必选
{
"type": "Deploy", // 操作类型,可选,默认 "Deploy"
// "Deploy" | "Skill" | "Retreat" | "SpeedUp" | "BulletTime"
// "部署" | "技能" | "撤退" | "二倍速" | "子弹时间"
"type": "部署", // 操作类型,可选,默认 "Deploy"
// "Deploy" | "Skill" | "Retreat" | "SpeedUp" | "BulletTime" | "SkillUsage"
// "部署" | "技能" | "撤退" | "二倍速" | "子弹时间" | "技能用法"
// 中英文皆可,效果相同
// 若为 "部署", 当费用不够时,会一直等待到费用够(除非 timeout
// 若为 "技能", 当技能 cd 没转好时,一直等待到技能 cd 好(除非 timeout
@@ -68,11 +68,15 @@
"location": [ 5, 5 ], // 部署干员的位置。 type 为 "部署" 时必选
"direction": "Left", // 部署干员的干员朝向。 type 为 "部署" 时必选
"direction": "", // 部署干员的干员朝向。 type 为 "部署" 时必选
// "Left" | "Right" | "Up" | "Down" | "None"
// "左" | "右" | "上" | "下" | "无"
// 中英文皆可,效果相同
"skill_usage": 1, // 修改技能用法。当 type 为 "技能用法" 时必选
// 举例:刚下淘金娘需要她帮忙打几个怪,不能自动开技能,中后期平稳了需要她自动开技能
// 则可以在对应时刻设置为 1
"pre_delay": 0, // 前置延时。可选,默认 0, 单位毫秒
"rear_delay": 0, // 后置延时。可选,默认 0, 单位毫秒

View File

@@ -10,11 +10,6 @@
{
"name": "能天使"
},
{
"name": "桃金娘",
"skill": 1,
"skill_usage": 1
},
{
"name": "澄闪"
},
@@ -22,9 +17,26 @@
"name": "临光"
}
],
"groups": [
{
"name": "投降先锋",
"opers": [
{
"name": "桃金娘",
"skill": 1,
"skill_usage": 1
},
{
"name": "琴柳",
"skill": 1,
"skill_usage": 1
}
]
}
],
"actions": [
{
"name": "桃金娘",
"name": "投降先锋",
"location": [
8,
4

View File

@@ -42,11 +42,12 @@ namespace asst
enum class BattleActionType // 操作类型
{
Deploy = 0, // 部署干员
UseSkill = 1, // 开技能
Retreat = 2, // 撤退干员
SwitchSpeed = 100, // 切换二倍速
BulletTime = 101 // 使用 1/5 的速度(点击任意干员),会在下一个任意操作后恢复原速度
Deploy, // 部署干员
UseSkill, // 开技能
Retreat, // 撤退干员
SkillUsage, // 技能用法
SwitchSpeed, // 切换二倍速
BulletTime // 使用 1/5 的速度(点击任意干员),会在下一个任意操作后恢复原速度
};
struct BattleAction // 操作
@@ -56,6 +57,7 @@ namespace asst
std::string group_name; // 目标名,若 type >= SwitchSpeed, group_name 为空
Point location;
BattleDeployDirection direction = BattleDeployDirection::Right;
BattleSkillUsage modify_usage = BattleSkillUsage::NotUse;
int pre_delay = 0;
int rear_delay = 0;
int time_out = INT_MAX;
@@ -63,7 +65,7 @@ namespace asst
struct BattleActionsGroup
{
std::unordered_map<std::string, std::vector<BattleDeployOper>> opers_groups;
std::unordered_map<std::string, std::vector<BattleDeployOper>> groups;
std::vector<BattleAction> actions;
};

View File

@@ -10,8 +10,8 @@ bool asst::BattleConfiger::parse(const json::value& json)
BattleActionsGroup battle_actions;
if (json.contains("opers_groups")) {
for (const auto& group_info : json.at("opers_groups").as_array()) {
if (json.contains("groups")) {
for (const auto& group_info : json.at("groups").as_array()) {
std::string group_name = group_info.at("name").as_string();
std::vector<BattleDeployOper> oper_vec;
for (const auto& oper_info : group_info.at("opers").as_array()) {
@@ -21,7 +21,7 @@ bool asst::BattleConfiger::parse(const json::value& json)
oper.skill_usage = static_cast<BattleSkillUsage>(oper_info.get("skill_usage", 0));
oper_vec.emplace_back(std::move(oper));
}
battle_actions.opers_groups.emplace(std::move(group_name), std::move(oper_vec));
battle_actions.groups.emplace(std::move(group_name), std::move(oper_vec));
}
}
@@ -35,7 +35,7 @@ bool asst::BattleConfiger::parse(const json::value& json)
// 单个干员的,干员名直接作为组名
std::string group_name = oper.name;
battle_actions.opers_groups.emplace(std::move(group_name), std::vector{ std::move(oper) });
battle_actions.groups.emplace(std::move(group_name), std::vector{ std::move(oper) });
}
}
@@ -68,6 +68,12 @@ bool asst::BattleConfiger::parse(const json::value& json)
{ "Bullettime", BattleActionType::SwitchSpeed },
{ "bullettime", BattleActionType::SwitchSpeed },
{ "子弹时间", BattleActionType::SwitchSpeed },
{ "SkillUsage", BattleActionType::SkillUsage },
{ "SKILLUSAGE", BattleActionType::SkillUsage },
{ "Skillusage", BattleActionType::SkillUsage },
{ "skillusage", BattleActionType::SkillUsage },
{ "技能用法", BattleActionType::SkillUsage },
};
std::string type_str = action_info.get("type", "Deploy");
@@ -121,7 +127,7 @@ bool asst::BattleConfiger::parse(const json::value& json)
else {
action.direction = BattleDeployDirection::Right;
}
action.modify_usage = static_cast<BattleSkillUsage>(action_info.get("skill_usage", 0));
action.pre_delay = action_info.get("pre_delay", 0);
action.rear_delay = action_info.get("rear_delay", 0);
action.time_out = action_info.get("timeout", INT_MAX);

View File

@@ -102,7 +102,7 @@ bool asst::BattleProcessTask::analyze_opers_preview()
opers.at(i).name = oper_name;
// 找出这个干员是哪个组里的,以及他的技能用法等
for (const auto& [group_name, deploy_opers] : m_actions_group.opers_groups) {
for (const auto& [group_name, deploy_opers] : m_actions_group.groups) {
auto iter = std::find_if(deploy_opers.cbegin(), deploy_opers.cend(),
[&](const BattleDeployOper& deploy) -> bool {
return deploy.name == oper_name;
@@ -263,6 +263,13 @@ bool asst::BattleProcessTask::do_action(const BattleAction& action)
break;
case BattleActionType::BulletTime:
break;
case BattleActionType::SkillUsage:
{
auto& oper_info = m_group_to_oper_mapping[action.group_name];
oper_info.skill_usage = action.modify_usage;
m_used_opers[oper_info.name].info.skill_usage = action.modify_usage;
return true;
} break;
}
sleep(action.rear_delay);