Skip to content

Commit

Permalink
修正副产物的计算逻辑 (#13)
Browse files Browse the repository at this point in the history
* “避免溢出”按钮 格式和代码整理

* 注释格式:一般是注释在代码前,并且"//"后应该有空格

* 删除更改逻辑时未处理的重复计算的步骤

* revert changes to package-lock.json

* Revert changes to package.json

---------

Co-authored-by: JimmyZJX <x@201a.cn>
  • Loading branch information
makuwa8992 and JimmyZJX committed Jan 9, 2024
1 parent 8607736 commit c72b220
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
23 changes: 0 additions & 23 deletions src/global_state.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,6 @@ export class GlobalState {
"成本":一个物品的当前产线成本以及被赋予的额外成本,若为原矿化物品或关键物品或多来源物品则为0
"累计成本":一个物品独自建造时的历史总计产出的成本,若为原矿化物品或关键物品或多来源物品则为0
*/
console.log(item_graph["石墨烯"]);
console.log(item_price["石墨烯"]);
console.log(result_dict);
for (var item in in_out_list) {
if (in_out_list[item] > 0) {
if (item in result_dict) {
Expand All @@ -634,33 +631,13 @@ export class GlobalState {
else {
result_dict[item] = in_out_list[item];
}
if (item_graph[item]["副产物"] && !(item in multi_sources) && !(item in key_item_list)) {//如果是线性规划相关物品的副产物,因为这边是当成原矿化的所以不应考虑其副产物
for (var other_products in item_graph[item]["副产物"]) {
if (other_products in surplus_list) {
surplus_list[other_products] = Number(surplus_list[other_products]) + item_graph[item]["副产物"][other_products] * in_out_list[item];
}
else {
surplus_list[other_products] = item_graph[item]["副产物"][other_products] * in_out_list[item];
}
}
}
for (var material in item_price[item]["原料"]) {
if (material in result_dict) {
result_dict[material] = Number(result_dict[material]) + item_price[item]["原料"][material] * in_out_list[item];
}
else {
result_dict[material] = item_price[item]["原料"][material] * in_out_list[item];
}
if (item_graph[material]["副产物"] && !(material in multi_sources) && !(material in key_item_list)) {
for (var other_products in item_graph[material]["副产物"]) {
if (other_products in surplus_list) {
surplus_list[other_products] = Number(surplus_list[other_products]) + item_graph[material]["副产物"][other_products] * item_price[item]["原料"][material] * in_out_list[item];
}
else {
surplus_list[other_products] = item_graph[material]["副产物"][other_products] * item_price[item]["原料"][material] * in_out_list[item];
}
}
}
}
}
}//遍历物品的item_price降可迭代物品的生产结果和副产物产出结果放入输出结果内
Expand Down
2 changes: 1 addition & 1 deletion src/scheme_data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DEFAULT_SCHEME_DATA = {
"单极磁石": { "成本": 10, "启用": 1, "与其它成本累计": 0 },
"铁": { "成本": 1, "启用": 0, "与其它成本累计": 0 }
}
},//这是示例,实际上cost_weight之后会在init_scheme_data中重置
},
"mining_rate": {
"科技面板倍率": 1.0,
"小矿机覆盖矿脉数": 8,
Expand Down

0 comments on commit c72b220

Please sign in to comment.