3 Angajamente e221706391 ... d3e0524f77

Autor SHA1 Permisiunea de a trimite mesaje. Dacă este dezactivată, utilizatorul nu va putea trimite nici un fel de mesaj Data
  raylu d3e0524f77 roi: draw lines between recipes 1 săptămână în urmă
  raylu ac1ff9723f roi: header, bold 1 săptămână în urmă
  raylu a322c939a5 roi: include worker consumable costs 1 săptămână în urmă
1 a modificat fișierele cu 35 adăugiri și 7 ștergeri
  1. 35 7
      roi.py

+ 35 - 7
roi.py

@@ -20,15 +20,22 @@ def main() -> None:
 		if profit := calc_profit(recipe, buildings, materials, prices):
 			profits.append(profit)
 	profits.sort(reverse=True)
+	print('\033[1mwrought    \033[0;32mdaily profit/area\033[31m')
+	print('\033[30mrecipe                         \033[0mexpertise            \033[33mcapex \033[35mdaily opex\033[0m')
 	for p in profits:
-		print(f'{p.output:5} \033[32m{p.profit_per_area: 10,.0f}\033[31m', end='')
+		print(f'\033[53;1m{p.output:5} \033[53;32m{p.profit_per_area: 10,.0f} ', end='')
+		warnings = []
 		if p.low_volume:
-			print(' low volume', end='')
+			warnings.append('low volume')
 		if p.heavy_logistics:
-			print(' heavy logistics', end='')
+			warnings.append('heavy logistics')
 		if p.high_opex:
-			print(' high opex', end='')
-		print(f'\n\033[30m{p.recipe:30} \033[0m{p.expertise:19} \033[33m{p.capex:7,.0f} \033[35m{p.cost_per_day:7,.0f}\033[0m')
+			warnings.append('high opex')
+		if len(warnings) > 0:
+			print('               \033[31m' + ' '.join(warnings).rjust(36), end='')
+		else:
+			print(' ' * 14 + '\033[0;53m' + ' ' * 37, 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[0m')
 
 def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materials: typing.Mapping[str, Material],
 		prices: typing.Mapping[str, Price]) -> Profit | None:
@@ -47,7 +54,8 @@ def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materi
 			for bm in building['BuildingCosts'])
 	profit_per_run = revenue - cost
 	runs_per_day = 24 * 60 * 60 * 1000 / recipe['TimeMs']
-	cost_per_day = cost * runs_per_day
+	worker_consumable_daily_cost = building_daily_cost(building, prices)
+	cost_per_day = cost * runs_per_day + worker_consumable_daily_cost
 	output_per_day = output['Amount'] * runs_per_day
 	logistics_per_day = max(
 		sum(materials[input['Ticker']]['Weight'] * input['Amount'] for input in recipe['Inputs']),
@@ -57,12 +65,27 @@ def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materi
 	) * runs_per_day
 	return Profit(output['Ticker'], recipe['RecipeName'],
 			expertise=building['Expertise'].replace('_', ' ').lower(),
-			profit_per_area=profit_per_run * runs_per_day / building['AreaCost'],
+			profit_per_area=(profit_per_run * runs_per_day - worker_consumable_daily_cost) / building['AreaCost'],
 			capex=capex,
 			cost_per_day=cost_per_day,
 			low_volume=output_price.average_traded < output_per_day * 20,
 			heavy_logistics=logistics_per_day > 100)
 
+def building_daily_cost(building: Building, prices: typing.Mapping[str, Price]) -> float:
+	consumption = {
+		'Pioneers': [('COF', 0.5), ('DW', 4), ('RAT', 4), ('OVE', 0.5), ('PWO', 0.2)],
+		'Settlers': [('DW', 5), ('RAT', 6), ('KOM', 1), ('EXO', 0.5), ('REP', 0.2), ('PT', 0.5)],
+		'Technicians': [('DW', 7.5), ('RAT', 7), ('ALE', 1), ('MED', 0.5), ('SC', 0.1), ('HMS', 0.5), ('SCN', 0.1)],
+		'Engineers': [('DW', 10), ('MED', 0.5), ('GIN', 1), ('FIM', 7), ('VG', 0.2), ('HSS', 0.2), ('PDA', 0.1)],
+		'Scientists': [('DW', 10), ('MED', 0.5), ('WIN', 1), ('MEA', 7), ('NST', 0.1), ('LC', 0.2), ('WS', 0.1)],
+	}
+	cost = 0
+	for worker, mats in consumption.items():
+		workers = building[worker]
+		for mat, per_100 in mats:
+			cost += prices[mat].vwap * workers * per_100 / 100
+	return cost
+
 class Recipe(typing.TypedDict):
 	RecipeName: str
 	BuildingTicker: str
@@ -79,6 +102,11 @@ class Building(typing.TypedDict):
 	Expertise: str
 	AreaCost: int
 	BuildingCosts: list[BuildingMat]
+	Pioneers: int
+	Settlers: int
+	Technicians: int
+	Engineers: int
+	Scientists: int
 
 class BuildingMat(typing.TypedDict):
 	CommodityTicker: str