From 95300cae4e242670fa7405d4e91bfb2d7f41b4e9 Mon Sep 17 00:00:00 2001 From: DavidWang19 Date: Wed, 5 Oct 2022 17:17:32 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E8=AF=86=E5=88=AB=E5=8C=BB=E7=96=97=E5=B9=B2?= =?UTF-8?q?=E5=91=98=E6=94=BB=E5=87=BB=E8=8C=83=E5=9B=B4=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Task/Plugin/RoguelikeBattleTaskPlugin.cpp | 93 ++++++++++--------- .../Task/Plugin/RoguelikeBattleTaskPlugin.h | 1 + 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/MeoAssistant/Task/Plugin/RoguelikeBattleTaskPlugin.cpp b/src/MeoAssistant/Task/Plugin/RoguelikeBattleTaskPlugin.cpp index adbfdf4c92..110ee87a46 100644 --- a/src/MeoAssistant/Task/Plugin/RoguelikeBattleTaskPlugin.cpp +++ b/src/MeoAssistant/Task/Plugin/RoguelikeBattleTaskPlugin.cpp @@ -743,6 +743,52 @@ std::vector asst::RoguelikeBattleTaskPlugin::available_locations(Ba return result; } +asst::BattleAttackRange asst::RoguelikeBattleTaskPlugin::get_attack_range(const BattleRealTimeOper& oper) +{ + int64_t elite = m_status->get_number(RuntimeStatus::RoguelikeCharElitePrefix + oper.name).value_or(0); + BattleAttackRange right_attack_range = BattleData.get_range(oper.name, elite); + + if (right_attack_range == BattleDataConfiger::EmptyRange) { + switch (oper.role) { + case BattleRole::Support: + right_attack_range = { + Point(-1, -1), Point(0, -1), Point(1, -1), Point(2, -1), // + Point(-1, 0), Point(0, 0), Point(1, 0), Point(2, 0), // + Point(-1, 1), Point(0, 1), Point(1, 1), Point(2, 1), // + }; + break; + case BattleRole::Caster: + right_attack_range = { + Point(0, -1), Point(1, -1), Point(2, -1), // + Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0), // + Point(0, 1), Point(1, 1), Point(2, 1), // + }; + break; + case BattleRole::Medic: + case BattleRole::Sniper: + right_attack_range = { + Point(0, -1), Point(1, -1), Point(2, -1), Point(3, -1), // + Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0), // + Point(0, 1), Point(1, 1), Point(2, 1), Point(3, 1), // + }; + break; + case BattleRole::Warrior: + right_attack_range = { Point(0, 0), Point(1, 0), Point(2, 0) }; + break; + case BattleRole::Special: + case BattleRole::Tank: + case BattleRole::Pioneer: + case BattleRole::Drone: + right_attack_range = { Point(0, 0), Point(1, 0) }; + break; + default: + break; + } + } + + return right_attack_range; +} + asst::RoguelikeBattleTaskPlugin::DeployInfo asst::RoguelikeBattleTaskPlugin::calc_best_plan( const BattleRealTimeOper& oper) { @@ -809,11 +855,7 @@ asst::RoguelikeBattleTaskPlugin::DeployInfo asst::RoguelikeBattleTaskPlugin::cal // 如果是医疗干员,判断覆盖范围内有无第一次放置的干员 if (oper.role == BattleRole::Medic) { - BattleAttackRange right_attack_range = { - Point(0, -1), Point(1, -1), Point(2, -1), Point(3, -1), // - Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0), // - Point(0, 1), Point(1, 1), Point(2, 1), Point(3, 1), // - }; + BattleAttackRange right_attack_range = get_attack_range(oper); for (const Point& direction : { Point::right(), Point::up(), Point::left(), Point::down() }) { if (direction == best_direction) break; for (Point& point : right_attack_range) @@ -868,47 +910,8 @@ std::pair asst::RoguelikeBattleTaskPlugin::calc_best_direction base_direction = -base_direction; } - int64_t elite = m_status->get_number(RuntimeStatus::RoguelikeCharElitePrefix + oper.name).value_or(0); // 按朝右算,后面根据方向做转换 - BattleAttackRange right_attack_range = BattleData.get_range(oper.name, elite); - - if (right_attack_range == BattleDataConfiger::EmptyRange) { - switch (oper.role) { - case BattleRole::Support: - right_attack_range = { - Point(-1, -1), Point(0, -1), Point(1, -1), Point(2, -1), // - Point(-1, 0), Point(0, 0), Point(1, 0), Point(2, 0), // - Point(-1, 1), Point(0, 1), Point(1, 1), Point(2, 1), // - }; - break; - case BattleRole::Caster: - right_attack_range = { - Point(0, -1), Point(1, -1), Point(2, -1), // - Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0), // - Point(0, 1), Point(1, 1), Point(2, 1), // - }; - break; - case BattleRole::Medic: - case BattleRole::Sniper: - right_attack_range = { - Point(0, -1), Point(1, -1), Point(2, -1), Point(3, -1), // - Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0), // - Point(0, 1), Point(1, 1), Point(2, 1), Point(3, 1), // - }; - break; - case BattleRole::Warrior: - right_attack_range = { Point(0, 0), Point(1, 0), Point(2, 0) }; - break; - case BattleRole::Special: - case BattleRole::Tank: - case BattleRole::Pioneer: - case BattleRole::Drone: - right_attack_range = { Point(0, 0), Point(1, 0) }; - break; - default: - break; - } - } + BattleAttackRange right_attack_range = get_attack_range(oper); int max_score = 0; Point opt_direction; diff --git a/src/MeoAssistant/Task/Plugin/RoguelikeBattleTaskPlugin.h b/src/MeoAssistant/Task/Plugin/RoguelikeBattleTaskPlugin.h index f723072670..b8551a7dcc 100644 --- a/src/MeoAssistant/Task/Plugin/RoguelikeBattleTaskPlugin.h +++ b/src/MeoAssistant/Task/Plugin/RoguelikeBattleTaskPlugin.h @@ -49,6 +49,7 @@ namespace asst Point placed; Point direction; }; + BattleAttackRange get_attack_range(const BattleRealTimeOper& oper); DeployInfo calc_best_plan(const BattleRealTimeOper& oper); // 计算摆放干员的朝向