Refactor Kelp Profit Calculator to include buy kelp option and update pricing constants
This commit is contained in:
parent
4a7adf1006
commit
88cac0c5e9
Binary file not shown.
@ -17,10 +17,11 @@ except Exception as exc:
|
|||||||
# EDIT VALUES HERE (CONFIG)
|
# EDIT VALUES HERE (CONFIG)
|
||||||
# =========================
|
# =========================
|
||||||
|
|
||||||
KELP_PRICE = 61.6 # per kelp item
|
KELP_PRICE = 61 # per kelp item
|
||||||
BLAZE_ROD_PRICE = 150 # per blaze rod
|
BLAZE_ROD_PRICE = 150 # per blaze rod
|
||||||
DRIED_KELP_PRICE = 86 # per dried kelp item
|
DRIED_KELP_PRICE = 83.18 # per dried kelp item
|
||||||
DRIED_KELP_BLOCK_PRICE = 751.01 # per dried kelp block
|
DRIED_KELP_BLOCK_PRICE = 750.5 # per dried kelp block
|
||||||
|
BUY_KELP = True # True = buy kelp, False = use owned kelp
|
||||||
|
|
||||||
SMOKERS = 64 # amount of smokers
|
SMOKERS = 64 # amount of smokers
|
||||||
KELP_AMOUNT = "1s" # amount of kelp to process (items)
|
KELP_AMOUNT = "1s" # amount of kelp to process (items)
|
||||||
@ -141,6 +142,7 @@ def calculate(
|
|||||||
dried_kelp_block_price: float,
|
dried_kelp_block_price: float,
|
||||||
smokers: int,
|
smokers: int,
|
||||||
kelp_amount: int,
|
kelp_amount: int,
|
||||||
|
buy_kelp: bool,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
|
||||||
if smokers <= 0:
|
if smokers <= 0:
|
||||||
@ -160,7 +162,11 @@ def calculate(
|
|||||||
total_hours = total_minutes / 60
|
total_hours = total_minutes / 60
|
||||||
|
|
||||||
# --- Scenario 1: Smelt and sell dried kelp ---
|
# --- Scenario 1: Smelt and sell dried kelp ---
|
||||||
kelp_cost = kelp_amount * kelp_price
|
kelp_market_value = kelp_amount * kelp_price
|
||||||
|
# In owned mode we still use kelp market value as opportunity cost,
|
||||||
|
# but label it as raw kelp profit in the UI.
|
||||||
|
kelp_cost = kelp_market_value
|
||||||
|
kelp_value_label = "Kelp Cost" if buy_kelp else "Raw Kelp Profit"
|
||||||
cost_smelt_only = kelp_cost + fuel_cost
|
cost_smelt_only = kelp_cost + fuel_cost
|
||||||
revenue_smelt_only = dried_kelp_out * dried_kelp_price
|
revenue_smelt_only = dried_kelp_out * dried_kelp_price
|
||||||
profit_smelt_only = revenue_smelt_only - cost_smelt_only
|
profit_smelt_only = revenue_smelt_only - cost_smelt_only
|
||||||
@ -175,7 +181,7 @@ def calculate(
|
|||||||
profit_craft_only = revenue_craft_only - cost_craft_only
|
profit_craft_only = revenue_craft_only - cost_craft_only
|
||||||
|
|
||||||
# --- Scenario 3: Smelt then craft, sell blocks + leftover dried kelp ---
|
# --- Scenario 3: Smelt then craft, sell blocks + leftover dried kelp ---
|
||||||
cost_smelt_then_craft = kelp_amount * kelp_price + fuel_cost
|
cost_smelt_then_craft = kelp_cost + fuel_cost
|
||||||
revenue_smelt_then_craft = (blocks_from_amount * dried_kelp_block_price) + (leftover_dried * dried_kelp_price)
|
revenue_smelt_then_craft = (blocks_from_amount * dried_kelp_block_price) + (leftover_dried * dried_kelp_price)
|
||||||
profit_smelt_then_craft = revenue_smelt_then_craft - cost_smelt_then_craft
|
profit_smelt_then_craft = revenue_smelt_then_craft - cost_smelt_then_craft
|
||||||
|
|
||||||
@ -185,6 +191,7 @@ def calculate(
|
|||||||
print(f"BLAZE_ROD_PRICE: {blaze_rod_price}")
|
print(f"BLAZE_ROD_PRICE: {blaze_rod_price}")
|
||||||
print(f"DRIED_KELP_PRICE: {dried_kelp_price}")
|
print(f"DRIED_KELP_PRICE: {dried_kelp_price}")
|
||||||
print(f"DRIED_KELP_BLOCK_PRICE: {dried_kelp_block_price}")
|
print(f"DRIED_KELP_BLOCK_PRICE: {dried_kelp_block_price}")
|
||||||
|
print(f"BUY_KELP: {buy_kelp}")
|
||||||
print(f"SMOKERS: {smokers}")
|
print(f"SMOKERS: {smokers}")
|
||||||
print(f"KELP_AMOUNT: {kelp_amount}")
|
print(f"KELP_AMOUNT: {kelp_amount}")
|
||||||
|
|
||||||
@ -213,12 +220,15 @@ def calculate(
|
|||||||
"blaze_rod_price": blaze_rod_price,
|
"blaze_rod_price": blaze_rod_price,
|
||||||
"dried_kelp_price": dried_kelp_price,
|
"dried_kelp_price": dried_kelp_price,
|
||||||
"dried_kelp_block_price": dried_kelp_block_price,
|
"dried_kelp_block_price": dried_kelp_block_price,
|
||||||
|
"buy_kelp": buy_kelp,
|
||||||
"smokers": smokers,
|
"smokers": smokers,
|
||||||
"kelp_amount": kelp_amount,
|
"kelp_amount": kelp_amount,
|
||||||
"dried_kelp_out": dried_kelp_out,
|
"dried_kelp_out": dried_kelp_out,
|
||||||
"blocks_from_amount": blocks_from_amount,
|
"blocks_from_amount": blocks_from_amount,
|
||||||
"leftover_dried": leftover_dried,
|
"leftover_dried": leftover_dried,
|
||||||
"blaze_rods_used": blaze_rods_used,
|
"blaze_rods_used": blaze_rods_used,
|
||||||
|
"kelp_market_value": kelp_market_value,
|
||||||
|
"kelp_value_label": kelp_value_label,
|
||||||
"kelp_cost": kelp_cost,
|
"kelp_cost": kelp_cost,
|
||||||
"fuel_cost": fuel_cost,
|
"fuel_cost": fuel_cost,
|
||||||
"total_seconds": total_seconds,
|
"total_seconds": total_seconds,
|
||||||
@ -241,6 +251,7 @@ def format_results(data: dict) -> str:
|
|||||||
f"BLAZE_ROD_PRICE: {data['blaze_rod_price']}\n"
|
f"BLAZE_ROD_PRICE: {data['blaze_rod_price']}\n"
|
||||||
f"DRIED_KELP_PRICE: {data['dried_kelp_price']}\n"
|
f"DRIED_KELP_PRICE: {data['dried_kelp_price']}\n"
|
||||||
f"DRIED_KELP_BLOCK_PRICE: {data['dried_kelp_block_price']}\n"
|
f"DRIED_KELP_BLOCK_PRICE: {data['dried_kelp_block_price']}\n"
|
||||||
|
f"BUY_KELP: {data['buy_kelp']}\n"
|
||||||
f"SMOKERS: {data['smokers']}\n"
|
f"SMOKERS: {data['smokers']}\n"
|
||||||
f"KELP_AMOUNT: {data['kelp_amount']}\n\n"
|
f"KELP_AMOUNT: {data['kelp_amount']}\n\n"
|
||||||
"=== Results ===\n"
|
"=== Results ===\n"
|
||||||
@ -275,6 +286,7 @@ def main():
|
|||||||
dried_kelp_block_price=parse_number_with_suffix(DRIED_KELP_BLOCK_PRICE),
|
dried_kelp_block_price=parse_number_with_suffix(DRIED_KELP_BLOCK_PRICE),
|
||||||
smokers=parse_int_with_suffix(SMOKERS, "SMOKERS"),
|
smokers=parse_int_with_suffix(SMOKERS, "SMOKERS"),
|
||||||
kelp_amount=parse_kelp_amount(KELP_AMOUNT),
|
kelp_amount=parse_kelp_amount(KELP_AMOUNT),
|
||||||
|
buy_kelp=BUY_KELP,
|
||||||
)
|
)
|
||||||
|
|
||||||
print(format_results(data))
|
print(format_results(data))
|
||||||
@ -320,6 +332,18 @@ def launch_ui():
|
|||||||
bordercolor="#2b2d31",
|
bordercolor="#2b2d31",
|
||||||
insertcolor="#f2f3f5",
|
insertcolor="#f2f3f5",
|
||||||
)
|
)
|
||||||
|
style.configure("SourceOn.TButton", font=("Segoe UI", 9, "bold"), padding=7)
|
||||||
|
style.map(
|
||||||
|
"SourceOn.TButton",
|
||||||
|
background=[("active", "#4752c4"), ("!disabled", "#5865f2")],
|
||||||
|
foreground=[("!disabled", "#ffffff")],
|
||||||
|
)
|
||||||
|
style.configure("SourceOff.TButton", font=("Segoe UI", 9, "bold"), padding=7)
|
||||||
|
style.map(
|
||||||
|
"SourceOff.TButton",
|
||||||
|
background=[("active", "#3a3d42"), ("!disabled", "#2b2d31")],
|
||||||
|
foreground=[("!disabled", "#dbdee1")],
|
||||||
|
)
|
||||||
|
|
||||||
style.configure("Dark.Vertical.TScrollbar", background="#2b2d31", troughcolor="#1e1f22")
|
style.configure("Dark.Vertical.TScrollbar", background="#2b2d31", troughcolor="#1e1f22")
|
||||||
|
|
||||||
@ -358,6 +382,7 @@ def launch_ui():
|
|||||||
]
|
]
|
||||||
|
|
||||||
entries = {}
|
entries = {}
|
||||||
|
buy_kelp_var = tk.BooleanVar(value=BUY_KELP)
|
||||||
|
|
||||||
ttk.Label(input_card, text="Inputs", style="FieldLabel.TLabel").grid(
|
ttk.Label(input_card, text="Inputs", style="FieldLabel.TLabel").grid(
|
||||||
row=0, column=0, columnspan=2, sticky="w", pady=(0, 10)
|
row=0, column=0, columnspan=2, sticky="w", pady=(0, 10)
|
||||||
@ -372,6 +397,28 @@ def launch_ui():
|
|||||||
entry.grid(row=row + 1, column=1, sticky="ew", pady=6)
|
entry.grid(row=row + 1, column=1, sticky="ew", pady=6)
|
||||||
entries[label_text] = entry
|
entries[label_text] = entry
|
||||||
|
|
||||||
|
source_row = ttk.Frame(input_card, style="Card.TFrame")
|
||||||
|
source_row.grid(row=len(fields) + 1, column=0, columnspan=2, sticky="ew", pady=(10, 2))
|
||||||
|
source_row.grid_columnconfigure(1, weight=1)
|
||||||
|
|
||||||
|
ttk.Label(source_row, text="Kelp Source", style="FieldLabel.TLabel").grid(row=0, column=0, sticky="w", padx=(0, 8))
|
||||||
|
source_toggle_btn = ttk.Button(source_row)
|
||||||
|
source_toggle_btn.grid(row=0, column=1, sticky="ew")
|
||||||
|
|
||||||
|
def refresh_source_toggle():
|
||||||
|
if buy_kelp_var.get():
|
||||||
|
source_toggle_btn.configure(text="Buying Kelp (click to use owned)", style="SourceOn.TButton")
|
||||||
|
else:
|
||||||
|
source_toggle_btn.configure(text="Using Owned Kelp (click to buy)", style="SourceOff.TButton")
|
||||||
|
|
||||||
|
def toggle_kelp_source():
|
||||||
|
buy_kelp_var.set(not buy_kelp_var.get())
|
||||||
|
refresh_source_toggle()
|
||||||
|
on_calculate()
|
||||||
|
|
||||||
|
source_toggle_btn.configure(command=toggle_kelp_source)
|
||||||
|
refresh_source_toggle()
|
||||||
|
|
||||||
kpi_row = ttk.Frame(results_card, style="Card.TFrame")
|
kpi_row = ttk.Frame(results_card, style="Card.TFrame")
|
||||||
kpi_row.grid(row=0, column=0, sticky="ew")
|
kpi_row.grid(row=0, column=0, sticky="ew")
|
||||||
kpi_row.grid_columnconfigure(0, weight=1)
|
kpi_row.grid_columnconfigure(0, weight=1)
|
||||||
@ -418,7 +465,8 @@ def launch_ui():
|
|||||||
fuel_cost_value = ttk.Label(fuel_card, text="0.00", style="KpiValueProfit.TLabel")
|
fuel_cost_value = ttk.Label(fuel_card, text="0.00", style="KpiValueProfit.TLabel")
|
||||||
fuel_cost_value.pack(anchor="w")
|
fuel_cost_value.pack(anchor="w")
|
||||||
|
|
||||||
ttk.Label(kelp_card, text="Kelp Cost", style="KpiLabel.TLabel").pack(anchor="w")
|
kelp_cost_label = ttk.Label(kelp_card, text="Kelp Cost", style="KpiLabel.TLabel")
|
||||||
|
kelp_cost_label.pack(anchor="w")
|
||||||
kelp_cost_value = ttk.Label(kelp_card, text="0.00", style="KpiValueProfit.TLabel")
|
kelp_cost_value = ttk.Label(kelp_card, text="0.00", style="KpiValueProfit.TLabel")
|
||||||
kelp_cost_value.pack(anchor="w")
|
kelp_cost_value.pack(anchor="w")
|
||||||
|
|
||||||
@ -470,6 +518,7 @@ def launch_ui():
|
|||||||
dried_kelp_block_price=parse_number_with_suffix(entries["Dried Kelp Block Price (k/m/b)"].get()),
|
dried_kelp_block_price=parse_number_with_suffix(entries["Dried Kelp Block Price (k/m/b)"].get()),
|
||||||
smokers=parse_int_with_suffix(entries["Smokers (k/m/b)"].get(), "SMOKERS"),
|
smokers=parse_int_with_suffix(entries["Smokers (k/m/b)"].get(), "SMOKERS"),
|
||||||
kelp_amount=parse_kelp_amount(entries["Kelp Amount (items k/m/b or s/ks/ms/bs)"].get()),
|
kelp_amount=parse_kelp_amount(entries["Kelp Amount (items k/m/b or s/ks/ms/bs)"].get()),
|
||||||
|
buy_kelp=buy_kelp_var.get(),
|
||||||
)
|
)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
messagebox.showerror("Invalid input", str(exc))
|
messagebox.showerror("Invalid input", str(exc))
|
||||||
@ -499,6 +548,7 @@ def launch_ui():
|
|||||||
|
|
||||||
smelt_time_value.configure(text=format_duration(data["total_seconds"]))
|
smelt_time_value.configure(text=format_duration(data["total_seconds"]))
|
||||||
fuel_cost_value.configure(text=money(data["fuel_cost"]))
|
fuel_cost_value.configure(text=money(data["fuel_cost"]))
|
||||||
|
kelp_cost_label.configure(text=data["kelp_value_label"])
|
||||||
kelp_cost_value.configure(text=money(data["kelp_cost"]))
|
kelp_cost_value.configure(text=money(data["kelp_cost"]))
|
||||||
|
|
||||||
result_text.delete("1.0", tk.END)
|
result_text.delete("1.0", tk.END)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user