From dde7dbf3a0c3051f0e2ddd7235e353675dedb98c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 21 Sep 2024 00:00:13 -0700 Subject: [PATCH] Update lemonade.py --- modules/lemonade.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/modules/lemonade.py b/modules/lemonade.py index 5db03a1..d4b966d 100644 --- a/modules/lemonade.py +++ b/modules/lemonade.py @@ -325,7 +325,7 @@ def start_lemonade(nodeID, message, celsius=False): else: buffer += "๐Ÿ“ŠP&L๐Ÿ“ˆ" + pnl - buffer += f"\n๐Ÿฅค to buy? Have {inventory.cups}, Cost {locale.currency(cups.cost, grouping=True)}/{str(cups.count)}๐Ÿ“ฆ" + buffer += f"\n๐Ÿฅค to buy? Have {inventory.cups} Cost {locale.currency(cups.cost, grouping=True)} a ๐Ÿ“ฆ of {str(cups.count)}" saveValues() return buffer @@ -340,8 +340,8 @@ def start_lemonade(nodeID, message, celsius=False): return "You do not have enough ๐Ÿ’ต." inventory.cups += (newcups * cups.count) inventory.cash -= cost - msg = "Purchased " + str(newcups) + " ๐Ÿ“ฆ of ๐Ÿฅค. " - msg += str(inventory.cups) + " ๐Ÿฅค inventory, " + locale.currency(inventory.cash, grouping=True) + " remaining๐Ÿ“Š" + msg = "Purchased " + str(newcups) + " ๐Ÿ“ฆ " + msg += str(inventory.cups) + " ๐Ÿฅค in inventory. " + locale.currency(inventory.cash, grouping=True) + f" remaining๐Ÿ“Š" else: msg = "No ๐Ÿฅค were purchased" except Exception as e: @@ -353,7 +353,7 @@ def start_lemonade(nodeID, message, celsius=False): if lemonadeTracker[i]['nodeID'] == nodeID: lemonadeTracker[i]['cmd'] = "lemons" saveValues() - msg += f"\n๐Ÿ‹ to buy? Have {inventory.lemons}, Cost {locale.currency(lemons.cost, grouping=True)} a ๐Ÿงบ for {str(lemons.count)}๐Ÿฅค" + msg += f"\n ๐Ÿ‹ to buy? Have {inventory.lemons}๐Ÿฅค of ๐Ÿ‹ Cost {locale.currency(lemons.cost, grouping=True)} a ๐Ÿงบ for {str(lemons.count)}๐Ÿฅค" return msg @@ -368,8 +368,8 @@ def start_lemonade(nodeID, message, celsius=False): return "You do not have enough cash." inventory.lemons += (newlemons * lemons.count) inventory.cash -= cost - msg = "Purchased " + str(newlemons) + " ๐Ÿงบ of ๐Ÿ‹. " - msg += str(inventory.lemons) + " ๐Ÿ‹ inventory, " + locale.currency(inventory.cash, grouping=True) + " remaining๐Ÿ“Š" + msg = "Purchased " + str(newlemons) + " ๐Ÿงบ " + msg += str(inventory.lemons) + " ๐Ÿ‹ in inventory. " + locale.currency(inventory.cash, grouping=True) + f" remaining๐Ÿ“Š" else: msg = "No ๐Ÿ‹ were purchased" except Exception as e: @@ -381,7 +381,7 @@ def start_lemonade(nodeID, message, celsius=False): if lemonadeTracker[i]['nodeID'] == nodeID: lemonadeTracker[i]['cmd'] = "sugar" saveValues() - msg += f"\n๐Ÿš to buy? You have {inventory.sugar} ๐Ÿฅค, Cost {locale.currency(sugar.cost, grouping=True)} a bag for {str(sugar.count)}๐Ÿฅค" + msg += f"\n ๐Ÿš to buy? You have {inventory.sugar}๐Ÿฅค of ๐Ÿš, Cost {locale.currency(sugar.cost, grouping=True)} a bag for {str(sugar.count)}๐Ÿฅค" return msg if "sugar" in last_cmd: @@ -396,7 +396,7 @@ def start_lemonade(nodeID, message, celsius=False): inventory.sugar += (newsugar * sugar.count) inventory.cash -= cost msg = " Purchased " + str(newsugar) + " bag(s) of ๐Ÿš for " + locale.currency(cost, grouping=True) - msg += ". " + str(inventory.sugar) + " ๐Ÿš inventory, " + locale.currency(inventory.cash, grouping=True) + " ๐Ÿ’ต remaining" + msg += ". " + str(inventory.sugar) + f"๐Ÿฅค๐Ÿš in inventory." else: msg = "No additional ๐Ÿš was purchased" except Exception as e: @@ -407,7 +407,7 @@ def start_lemonade(nodeID, message, celsius=False): if lemonadeTracker[i]['nodeID'] == nodeID: lemonadeTracker[i]['cmd'] = "price" saveValues() - msg += f"\nPrice to Sell? Cost of goods is {locale.currency(unit, grouping=True)} per ๐Ÿฅค" + msg += f"\nPrice to Sell? Cost of goods is {locale.currency(unit, grouping=True)} per ๐Ÿฅค {locale.currency(inventory.cash, grouping=True)} ๐Ÿ’ต remaining" return msg if "price" in last_cmd: @@ -455,10 +455,10 @@ def start_lemonade(nodeID, message, celsius=False): gainloss= inventory.cash - inventory.start # Display the calculated sales information - msg = "Results Week #" + str(weeks.current) + " of " + str(weeks.total) + msg = "Results Week๐Ÿ“Š#" + str(weeks.current) + "of" + str(weeks.total) msg += " Cost/Price:" + locale.currency(unit, grouping=True) + "/" + locale.currency(price, grouping=True) msg += " P.Margin:" + locale.currency(margin, grouping=True) - msg += " T.Sales:" + str(sales) + " x " + locale.currency(price, grouping=True) + msg += " T.Sales:" + str(sales) + "@" + locale.currency(price, grouping=True) msg += " G.Profit: " + locale.currency(gross, grouping=True) msg += " N.Profit:" + locale.currency(net, grouping=True) @@ -468,7 +468,13 @@ def start_lemonade(nodeID, message, celsius=False): msg += " ๐Ÿ‹:" + str(inventory.lemons) msg += " ๐Ÿš:" + str(inventory.sugar) msg += " ๐Ÿ’ต:" + locale.currency(inventory.cash, grouping=True) - msg += " P&L:" + locale.currency(gainloss, grouping=True) + # Display the gain/loss + pnl = locale.currency(gainloss, grouping=True) + if "0.00" not in pnl: + if pnl.startswith("-"): + buffer += "๐Ÿ“ŠP&L๐Ÿ“‰" + pnl + else: + buffer += "๐Ÿ“ŠP&L๐Ÿ“ˆ" + pnl # Display the weekly sales summary pad_week = len(str(weeks.total)) @@ -476,8 +482,8 @@ def start_lemonade(nodeID, message, celsius=False): total = 0 msg += "\nWeekly๐Ÿ“Š" for i in range(len(weeks.summary)): - msg += " Week " + str(weeks.current).rjust(pad_week) + ": " + str(weeks.summary[i]['sales']).rjust(pad_sale) + \ - " sold x " + locale.currency(weeks.summary[i]['price'], grouping=True) + " ea." + msg += "#" + str(weeks.current).rjust(pad_week) + ". " + str(weeks.summary[i]['sales']).rjust(pad_sale) + \ + " sold x " + locale.currency(weeks.summary[i]['price'], grouping=True) + "ea. " total = total + weeks.summary[i]['sales'] # Loop through a range of prices to find the highest net profit @@ -502,7 +508,7 @@ def start_lemonade(nodeID, message, celsius=False): maxnet = net if (maxnet > minnet): msg += "Sales could have been:" - msg += " " + str(maxsales) + " sold x " + locale.currency(maxprice, grouping=True) + " ea. = " + \ + msg += " " + str(maxsales) + " sold x " + locale.currency(maxprice, grouping=True) + "ea. @" + \ locale.currency(maxgross, grouping=True) + " for a net profit of " + locale.currency(maxnet, grouping=True) if (inventory.cups <= 0): msg += " You ran out of cups.๐Ÿฅค" @@ -545,7 +551,7 @@ def start_lemonade(nodeID, message, celsius=False): weeks.current = weeks.current + 1 - msg += f"\nPlay another week๐Ÿฅค 'end' to end game" + msg += f"\nPlay another week๐Ÿฅค? 'end' to end game" saveValues() return msg