Skip to content

Commit

Permalink
mod切换添加弹窗,有增产策略无增产剂时自动选择最后增产剂 (#33)
Browse files Browse the repository at this point in the history
 添加切mod弹窗提示,有增产策略无增产剂时强制选择最后的增产剂
  • Loading branch information
MengLeiFudge authored Oct 13, 2024
1 parent b0a9e10 commit e45ffdc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ import {
} from "./GameData.jsx";
import {Select} from "antd";

function GameVersion({set_needs_list}) {
function GameVersion({needs_list, set_needs_list}) {
const mod_options = get_mod_options();
const set_game_data = useContext(GameInfoSetterContext);
const set_scheme_data = useContext(SchemeDataSetterContext);
const [mods, set_mods] = useState([]);

async function mods_change(modList) {
if (JSON.stringify(needs_list) !== '{}'
&& !confirm(`检测到计算器内有产线,确认继续切换mod吗?切换后将清空产线!`)) {
return;// 用户取消
}
//清除产线
set_needs_list({});
//判断modList是否合理,并调整顺序
//巨构是深空的前置依赖
let b1 = false;
Expand Down Expand Up @@ -120,7 +126,7 @@ function AppWithContexts() {
return <>
{/*游戏版本、模组选择*/}
<div className="d-flex column-gap-4 row-gap-2 flex-wrap">
<GameVersion set_needs_list={set_needs_list}/>
<GameVersion needs_list={needs_list} set_needs_list={set_needs_list}/>
</div>
{/*生产策略、需求列表、清空数据缓存按钮、采矿参数&其他设置是否显示按钮*/}
<div className="d-flex column-gap-4 row-gap-2 flex-wrap">
Expand Down
2 changes: 1 addition & 1 deletion src/batch_setting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function BatchSetting() {
let pro_num_item = {};
for (let data of game_data.proliferator_data) {
let pro_point = data["增产点数"];
pro_num_item[pro_point] = pro_point == 0 ? "无" : data["名称"];
pro_num_item[pro_point] = pro_point === 0 ? "无" : data["名称"];
}

let factory_doms = [];
Expand Down
16 changes: 16 additions & 0 deletions src/global_state.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ export class GlobalState {
this.scheme_data = scheme_data;
this.ui_settings = ui_settings;

//获取最后一个增产剂对应的点数值
//懒得比较获取最大值了,直接用最后一个增产剂作为最大值
let maxProliferatorPoint = game_info.game_data.proliferator_data[game_info.game_data.proliferator_data.length - 1].增产点数;
for (let i = 0; i < scheme_data.scheme_for_recipe.length; i++) {
//选择增产塔对应配方时,如果未选择增产策略,强制选择增产策略为增产分馏
if (game_info.game_data.recipe_data[i].增产 == 8//8也就是bit4,增产分馏策略的位置
&& scheme_data.scheme_for_recipe[i].增产模式 == 0) {
scheme_data.scheme_for_recipe[i].增产模式 = 4;//模式就是对应的bit,也就是4
}
//选择增产策略但是未选择增产剂时,强制选择最后一个增产剂;但是选择增产剂时,不会强制选择增产策略
if (scheme_data.scheme_for_recipe[i].增产模式 > 0
&& scheme_data.scheme_for_recipe[i].增产点数 == 0) {
scheme_data.scheme_for_recipe[i].增产点数 = maxProliferatorPoint;
}
}

this.#init_pro_proliferator(ui_settings.proliferate_itself);
this.#init_item_graph();
this.#init_item_list();
Expand Down

0 comments on commit e45ffdc

Please sign in to comment.