mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
fix: 使用理智药后状态未能更新
This commit is contained in:
@@ -16,7 +16,7 @@ bool asst::FightTimesTaskPlugin::verify(AsstMsg msg, const json::value& details)
|
||||
}
|
||||
|
||||
const std::string task = details.get("details", "task", "");
|
||||
if (task.ends_with("MedicineConfirm") || task.ends_with("StoneConfirm")) {
|
||||
if (/* task.ends_with("MedicineConfirm") 走插件调用 */ task.ends_with("StoneConfirm")) {
|
||||
m_has_used_medicine = true;
|
||||
}
|
||||
else if (task.ends_with("StartButton2")) {
|
||||
@@ -134,22 +134,25 @@ std::optional<int> asst::FightTimesTaskPlugin::change_series(int sanity_current,
|
||||
int fight_times_remain = std::min(m_fight_times_max - m_fight_times, 6);
|
||||
if (!m_has_used_medicine && !m_is_medicine_exhausted) {
|
||||
if (fight_times_remain != series) {
|
||||
// 调整到剩余次数
|
||||
return select_series(false);
|
||||
return select_series(false); // 调整到剩余次数
|
||||
}
|
||||
return series;
|
||||
}
|
||||
|
||||
// 用过药品, 认为已选择最大可用次数
|
||||
if (m_has_used_medicine && sanity_cost <= sanity_current) { // 吃药前一般选择最大可用次数, 吃完药已经够理智了
|
||||
if (m_has_used_medicine) { // 用过药品, 认为已选择最大可用次数
|
||||
if (sanity_cost <= sanity_current) { // 吃药前一般选择最大可用次数, 吃完药已经够理智了
|
||||
return series;
|
||||
}
|
||||
// 吃药后理智超限, 减少了吃药量, 选择剩余次数
|
||||
}
|
||||
|
||||
auto ret = select_series(true);
|
||||
if (!ret && m_is_medicine_exhausted) { // 药品用完, 且没有次数可用, 刷理智结束
|
||||
m_task_ptr->set_enable(false);
|
||||
}
|
||||
|
||||
else if (!ret) {
|
||||
ret = select_series(1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
|
||||
void finish_fight() { m_fight_times += m_series_current; }
|
||||
|
||||
void set_has_used_medicine() { m_has_used_medicine = true; }
|
||||
|
||||
// 获取 当前理智/最大理智
|
||||
static std::optional<asst::SanityResult> analyze_sanity_remain(const cv::Mat& image);
|
||||
// 获取 连战次数
|
||||
@@ -56,8 +58,9 @@ protected:
|
||||
private:
|
||||
bool open_series_list(const cv::Mat& image = cv::Mat());
|
||||
void close_series_list(const cv::Mat& image = cv::Mat());
|
||||
// 计算并调整连续战斗次数, 返回是否修改了次数
|
||||
// 计算并调整连续战斗次数; 返回是否修改了次数
|
||||
std::optional<int> change_series(int sanity_remain, int sanity_cost, int series);
|
||||
// 选择连战次数, available_only: 是否选择当前可用的次数; 返回调整到的次数
|
||||
std::optional<int> select_series(bool available_only);
|
||||
bool select_series(int times);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Controller/Controller.h"
|
||||
#include "InstHelper.h"
|
||||
#include "Task/Fight/DrGrandetTaskPlugin.h"
|
||||
#include "Task/Fight/FightTimesTaskPlugin.h"
|
||||
#include "Task/ProcessTask.h"
|
||||
#include "Utils/Logger.hpp"
|
||||
#include "Utils/NoWarningCV.h"
|
||||
@@ -125,14 +126,20 @@ bool asst::MedicineCounterTaskPlugin::_run()
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (auto ptr = m_task_ptr->find_plugin<FightTimesTaskPlugin>()) {
|
||||
ptr->set_has_used_medicine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ProcessTask(*this, { "MedicineConfirm" }).set_retry_times(5).run()) {
|
||||
Log.error(__FUNCTION__, "unable to run medicine confirm");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto ptr = m_task_ptr->find_plugin<FightTimesTaskPlugin>()) {
|
||||
ptr->set_has_used_medicine();
|
||||
}
|
||||
auto info = basic_info_with_what("UseMedicine");
|
||||
info["details"]["is_expiring"] = m_used_count > m_max_count;
|
||||
info["details"]["count"] = using_medicine->using_count;
|
||||
|
||||
Reference in New Issue
Block a user