|
@@ -1,6 +1,7 @@
|
|
|
from __future__ import annotations
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
import dataclasses
|
|
import dataclasses
|
|
|
|
|
+import json
|
|
|
import typing
|
|
import typing
|
|
|
|
|
|
|
|
import cache
|
|
import cache
|
|
@@ -29,7 +30,7 @@ def main() -> None:
|
|
|
warnings.append('low volume')
|
|
warnings.append('low volume')
|
|
|
if p.logistics_per_area > 1.5:
|
|
if p.logistics_per_area > 1.5:
|
|
|
warnings.append('heavy logistics')
|
|
warnings.append('heavy logistics')
|
|
|
- if p.high_opex:
|
|
|
|
|
|
|
+ if p.cost_per_day > 50_000:
|
|
|
warnings.append('high opex')
|
|
warnings.append('high opex')
|
|
|
if len(warnings) > 0:
|
|
if len(warnings) > 0:
|
|
|
print(' \033[31m' + ' '.join(warnings).ljust(43), end='')
|
|
print(' \033[31m' + ' '.join(warnings).ljust(43), end='')
|
|
@@ -37,6 +38,9 @@ def main() -> None:
|
|
|
print(' ' * 14 + '\033[0;53m' + ' ' * 43, end='')
|
|
print(' ' * 14 + '\033[0;53m' + ' ' * 43, end='')
|
|
|
print(f'\n\033[0;30m{p.recipe:30} \033[0m{p.expertise:19} \033[33m{p.capex:7,.0f} \033[35m{p.cost_per_day:9,.0f} \033[34m{p.logistics_per_area:5.2f}\033[0m')
|
|
print(f'\n\033[0;30m{p.recipe:30} \033[0m{p.expertise:19} \033[33m{p.capex:7,.0f} \033[35m{p.cost_per_day:9,.0f} \033[34m{p.logistics_per_area:5.2f}\033[0m')
|
|
|
|
|
|
|
|
|
|
+ with open('www/roi.json', 'w') as f:
|
|
|
|
|
+ json.dump([dataclasses.asdict(p) for p in profits], f, indent='\t')
|
|
|
|
|
+
|
|
|
def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materials: typing.Mapping[str, Material],
|
|
def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materials: typing.Mapping[str, Material],
|
|
|
prices: typing.Mapping[str, Price]) -> Profit | None:
|
|
prices: typing.Mapping[str, Price]) -> Profit | None:
|
|
|
try:
|
|
try:
|
|
@@ -139,11 +143,9 @@ class Profit:
|
|
|
cost_per_day: float
|
|
cost_per_day: float
|
|
|
logistics_per_area: float
|
|
logistics_per_area: float
|
|
|
low_volume: bool
|
|
low_volume: bool
|
|
|
- high_opex: bool = dataclasses.field(init=False)
|
|
|
|
|
score: float = dataclasses.field(init=False)
|
|
score: float = dataclasses.field(init=False)
|
|
|
|
|
|
|
|
def __post_init__(self) -> None:
|
|
def __post_init__(self) -> None:
|
|
|
- self.high_opex = self.cost_per_day > 50_000
|
|
|
|
|
self.score = self.profit_per_area
|
|
self.score = self.profit_per_area
|
|
|
if self.low_volume:
|
|
if self.low_volume:
|
|
|
self.score *= 0.2
|
|
self.score *= 0.2
|