feat: 优化烧开水逻辑,现在能在低难度烧水,高难度开始 (#6094)

This commit is contained in:
Lancarus
2023-08-28 19:18:55 +08:00
committed by GitHub
parent 9743a1137a
commit 54f6ca91c0
18 changed files with 979 additions and 474 deletions

View File

@@ -500,7 +500,7 @@
{
"name": "前行的林地",
"option_num": 2,
"choose": 2,
"choose": 1,
"choice_require": [
{
"name": "树上就不能走吗?",

File diff suppressed because it is too large Load Diff

View File

@@ -115,6 +115,60 @@
],
"maxTimes": 20
},
"SwipeToTheUp": {
"algorithm": "JustReturn",
"action": "Swipe",
"postDelay": 300,
"specificRect": [
600,
510,
100,
100
],
"rectMove": [
600,
0,
100,
100
],
"specialParams": [
150,
0,
1,
1
],
"next": [
"#next"
],
"maxTimes": 20
},
"SwipeToTheDown": {
"algorithm": "JustReturn",
"action": "Swipe",
"postDelay": 300,
"specificRect": [
600,
145,
100,
100
],
"rectMove": [
600,
610,
100,
100
],
"specialParams": [
150,
0,
1,
1
],
"next": [
"#next"
],
"maxTimes": 20
},
"StageTheme": {
"action": "ClickSelf",
"roi": [
@@ -7752,6 +7806,19 @@
"Roguelike@StartExplore"
]
},
"Roguelike@ChooseDifficultyConfirm": {
"algorithm": "OcrDetect",
"action": "ClickSelf",
"postDelay": 500,
"text": [ "选择" ],
"roi": [
1064,
294,
216,
170
]
},
"Roguelike@ChooseOper": {
"Doc": "本任务注册了插件 RoguelikeRecruitTaskPlugin",
"algorithm": "JustReturn",
@@ -7926,6 +7993,16 @@
160
]
},
"Roguelike@ExitThenAbandon_mode4": {
"action": "ClickSelf",
"cache": false,
"roi": [
0,
0,
320,
160
]
},
"Roguelike@FormationConfirm": {
"action": "ClickSelf",
"roi": [
@@ -9345,6 +9422,18 @@
"Roguelike@StartAction@LoadingIcon"
]
},
"Roguelike@StartExploreConfirm": {
"template": "empty.png",
"action": "ClickSelf",
"cache": false,
"postDelay": 2000,
"roi": [
1064,
294,
216,
170
]
},
"Roguelike@StartExplore": {
"Doc": "base_task",
"template": "empty.png",
@@ -9360,6 +9449,7 @@
"next": [
"Roguelike@SquadDefault",
"Roguelike@InitalDrop",
"Roguelike@ChooseDifficulty",
"Roguelike@StartExplore"
]
},
@@ -9494,6 +9584,13 @@
"Phantom@Roguelike@Abandon"
]
},
"Phantom@Roguelike@ExitThenAbandon_mode4": {
"template": "Roguelike@ExitThenAbandon_mode4.png",
"next": [
"Phantom@Roguelike@ExitThenAbandon",
"Phantom@Roguelike@Abandon"
]
},
"Phantom@Roguelike@GamePass": {},
"Phantom@Roguelike@GamePassSkip1": {},
"Phantom@Roguelike@GamePassSkip1Confirm": {
@@ -9541,7 +9638,7 @@
"故土残躯"
],
"next": [
"Phantom@Roguelike@ExitThenAbandon"
"Phantom@Roguelike@ExitThenAbandon_mode4"
]
},
"Phantom@Roguelike@NextLevel": {
@@ -9663,6 +9760,59 @@
"Phantom@Roguelike@TodoEnter": {},
"Mizuki@Roguelike@Abandon": {},
"Mizuki@Roguelike@ChooseDifficulty": {},
"Mizuki@Roguelike@ChooseDifficulty0": {
"baseTask": "Roguelike@ChooseDifficulty",
"roi": [
1064,
294,
216,
170
],
"next": [
"Roguelike@StartExplore"
]
},
"Mizuki@Roguelike@ChooseDifficultyConfirm": {
"algorithm": "OcrDetect",
"action": "ClickSelf",
"text": [ "选择" ],
"roi": [
1064,
294,
216,
170
]
},
"Mizuki@Roguelike@ChooseDifficulty_Easiest": {
"action": "ClickRect",
"specificRect": [ 1144, 472, 78, 24 ],
"postDelay": 500,
"template": "Mizuki@Roguelike@StartExplore.png",
"roi": [
1026,
470,
254,
248
],
"next": [
"(SwipeToTheUp*5)"
]
},
"Mizuki@Roguelike@ChooseDifficulty_Hardest": {
"action": "ClickRect",
"specificRect": [ 1144, 472, 78, 24 ],
"postDelay": 500,
"template": "Mizuki@Roguelike@StartExplore.png",
"roi": [
1026,
470,
254,
248
],
"next": [
"(SwipeToTheDown*5)"
]
},
"Mizuki@Roguelike@ChooseOper": {
"onErrorNext": [
"Mizuki@Roguelike@RecruitWithoutButton"
@@ -9826,6 +9976,15 @@
"Mizuki@Roguelike@DataTraceback"
]
},
"Mizuki@Roguelike@ExitThenAbandon_mode4": {
"template": "Roguelike@ExitThenAbandon.png",
"next": [
"Mizuki@Roguelike@ExitThenAbandon",
"Mizuki@Roguelike@Abandon",
"Mizuki@Roguelike@DiceConfirmThenAbandon",
"Mizuki@Roguelike@DataTraceback"
]
},
"Mizuki@Roguelike@GamePass": {},
"Mizuki@Roguelike@GamePassSkip1": {},
"Mizuki@Roguelike@GamePassSkip1Confirm": {
@@ -9938,7 +10097,7 @@
"绀碧摇篮"
],
"next": [
"Mizuki@Roguelike@ExitThenAbandon"
"Mizuki@Roguelike@ExitThenAbandon_mode4"
]
},
"Mizuki@Roguelike@NextLevel": {
@@ -10157,9 +10316,49 @@
]
},
"Mizuki@Roguelike@StartExplore": {},
"Mizuki@Roguelike@StartExploreConfirm": {
"template": "Mizuki@Roguelike@StartExplore.png"
},
"Mizuki@Roguelike@TodoEnter": {},
"Sami@Roguelike@Abandon": {},
"Sami@Roguelike@ChooseDifficulty": {},
"Sami@Roguelike@ChooseDifficulty": {
"roi": [
1064,
294,
216,
170
]
},
"Sami@Roguelike@ChooseDifficulty_Easiest": {
"action": "ClickRect",
"specificRect": [ 1119, 479, 80, 22 ],
"postDelay": 500,
"template": "Sami@Roguelike@StartExplore.png",
"roi": [
958,
530,
322,
189
],
"next": [
"(SwipeToTheUp*5)"
]
},
"Sami@Roguelike@ChooseDifficulty_Hardest": {
"action": "ClickRect",
"specificRect": [ 1119, 479, 80, 22 ],
"postDelay": 500,
"template": "Sami@Roguelike@StartExplore.png",
"roi": [
958,
530,
322,
189
],
"next": [
"(SwipeToTheDown*5)"
]
},
"Sami@Roguelike@ChooseOper": {
"onErrorNext": [
"Sami@Roguelike@RecruitWithoutButton"
@@ -10270,6 +10469,13 @@
"Sami@Roguelike@Abandon"
]
},
"Sami@Roguelike@ExitThenAbandon_mode4": {
"template": "Roguelike@ExitThenAbandon_mode4.png",
"next": [
"Sami@Roguelike@ExitThenAbandon",
"Sami@Roguelike@Abandon"
]
},
"Sami@Roguelike@GamePass": {},
"Sami@Roguelike@GamePassSkip1": {},
"Sami@Roguelike@GamePassSkip1Confirm": {
@@ -10371,7 +10577,7 @@
"深埋迷境"
],
"next": [
"Sami@Roguelike@ExitThenAbandon"
"Sami@Roguelike@ExitThenAbandon_mode4"
]
},
"Sami@Roguelike@NextLevel": {
@@ -10388,6 +10594,8 @@
"next": [
"Sami@Roguelike@LevelName",
"Sami@Roguelike@NextLevel",
"Sami@Roguelike@StageBoskyPassage",
"Sami@Roguelike@StageBoskyPassageAI6",
"Sami@Roguelike@StageTrader",
"Sami@Roguelike@StageTraderAI6",
"Sami@Roguelike@StageSafeHouse",
@@ -10396,8 +10604,6 @@
"Sami@Roguelike@StageBoonsAI6",
"Sami@Roguelike@StageEmergencyTransportation",
"Sami@Roguelike@StageEmergencyTransportationAI6",
"Sami@Roguelike@StageBoskyPassage",
"Sami@Roguelike@StageBoskyPassageAI6",
"Sami@Roguelike@StageGambling",
"Sami@Roguelike@StageGamblingAI6",
"Sami@Roguelike@StageProphecy",
@@ -10789,6 +10995,15 @@
"Sami@Roguelike@NextLevel#next"
]
},
"Sami@Roguelike@StartExploreConfirm": {
"template": "Sami@Roguelike@StartExplore.png",
"roi": [
958,
530,
322,
189
]
},
"Sami@Roguelike@StartExplore": {
"roi": [
958,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -77,6 +77,8 @@
<ClInclude Include="Task\BattleHelper.h" />
<ClInclude Include="Task\Interface\SingleStepTask.h" />
<ClInclude Include="Task\Interface\SSSCopilotTask.h" />
<ClInclude Include="Task\Roguelike\RoguelikeDifficultySelectionTaskPlugin.h" />
<ClInclude Include="Task\Roguelike\RoguelikeLastRewardTaskPlugin.h" />
<ClInclude Include="Task\SSS\SSSBattleProcessTask.h" />
<ClInclude Include="Task\SSS\SSSDropRewardsTaskPlugin.h" />
<ClInclude Include="Task\SSS\SSSStageManagerTask.h" />
@@ -231,6 +233,8 @@
<ClCompile Include="Task\BattleHelper.cpp" />
<ClCompile Include="Task\Interface\SingleStepTask.cpp" />
<ClCompile Include="Task\Interface\SSSCopilotTask.cpp" />
<ClCompile Include="Task\Roguelike\RoguelikeDifficultySelectionTaskPlugin.cpp" />
<ClCompile Include="Task\Roguelike\RoguelikeLastRewardTaskPlugin.cpp" />
<ClCompile Include="Task\SSS\SSSBattleProcessTask.cpp" />
<ClCompile Include="Task\SSS\SSSDropRewardsTaskPlugin.cpp" />
<ClCompile Include="Task\SSS\SSSStageManagerTask.cpp" />

View File

@@ -612,6 +612,12 @@
<ClInclude Include="Vision\Config\OCRerConfig.h">
<Filter>源文件\Vision\Config</Filter>
</ClInclude>
<ClInclude Include="Task\Roguelike\RoguelikeDifficultySelectionTaskPlugin.h">
<Filter>源文件\Task\Roguelike</Filter>
</ClInclude>
<ClInclude Include="Task\Roguelike\RoguelikeLastRewardTaskPlugin.h">
<Filter>源文件\Task\Roguelike</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Vision\VisionHelper.cpp">
@@ -1007,5 +1013,11 @@
<ClCompile Include="Vision\Config\OCRerConfig.cpp">
<Filter>源文件\Vision\Config</Filter>
</ClCompile>
<ClCompile Include="Task\Roguelike\RoguelikeDifficultySelectionTaskPlugin.cpp">
<Filter>源文件\Task\Roguelike</Filter>
</ClCompile>
<ClCompile Include="Task\Roguelike\RoguelikeLastRewardTaskPlugin.cpp">
<Filter>源文件\Task\Roguelike</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>

View File

@@ -53,6 +53,7 @@ namespace asst
static inline const std::string RoguelikeRecruitmentTeamComplete = "RoguelikeRecruitmentTeamComplete";
static inline const std::string RoguelikeRecruitmentCount = "RoguelikeRecruitmentCount";
static inline const std::string RoguelikeMode = "RoguelikeMode";
static inline const std::string RoguelikeNeedChangeDifficulty = "RoguelikeNeedChangeDifficulty";
static inline const std::string ProcessTaskLastTimePrefix = "#LastTime#";

View File

@@ -18,6 +18,7 @@ namespace asst
void set_priority(int priority);
void set_block(bool block);
virtual void set_task_ptr(AbstractTask* ptr);
virtual bool verify(AsstMsg msg, const json::value& details) const = 0;

View File

@@ -8,7 +8,9 @@
#include "Task/Roguelike/RoguelikeControlTaskPlugin.h"
#include "Task/Roguelike/RoguelikeCustomStartTaskPlugin.h"
#include "Task/Roguelike/RoguelikeDebugTaskPlugin.h"
#include "Task/Roguelike/RoguelikeDifficultySelectionTaskPlugin.h"
#include "Task/Roguelike/RoguelikeFormationTaskPlugin.h"
#include "Task/Roguelike/RoguelikeLastRewardTaskPlugin.h"
#include "Task/Roguelike/RoguelikeRecruitTaskPlugin.h"
#include "Task/Roguelike/RoguelikeResetTaskPlugin.h"
#include "Task/Roguelike/RoguelikeShoppingTaskPlugin.h"
@@ -26,6 +28,7 @@ asst::RoguelikeTask::RoguelikeTask(const AsstCallback& callback, Assistant* inst
m_roguelike_task_ptr->register_plugin<RoguelikeFormationTaskPlugin>();
m_roguelike_task_ptr->register_plugin<RoguelikeControlTaskPlugin>();
m_roguelike_task_ptr->register_plugin<RoguelikeResetTaskPlugin>();
m_debug_task_ptr = m_roguelike_task_ptr->register_plugin<RoguelikeDebugTaskPlugin>();
m_roguelike_task_ptr->register_plugin<RoguelikeShoppingTaskPlugin>()->set_retry_times(0);
@@ -38,6 +41,9 @@ asst::RoguelikeTask::RoguelikeTask(const AsstCallback& callback, Assistant* inst
m_skill_task_ptr->set_retry_times(2).set_ignore_error(true);
m_roguelike_task_ptr->register_plugin<RoguelikeStageEncounterTaskPlugin>()->set_retry_times(0);
m_roguelike_task_ptr->register_plugin<RoguelikeLastRewardTaskPlugin>();
m_roguelike_task_ptr->register_plugin<RoguelikeDifficultySelectionTaskPlugin>();
// 这个任务如果卡住会放弃当前的肉鸽并重新开始,所以多添加一点。先这样凑合用
for (int i = 0; i != 100; ++i) {
m_subtasks.emplace_back(m_roguelike_task_ptr);
@@ -69,6 +75,7 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
// 4 - 刷开局藏品,以获得热水壶或者演讲稿开局,不期而遇采用保守策略
int mode = params.get("mode", 0);
status()->set_properties(Status::RoguelikeMode, std::to_string(mode));
status()->set_properties(Status::RoguelikeNeedChangeDifficulty, "0");
switch (mode) {
case 0:
m_debug_task_ptr->set_enable(true);
@@ -90,22 +97,35 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
}
if (mode == 4) {
// 设置ocr第三层层名设置识别到退出重进
Task.get<OcrTaskInfo>(theme + "@Roguelike@LevelName")->text =
Task.get<OcrTaskInfo>(theme + "@Roguelike@LevelName_mode4")->text;
Task.get(theme + "@Roguelike@LevelName")->next = Task.get(theme + "@Roguelike@LevelName_mode4")->next;
// 获得热水壶和演讲时长延时
Task.get(theme + "@Roguelike@LastReward")->post_delay =
Task.get(theme + "@Roguelike@LastReward_mode4")->post_delay;
Task.get(theme + "@Roguelike@LastReward4")->post_delay =
Task.get(theme + "@Roguelike@LastReward_mode4")->post_delay;
// 获得其他奖励时重开
Task.get(theme + "@Roguelike@LastReward2")->next = Task.get(theme + "@Roguelike@LastReward_mode4")->next;
Task.get(theme + "@Roguelike@LastReward3")->next = Task.get(theme + "@Roguelike@LastReward_mode4")->next;
Task.get(theme + "@Roguelike@LastRewardRand")->next = Task.get(theme + "@Roguelike@LastReward_mode4")->next;
}
else {
// 重置需要ocr的层名和next任务
Task.get<OcrTaskInfo>(theme + "@Roguelike@LevelName")->text =
Task.get<OcrTaskInfo>(theme + "@Roguelike@LevelName_normal_mode")->text;
Task.get(theme + "@Roguelike@LevelName")->next = Task.get(theme + "@Roguelike@LevelName_normal_mode")->next;
// 重置获得热水壶和演讲延时
Task.get(theme + "@Roguelike@LastReward")->post_delay =
Task.get(theme + "@Roguelike@LastReward_normal_mode")->post_delay;
Task.get(theme + "@Roguelike@LastReward4")->post_delay =
Task.get(theme + "@Roguelike@LastReward_normal_mode")->post_delay;
// 重置其他奖励next
Task.get(theme + "@Roguelike@LastReward2")->next = Task.get(theme + "@Roguelike@LastReward_normal_mode")->next;
Task.get(theme + "@Roguelike@LastReward3")->next = Task.get(theme + "@Roguelike@LastReward_normal_mode")->next;
Task.get(theme + "@Roguelike@LastRewardRand")->next =
Task.get(theme + "@Roguelike@LastReward_normal_mode")->next;
}
int number_of_starts = params.get("starts_count", INT_MAX);
m_roguelike_task_ptr->set_times_limit(theme + "@Roguelike@StartExplore", number_of_starts);

View File

@@ -9,6 +9,8 @@ namespace asst
class RoguelikeBattleTaskPlugin;
class RoguelikeCustomStartTaskPlugin;
class RoguelikeDebugTaskPlugin;
class RoguelikeLastRewardTaskPlugin;
class RoguelikeDifficultySelectionTaskPlugin;
class RoguelikeTask : public InterfaceTask
{

View File

@@ -0,0 +1,55 @@
#include "RoguelikeDifficultySelectionTaskPlugin.h"
#include "Status.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
bool asst::RoguelikeDifficultySelectionTaskPlugin::verify(AsstMsg msg, const json::value& details) const
{
if (msg != AsstMsg::SubTaskStart || details.get("subtask", std::string()) != "ProcessTask") {
return false;
}
auto roguelike_name_opt = status()->get_properties(Status::RoguelikeTheme);
if (!roguelike_name_opt) {
Log.error("Roguelike name doesn't exist!");
return false;
}
const std::string roguelike_name = std::move(roguelike_name_opt.value()) + "@";
const std::string& task = details.get("details", "task", "");
std::string_view task_view = task;
if (task_view.starts_with(roguelike_name)) {
task_view.remove_prefix(roguelike_name.length());
}
if (task_view == "Roguelike@StartExplore") {
return true;
}
else {
return false;
}
}
bool asst::RoguelikeDifficultySelectionTaskPlugin::_run()
{
LogTraceFunction;
std::string theme = status()->get_properties(Status::RoguelikeTheme).value();
std::string mode = status()->get_properties(Status::RoguelikeMode).value();
// todo:以后可以根据传入的难度值选择难度?
std::string change_difficulty = status()->get_properties(Status::RoguelikeNeedChangeDifficulty).value();
if (theme != "Phantom" && mode == "4") {
if (change_difficulty == "max") {
// 到第三层退出,选最高难度开水壶
ProcessTask(*this, { theme + "@Roguelike@ChooseDifficulty_Hardest" }).run();
}
// 其他情况下开始,选最低难度
else {
ProcessTask(*this, { theme + "@Roguelike@ChooseDifficulty_Easiest" }).run();
}
status()->set_properties(Status::RoguelikeNeedChangeDifficulty, "0");
ProcessTask(*this, { theme + "@Roguelike@ChooseDifficultyConfirm" }).run();
ProcessTask(*this, { theme + "@Roguelike@StartExploreConfirm" }).run();
}
return true;
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include "Task/AbstractTaskPlugin.h"
namespace asst
{
class RoguelikeDifficultySelectionTaskPlugin : public AbstractTaskPlugin
{
public:
using AbstractTaskPlugin::AbstractTaskPlugin;
virtual ~RoguelikeDifficultySelectionTaskPlugin() override = default;
public:
virtual bool verify(AsstMsg msg, const json::value& details) const override;
protected:
virtual bool _run() override;
};
}

View File

@@ -0,0 +1,43 @@
#include "RoguelikeLastRewardTaskPlugin.h"
#include "Status.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
bool asst::RoguelikeLastRewardTaskPlugin::verify(AsstMsg msg, const json::value& details) const
{
if (msg != AsstMsg::SubTaskStart || details.get("subtask", std::string()) != "ProcessTask") {
return false;
}
auto roguelike_name_opt = status()->get_properties(Status::RoguelikeTheme);
if (!roguelike_name_opt) {
Log.error("Roguelike name doesn't exist!");
return false;
}
const std::string roguelike_name = std::move(roguelike_name_opt.value()) + "@";
const std::string& task = details.get("details", "task", "");
std::string_view task_view = task;
if (task_view.starts_with(roguelike_name)) {
task_view.remove_prefix(roguelike_name.length());
}
if (task_view == "Roguelike@ExitThenAbandon_mode4") {
return true;
}
else {
return false;
}
}
bool asst::RoguelikeLastRewardTaskPlugin::_run()
{
LogTraceFunction;
std::string theme = status()->get_properties(Status::RoguelikeTheme).value();
std::string mode = status()->get_properties(Status::RoguelikeMode).value();
if (theme != "Phantom" && mode == "4") {
status()->set_properties(Status::RoguelikeNeedChangeDifficulty, "max");
}
return true;
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include "Task/AbstractTaskPlugin.h"
namespace asst
{
class RoguelikeLastRewardTaskPlugin : public AbstractTaskPlugin
{
public:
using AbstractTaskPlugin::AbstractTaskPlugin;
virtual ~RoguelikeLastRewardTaskPlugin() override = default;
public:
virtual bool verify(AsstMsg msg, const json::value& details) const override;
protected:
virtual bool _run() override;
};
}

View File

@@ -133,7 +133,7 @@ bool asst::RoguelikeShoppingTaskPlugin::_run()
continue;
}
}
if (goods.promotion != 0) {
if (total_wait_promotion == 0) {
Log.trace("Ready to buy", goods.name, ", but there is no one waiting for promotion, skip");