raylu 2 өдөр өмнө
parent
commit
6bed727247
3 өөрчлөгдсөн 16 нэмэгдсэн , 7 устгасан
  1. 9 5
      roi.py
  2. 6 2
      ts/roi.ts
  3. 1 0
      www/index.html

+ 9 - 5
roi.py

@@ -20,11 +20,11 @@ def main() -> None:
 	for recipe in recipes:
 		if profit := calc_profit(recipe, buildings, materials, prices):
 			profits.append(profit)
-	profits.sort(reverse=True)
+	profits.sort()
 	print('\033[1mwrought    \033[0;32mdaily profit/area\033[31m')
 	print('\033[30mrecipe                         \033[0mexpertise            \033[33mcapex \033[35mdaily opex \033[34mlogistics\033[0m')
 	for p in profits:
-		print(f'\033[53;1m{p.output:5} \033[53;32m{p.profit_per_area: 10,.0f} ', end='')
+		print(f'\033[53;1m{p.output:5} \033[53;32m{p.profit_per_day/p.area: 10,.0f} ', end='')
 		warnings = []
 		if p.average_traded_7d < p.output_per_day * 20:
 			warnings.append('low volume')
@@ -69,7 +69,8 @@ def calc_profit(recipe: Recipe, buildings: typing.Mapping[str, Building], materi
 	) * runs_per_day / building['AreaCost']
 	return Profit(output['Ticker'], recipe['RecipeName'],
 			expertise=building['Expertise'].replace('_', ' ').lower(),
-			profit_per_area=(profit_per_run * runs_per_day - worker_consumable_daily_cost) / building['AreaCost'],
+			profit_per_day=(profit_per_run * runs_per_day - worker_consumable_daily_cost),
+			area=building['AreaCost'],
 			capex=capex,
 			cost_per_day=cost_per_day,
 			logistics_per_area=logistics_per_area,
@@ -139,7 +140,8 @@ class Profit:
 	output: str
 	recipe: str
 	expertise: str
-	profit_per_area: float
+	profit_per_day: float
+	area: float
 	capex: float
 	cost_per_day: float
 	logistics_per_area: float
@@ -147,7 +149,9 @@ class Profit:
 	average_traded_7d: float
 
 	def __lt__(self, other: Profit) -> bool:
-		return self.profit_per_area < other.profit_per_area
+		break_even = self.capex / self.profit_per_day
+		other_break_even = other.capex / other.profit_per_day
+		return break_even < other_break_even
 
 if __name__ == '__main__':
 	main()

+ 6 - 2
ts/roi.ts

@@ -8,10 +8,13 @@
 	const tbody = document.querySelector('tbody')!;
 	for (const p of profits) {
 		const tr = document.createElement('tr');
+		const profit_per_area = p.profit_per_day / p.area;
+		const break_even = p.capex / p.profit_per_day;
 		tr.innerHTML = `
 			<td>${p.output}</td>
 			<td>${p.expertise}</td>
-			<td style="color: ${color(p.profit_per_area, 0, 500)}">${formatDecimal(p.profit_per_area)}</td>
+			<td style="color: ${color(profit_per_area, 0, 500)}">${formatDecimal(profit_per_area)}</td>
+			<td><span style="color: ${color(break_even, 30, 2)}">${formatDecimal(break_even)}</span>d</td>
 			<td style="color: ${color(p.capex, 300_000, 50_000)}">${formatWhole(p.capex)}</td>
 			<td style="color: ${color(p.cost_per_day, 100_000, 25_000)}">${formatWhole(p.cost_per_day)}</td>
 			<td style="color: ${color(p.logistics_per_area, 2, 0.2)}">${formatDecimal(p.logistics_per_area)}</td>
@@ -36,7 +39,8 @@ interface Profit {
 	output: string
 	recipe: string
 	expertise: string
-	profit_per_area: number
+	profit_per_day: number
+	area: number
 	capex: number
 	cost_per_day: number
 	logistics_per_area: number

+ 1 - 0
www/index.html

@@ -16,6 +16,7 @@
 					<th>wrought<br>product</th>
 					<th>expertise</th>
 					<th>daily<br>profit/area</th>
+					<th>break<br>even</th>
 					<th>capex</th>
 					<th>daily<br>opex</th>
 					<th>logistics</th>