1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 06:39:25 +08:00

add: keep 1 level white flagship when auto retire

This commit is contained in:
0O0o0oOoO00
2026-03-20 22:50:36 +08:00
parent 289652382a
commit b777b9656d
15 changed files with 77 additions and 0 deletions

View File

@@ -361,6 +361,10 @@ void Cracker::disable_skip_enter_battle() {
restore_combat_delay_active();
}
void Cracker::set_white_flagship_keep_count(int ships) {
m_keep_white_flagship_number.store(ships);
}
void Cracker::enable_auto_retire() {
ENABLE(AUTO_RETIRE);
}
@@ -1750,6 +1754,13 @@ Lua::Table Cracker::filter_ship(sol::this_state& l, Lua::VariadicArgs& args) {
}
});
int white_flagship_to_keep = 0;
int keep_white_flagship_number = m_keep_white_flagship_number.load();
auto is_white_flagship = [](int configId) {
return configId == 107041 || configId == 106021 || configId == 107011 || configId == 206011;
};
auto filter = [&](sol::this_state, Lua::Object value) {
Lua::Table ship = value;
@@ -1787,6 +1798,19 @@ Lua::Table Cracker::filter_ship(sol::this_state& l, Lua::VariadicArgs& args) {
return false;
}
}
if (keep_white_flagship_number != 0) {
if (is_white_flagship(configId)) {
int level = ship["level"];
if (level == 1) {
if (white_flagship_to_keep < keep_white_flagship_number) {
white_flagship_to_keep++;
return false;
}
}
}
}
return true;
};
@@ -1938,6 +1962,7 @@ Cracker::Config Cracker::get_config() {
.exercise_more_power_rate = static_cast<int>(m_exercise_more_power_rate.load() * 100),
.better_global_speedup_rate = static_cast<int>(m_better_global_speedup_rate.load()),
.chapter_auto_clear_step_interval = m_mover.interval.load(),
.white_flagship_keep_count = m_keep_white_flagship_number.load(),
};
return config;
}
@@ -1964,6 +1989,7 @@ void Cracker::apply_config(Config& config) {
}
if(IS_CONFIG_ENABLED(AUTO_RETIRE)) {
set_white_flagship_keep_count(config.white_flagship_keep_count);
enable_auto_retire();
} else {
disable_auto_retire();

View File

@@ -130,6 +130,7 @@ public:
int exercise_more_power_rate = 1;
int better_global_speedup_rate = 1;
double chapter_auto_clear_step_interval = 0.5;
int white_flagship_keep_count = 0;
};
public:
@@ -169,6 +170,7 @@ public:
void enable_skip_enter_battle();
void disable_skip_enter_battle();
void set_white_flagship_keep_count(int ships);
void enable_auto_retire();
void disable_auto_retire();
@@ -533,6 +535,7 @@ private:
std::atomic<bool> m_fast_stage_move_need_pause = false;
std::atomic<bool> m_no_emotion_warning_need_pause = false;
std::atomic<bool> m_skip_enter_battle_need_pause = false;
std::atomic<int> m_keep_white_flagship_number = 0;
static std::vector<std::string> s_shipStatus;
static std::vector<int> s_excludedShips;

View File

@@ -1382,6 +1382,20 @@ CrackerServer::CrackerServer() {
CRACK_OK();
});
Post("/set_white_flagship_keep_count", [](const httplib::Request& req, httplib::Response& res) {
try {
Json::Reader reader;
Json::Value j;
reader.parse(req.body, j);
Cracker::Instance().set_white_flagship_keep_count(j["count"].asInt());
} catch (std::exception& e) {
SPDLOG_ERROR("Set white flagship keep count failed: {}", e.what());
res.status = 500;
return;
}
CRACK_OK();
});
Post("/enable_auto_retire", [](const httplib::Request& req, httplib::Response& res) {
try {
Cracker::Instance().enable_auto_retire();

View File

@@ -173,6 +173,7 @@ void CrackerUI::draw_menu() {
ImGui::Checkbox("自动再次前往", &CONFIG_FLAG(AUTO_ONCE_AGAIN));
ImGui::Checkbox("自动退役", &CONFIG_FLAG(AUTO_RETIRE));
ImGui::Checkbox("跳过战斗进场", &CONFIG_FLAG(SKIP_ENTER_BATTLE));
ImGui::InputInt("自动退役保留白皮航母数量", &m_cracker_config.white_flagship_keep_count);
ImGui::EndTable();
}

View File

@@ -235,6 +235,7 @@
"SkipAirStrikeAnimation": false,
"AutoOnceAgain": false,
"AutoRetire": false,
"AutoRetireKeepWhiteFlagshipCount": 0,
"SkipEnemyScan": false,
"SkipBattleResult": false,
"SkipEnterBattle": false

View File

@@ -934,6 +934,10 @@
"type": "checkbox",
"value": false
},
"AutoRetireKeepWhiteFlagshipCount": {
"type": "input",
"value": 0
},
"SkipEnemyScan": {
"type": "checkbox",
"value": false

View File

@@ -900,6 +900,7 @@ Misc:
SkipAirStrikeAnimation: false
AutoOnceAgain: false
AutoRetire: false
AutoRetireKeepWhiteFlagshipCount: 0
SkipEnemyScan: false
SkipBattleResult: false
SkipEnterBattle: false

View File

@@ -555,6 +555,7 @@ class GeneratedConfig:
Misc_SkipAirStrikeAnimation = False
Misc_AutoOnceAgain = False
Misc_AutoRetire = False
Misc_AutoRetireKeepWhiteFlagshipCount = 0
Misc_SkipEnemyScan = False
Misc_SkipBattleResult = False
Misc_SkipEnterBattle = False

View File

@@ -168,6 +168,7 @@ class FullGeneratedConfig:
Hook_Misc_SkipAirStrikeAnimation = None
Hook_Misc_AutoOnceAgain = None
Hook_Misc_AutoRetire = None
Hook_Misc_AutoRetireKeepWhiteFlagshipCount = None
Hook_Misc_SkipEnemyScan = None
Hook_Misc_SkipBattleResult = None
Hook_Misc_SkipEnterBattle = None

View File

@@ -3195,6 +3195,10 @@
"name": "Misc.AutoRetire.name",
"help": "Misc.AutoRetire.help"
},
"AutoRetireKeepWhiteFlagshipCount": {
"name": "Misc.AutoRetireKeepWhiteFlagshipCount.name",
"help": "Misc.AutoRetireKeepWhiteFlagshipCount.help"
},
"SkipEnemyScan": {
"name": "Misc.SkipEnemyScan.name",
"help": "Misc.SkipEnemyScan.help"

View File

@@ -3195,6 +3195,10 @@
"name": "Misc.AutoRetire.name",
"help": "Misc.AutoRetire.help"
},
"AutoRetireKeepWhiteFlagshipCount": {
"name": "Misc.AutoRetireKeepWhiteFlagshipCount.name",
"help": "Misc.AutoRetireKeepWhiteFlagshipCount.help"
},
"SkipEnemyScan": {
"name": "Misc.SkipEnemyScan.name",
"help": "Misc.SkipEnemyScan.help"

View File

@@ -3195,6 +3195,10 @@
"name": "自动退役",
"help": "注意:该功能存在风险,开启前请确保船是锁上的!!!"
},
"AutoRetireKeepWhiteFlagshipCount": {
"name": "自动退役时保留 X 个一级白皮航母",
"help": "设置为 0 时全部退役,推荐设置为 5"
},
"SkipEnemyScan": {
"name": "章节图跳过索敌",
"help": ""

View File

@@ -3195,6 +3195,10 @@
"name": "Misc.AutoRetire.name",
"help": "Misc.AutoRetire.help"
},
"AutoRetireKeepWhiteFlagshipCount": {
"name": "Misc.AutoRetireKeepWhiteFlagshipCount.name",
"help": "Misc.AutoRetireKeepWhiteFlagshipCount.help"
},
"SkipEnemyScan": {
"name": "Misc.SkipEnemyScan.name",
"help": "Misc.SkipEnemyScan.help"

View File

@@ -57,6 +57,9 @@ class CrackApi:
class ChapterAutoClearStepInterval(BaseModel):
interval: float
class AutoRetireKeepWhiteFlagshipCount(BaseModel):
count: int
def __init__(self, base_url, timeout=10):
self.api_url = base_url
self.timeout = timeout
@@ -422,6 +425,9 @@ class CrackApi:
def disable_auto_once_again(self):
self.post("disable_auto_once_again")
def set_white_flagship_keep_count(self, param: AutoRetireKeepWhiteFlagshipCount):
self.post("set_white_flagship_keep_count", data=param.json())
def enable_auto_retire(self):
self.post("enable_auto_retire")

View File

@@ -393,6 +393,9 @@ class CrackOp:
class EnableAutoRetire(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_AutoRetire:
white_flagship_keep_count = self.full_config.Hook_Misc_AutoRetireKeepWhiteFlagshipCount
if white_flagship_keep_count != 0:
self.api.set_white_flagship_keep_count(CrackApi.AutoRetireKeepWhiteFlagshipCount(count=white_flagship_keep_count))
self.api.enable_auto_retire()
class DisableAutoRetire(Op):