Skip to content

Commit

Permalink
add price to food
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiDuncan committed Dec 13, 2023
1 parent ab470b9 commit 46ae186
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sizebot/cogs/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,12 @@ async def food(self, ctx, food: typing.Union[DigiObject, str], *, who: typing.Un

days_per_food = food.calories / cals_needed
food_per_day = 1 / days_per_food
cost = food.price * food_per_day if food.price else None

if food_per_day >= 1:
foodout = f"{userdata.nickname} would need to eat **{food_per_day:,.1} {food.name_plural}** per day.\n(1 {food.name} is {food.calories} calories.)"
if cost:
foodout += "\nThat would cost **${cost:,.2}**."
else:
foodout = f"A {food.name} ({food.calories} calories) would last {userdata.nickname} **{prettyTimeDelta(86400 * days_per_food, roundeventually=True)}.**"

Expand Down
29 changes: 29 additions & 0 deletions sizebot/data/objects/food.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"width": "0.0127",
"thickness": "0.0127",
"calories": "3.7",
"price": "0.15",
"weight": "0.55",
"tags": [
"food"
Expand All @@ -131,6 +132,7 @@
"length": "0.0254",
"diameter": "0.0127",
"calories": "23",
"price": "0.056",
"weight": "6",
"tags": [
"food"
Expand All @@ -143,6 +145,7 @@
"width": "0.018",
"depth": "0.0075",
"calories": "10.7",
"price": "0.028",
"weight": "1.75",
"tags": [
"food"
Expand All @@ -157,6 +160,7 @@
"dimension": "d",
"diameter": "0.04",
"calories": "87",
"price": "0.695",
"weight": "21.8",
"tags": [
"food"
Expand All @@ -173,6 +177,7 @@
"height": "0.009",
"diameter": "0.04445",
"calories": "160",
"price": "0.0883",
"weight": "11.3",
"tags": [
"food"
Expand All @@ -187,6 +192,7 @@
"height": "0.045",
"diameter": "0.2275",
"calories": "131",
"price": "2",
"weight": "80",
"tags": [
"food"
Expand All @@ -202,6 +208,7 @@
"width": "0.03",
"depth": "0.01",
"calories": "59",
"price": "0.50",
"weight": "16",
"tags": [
"food"
Expand All @@ -218,6 +225,7 @@
"diameter": "0.053",
"thickness": "0.003175",
"calories": "10",
"price": "0.182",
"weight": "12",
"tags": [
"food"
Expand All @@ -228,6 +236,7 @@
"dimension": "h",
"height": "0.05312",
"calories": "78",
"price": "0.17",
"weight": "48.1942",
"tags": [
"food"
Expand All @@ -241,6 +250,7 @@
"dimension": "d",
"diameter": "0.0725",
"calories": "45",
"price": "0.95",
"weight": "88",
"tags": [
"food"
Expand All @@ -253,6 +263,7 @@
"width": "0.022225",
"thickness": "0.00238125",
"calories": "11",
"price": "0.095",
"weight": "2.9",
"tags": [
"food"
Expand All @@ -267,6 +278,7 @@
"dimension": "h",
"height": "0.075",
"calories": "95",
"price": "0.69",
"weight": "85",
"tags": [
"food"
Expand All @@ -279,6 +291,7 @@
"width": "0.0899",
"thickness": "0.003",
"calories": "113",
"price": "0.226",
"weight": "17",
"tags": [
"food"
Expand All @@ -293,6 +306,7 @@
"height": "0.06985",
"diameter": "0.09525",
"calories": "563",
"price": "0.27",
"weight": "215.456",
"tags": [
"food"
Expand All @@ -309,6 +323,7 @@
"dimension": "l",
"length": "0.10541",
"calories": "218",
"price": "1.99",
"weight": "42.5",
"tags": [
"food"
Expand All @@ -324,6 +339,7 @@
"width": "0.06",
"depth": "0.04",
"calories": "85",
"price": "0.31",
"weight": "170.097",
"tags": [
"food"
Expand All @@ -339,6 +355,7 @@
"height": "0.11",
"diameter": "0.0953",
"calories": "163",
"price": "0.10",
"weight": "320",
"tags": [
"food"
Expand All @@ -353,6 +370,7 @@
"length": "0.1143",
"width": "0.0762",
"calories": "200",
"price": "0.3275",
"weight": "47.9815679",
"tags": [
"food"
Expand All @@ -368,6 +386,7 @@
"height": "0.0635",
"diameter": "0.12065",
"calories": "677",
"price": "3",
"weight": "300.5049",
"tags": [
"food"
Expand All @@ -379,6 +398,7 @@
"height": "0.122",
"diameter": "0.058",
"calories": "140",
"price": "0.55",
"weight": "355",
"tags": [
"food"
Expand All @@ -396,6 +416,7 @@
"length": "0.127",
"depth": "0.047625",
"calories": "156",
"price": "1.79",
"weight": "99.2233",
"tags": [
"food"
Expand All @@ -408,6 +429,7 @@
"width": "0.09525",
"depth": "0.01905",
"calories": "310",
"price": "1.49",
"weight": "127",
"tags": [
"food"
Expand All @@ -419,6 +441,7 @@
"length": "0.15",
"diameter": "0.0254",
"calories": "102",
"price": "0.75",
"weight": "28.35",
"tags": [
"food"
Expand All @@ -432,6 +455,7 @@
"dimension": "l",
"length": "0.1905",
"calories": "105",
"price": "0.27",
"weight": "120",
"tags": [
"food"
Expand All @@ -446,6 +470,7 @@
"dimension": "l",
"length": "0.2",
"calories": "234",
"price": "0.88",
"weight": "500",
"tags": [
"food"
Expand All @@ -457,6 +482,7 @@
"height": "0.21",
"diameter": "0.085",
"calories": "0",
"price": "1.25",
"weight": "793.787",
"tags": [
"food"
Expand All @@ -474,6 +500,7 @@
"dimension": "d",
"diameter": "0.3",
"calories": "1680",
"price": "8",
"weight": "726",
"tags": [
"food"
Expand All @@ -492,6 +519,7 @@
"height": "0.3",
"diameter": "0.08",
"calories": "980",
"price": "2.24",
"weight": "149",
"tags": [
"food"
Expand All @@ -508,6 +536,7 @@
"dimension": "l",
"length": "0.3048",
"calories": "620",
"price": "5",
"weight": "907.185",
"tags": [
"food"
Expand Down
10 changes: 9 additions & 1 deletion sizebot/lib/objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@total_ordering
class DigiObject:
def __init__(self, name, dimension, aliases=[], tags=[], symbol = None, height = None, length = None,
width = None, diameter = None, depth = None, thickness = None, calories = None,
width = None, diameter = None, depth = None, thickness = None, calories = None, price = None,
weight = None, note = None):

self.name = name
Expand All @@ -47,6 +47,7 @@ def __init__(self, name, dimension, aliases=[], tags=[], symbol = None, height =
self.depth = depth and SV(depth)
self.thickness = thickness and SV(thickness)
self.calories = SV(calories) if calories is not None else None
self.price = Decimal(price) if price is not None else None
self.weight = weight and WV(weight)

dimensionmap = {
Expand Down Expand Up @@ -93,6 +94,8 @@ def get_stats(self, multiplier = 1):
returnstr += f"{emojis.blank}**{SV(self.thickness * multiplier):,.3mu}** thick\n"
if self.calories is not None:
returnstr += f"{emojis.blank}has **{Decimal(self.calories * (multiplier ** 3)):,.3}** calories\n"
if self.price is not None:
returnstr += f"{emojis.blank}costs **${Decimal(self.price * (multiplier ** 3)):,.2}**\n"
if self.weight:
returnstr += "and weighs...\n"
returnstr += f"{emojis.blank}**{WV(self.weight * (multiplier ** 3)):,.3mu}**"
Expand All @@ -114,6 +117,8 @@ def get_stats_sentence(self, multiplier = 1, system: Literal["m", "u"] = "m"):
statsstrings.append(f"**{SV(self.thickness * multiplier):,.3{system}}** thick")
if self.calories is not None:
statsstrings.append(f"has **{Decimal(self.calories * (multiplier ** 3)):,.3}** calories")
if self.price is not None:
statsstrings.append(f"costs **${Decimal(self.price * (multiplier ** 3)):,.2}**")
if self.weight:
statsstrings.append(f"weighs **{WV(self.weight * multiplier ** 3):,.3{system}}**")

Expand Down Expand Up @@ -146,6 +151,9 @@ def get_stats_embed(self, multiplier = 1):
if self.calories is not None:
embed.add_field(name = "Calories",
value = f"has **{Decimal(self.calories * (multiplier **3)):,.3}** calories\n")
if self.price is not None:
embed.add_field(name = "Price",
value = f"costs **${Decimal(self.price * (multiplier ** 3)):,.2}**")
if self.weight:
embed.add_field(name = "Weight",
value = f"**{WV(self.weight * (multiplier ** 3)):,.3mu}**")
Expand Down

0 comments on commit 46ae186

Please sign in to comment.