|
|
@ -111,7 +111,6 @@ async def _withdraw_points(gardener: Gardener, amount):
|
|
|
|
|
|
|
|
|
|
|
|
if (gardener.points - amount) < 0:
|
|
|
|
if (gardener.points - amount) < 0:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
|
|
|
|
gardener.points -= amount
|
|
|
|
gardener.points -= amount
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
@ -245,11 +244,9 @@ class PlantTycoon(commands.Cog):
|
|
|
|
await self._load_plants_products()
|
|
|
|
await self._load_plants_products()
|
|
|
|
|
|
|
|
|
|
|
|
modifiers = sum(
|
|
|
|
modifiers = sum(
|
|
|
|
[
|
|
|
|
|
|
|
|
self.products[product]["modifier"]
|
|
|
|
self.products[product]["modifier"]
|
|
|
|
for product in gardener.products
|
|
|
|
for product in gardener.products
|
|
|
|
if gardener.products[product] > 0
|
|
|
|
if gardener.products[product] > 0
|
|
|
|
]
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
degradation = (
|
|
|
|
degradation = (
|
|
|
@ -290,17 +287,15 @@ class PlantTycoon(commands.Cog):
|
|
|
|
product = product.lower()
|
|
|
|
product = product.lower()
|
|
|
|
product_category = product_category.lower()
|
|
|
|
product_category = product_category.lower()
|
|
|
|
if product in self.products and self.products[product]["category"] == product_category:
|
|
|
|
if product in self.products and self.products[product]["category"] == product_category:
|
|
|
|
if product in gardener.products:
|
|
|
|
if product in gardener.products and gardener.products[product] > 0:
|
|
|
|
if gardener.products[product] > 0:
|
|
|
|
|
|
|
|
gardener.current["health"] += self.products[product]["health"]
|
|
|
|
gardener.current["health"] += self.products[product]["health"]
|
|
|
|
gardener.products[product] -= 1
|
|
|
|
gardener.products[product] -= 1
|
|
|
|
if gardener.products[product] == 0:
|
|
|
|
if gardener.products[product] == 0:
|
|
|
|
del gardener.products[product.lower()]
|
|
|
|
del gardener.products[product.lower()]
|
|
|
|
if product_category == "water":
|
|
|
|
if product_category == "fertilizer":
|
|
|
|
emoji = ":sweat_drops:"
|
|
|
|
|
|
|
|
elif product_category == "fertilizer":
|
|
|
|
|
|
|
|
emoji = ":poop:"
|
|
|
|
emoji = ":poop:"
|
|
|
|
# elif product_category == "tool":
|
|
|
|
elif product_category == "water":
|
|
|
|
|
|
|
|
emoji = ":sweat_drops:"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
emoji = ":scissors:"
|
|
|
|
emoji = ":scissors:"
|
|
|
|
message = "Your plant got some health back! {}".format(emoji)
|
|
|
|
message = "Your plant got some health back! {}".format(emoji)
|
|
|
@ -310,18 +305,13 @@ class PlantTycoon(commands.Cog):
|
|
|
|
damage_msg = "You used {} too many times!".format(product)
|
|
|
|
damage_msg = "You used {} too many times!".format(product)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
damage_msg = "You gave too much of {}.".format(product)
|
|
|
|
damage_msg = "You gave too much of {}.".format(product)
|
|
|
|
message = "{} Your plant lost some health. :wilted_rose:".format(
|
|
|
|
message = "{} Your plant lost some health. :wilted_rose:".format(damage_msg)
|
|
|
|
damage_msg
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
gardener.points += self.defaults["points"]["add_health"]
|
|
|
|
gardener.points += self.defaults["points"]["add_health"]
|
|
|
|
await gardener.save_gardener()
|
|
|
|
await gardener.save_gardener()
|
|
|
|
else:
|
|
|
|
elif product in gardener.products or product_category != "tool":
|
|
|
|
message = "You have no {}. Go buy some!".format(product)
|
|
|
|
message = "You have no {}. Go buy some!".format(product)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if product_category == "tool":
|
|
|
|
|
|
|
|
message = "You don't have a {}. Go buy one!".format(product)
|
|
|
|
message = "You don't have a {}. Go buy one!".format(product)
|
|
|
|
else:
|
|
|
|
|
|
|
|
message = "You have no {}. Go buy some!".format(product)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
message = "Are you sure you are using {}?".format(product_category)
|
|
|
|
message = "Are you sure you are using {}?".format(product_category)
|
|
|
|
|
|
|
|
|
|
|
@ -412,24 +402,18 @@ class PlantTycoon(commands.Cog):
|
|
|
|
gardener.current = plant
|
|
|
|
gardener.current = plant
|
|
|
|
await gardener.save_gardener()
|
|
|
|
await gardener.save_gardener()
|
|
|
|
|
|
|
|
|
|
|
|
em = discord.Embed(description=message, color=discord.Color.green())
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
plant = gardener.current
|
|
|
|
plant = gardener.current
|
|
|
|
message = "You're already growing {} **{}**, silly.".format(
|
|
|
|
message = "You're already growing {} **{}**, silly.".format(
|
|
|
|
plant["article"], plant["name"]
|
|
|
|
plant["article"], plant["name"]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
em = discord.Embed(description=message, color=discord.Color.green())
|
|
|
|
em = discord.Embed(description=message, color=discord.Color.green())
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.send(embed=em)
|
|
|
|
await ctx.send(embed=em)
|
|
|
|
|
|
|
|
|
|
|
|
@_gardening.command(name="profile")
|
|
|
|
@_gardening.command(name="profile")
|
|
|
|
async def _profile(self, ctx: commands.Context, *, member: discord.Member = None):
|
|
|
|
async def _profile(self, ctx: commands.Context, *, member: discord.Member = None):
|
|
|
|
"""Check your gardening profile."""
|
|
|
|
"""Check your gardening profile."""
|
|
|
|
if member is not None:
|
|
|
|
author = member if member is not None else ctx.author
|
|
|
|
author = member
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
author = ctx.author
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gardener = await self._gardener(author)
|
|
|
|
gardener = await self._gardener(author)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
await self._apply_degradation(gardener)
|
|
|
|
await self._apply_degradation(gardener)
|
|
|
@ -440,9 +424,7 @@ class PlantTycoon(commands.Cog):
|
|
|
|
avatar = author.avatar_url if author.avatar else author.default_avatar_url
|
|
|
|
avatar = author.avatar_url if author.avatar else author.default_avatar_url
|
|
|
|
em.set_author(name="Gardening profile of {}".format(author.name), icon_url=avatar)
|
|
|
|
em.set_author(name="Gardening profile of {}".format(author.name), icon_url=avatar)
|
|
|
|
em.add_field(name="**Thneeds**", value=str(gardener.points))
|
|
|
|
em.add_field(name="**Thneeds**", value=str(gardener.points))
|
|
|
|
if not gardener.current:
|
|
|
|
if gardener.current:
|
|
|
|
em.add_field(name="**Currently growing**", value="None")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
em.set_thumbnail(url=gardener.current["image"])
|
|
|
|
em.set_thumbnail(url=gardener.current["image"])
|
|
|
|
em.add_field(
|
|
|
|
em.add_field(
|
|
|
|
name="**Currently growing**",
|
|
|
|
name="**Currently growing**",
|
|
|
@ -450,16 +432,15 @@ class PlantTycoon(commands.Cog):
|
|
|
|
gardener.current["name"], gardener.current["health"]
|
|
|
|
gardener.current["name"], gardener.current["health"]
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
em.add_field(name="**Currently growing**", value="None")
|
|
|
|
if not gardener.badges:
|
|
|
|
if not gardener.badges:
|
|
|
|
em.add_field(name="**Badges**", value="None")
|
|
|
|
em.add_field(name="**Badges**", value="None")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
badges = ""
|
|
|
|
badges = "".join("{}\n".format(badge.capitalize()) for badge in gardener.badges)
|
|
|
|
for badge in gardener.badges:
|
|
|
|
|
|
|
|
badges += "{}\n".format(badge.capitalize())
|
|
|
|
|
|
|
|
em.add_field(name="**Badges**", value=badges)
|
|
|
|
em.add_field(name="**Badges**", value=badges)
|
|
|
|
if not gardener.products:
|
|
|
|
if gardener.products:
|
|
|
|
em.add_field(name="**Products**", value="None")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
products = ""
|
|
|
|
products = ""
|
|
|
|
for product_name, product_data in gardener.products.items():
|
|
|
|
for product_name, product_data in gardener.products.items():
|
|
|
|
if self.products[product_name] is None:
|
|
|
|
if self.products[product_name] is None:
|
|
|
@ -470,6 +451,8 @@ class PlantTycoon(commands.Cog):
|
|
|
|
self.products[product_name]["modifier"],
|
|
|
|
self.products[product_name]["modifier"],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
em.add_field(name="**Products**", value=products)
|
|
|
|
em.add_field(name="**Products**", value=products)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
em.add_field(name="**Products**", value="None")
|
|
|
|
if gardener.current:
|
|
|
|
if gardener.current:
|
|
|
|
degradation = await self._degradation(gardener)
|
|
|
|
degradation = await self._degradation(gardener)
|
|
|
|
die_in = await _die_in(gardener, degradation)
|
|
|
|
die_in = await _die_in(gardener, degradation)
|
|
|
@ -600,7 +583,6 @@ class PlantTycoon(commands.Cog):
|
|
|
|
self.products[pd]["category"],
|
|
|
|
self.products[pd]["category"],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
await ctx.send(embed=em)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if amount <= 0:
|
|
|
|
if amount <= 0:
|
|
|
|
message = "Invalid amount! Must be greater than 1"
|
|
|
|
message = "Invalid amount! Must be greater than 1"
|
|
|
@ -629,6 +611,7 @@ class PlantTycoon(commands.Cog):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
message = "I don't have this product."
|
|
|
|
message = "I don't have this product."
|
|
|
|
em = discord.Embed(description=message, color=discord.Color.green())
|
|
|
|
em = discord.Embed(description=message, color=discord.Color.green())
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.send(embed=em)
|
|
|
|
await ctx.send(embed=em)
|
|
|
|
|
|
|
|
|
|
|
|
@_gardening.command(name="convert")
|
|
|
|
@_gardening.command(name="convert")
|
|
|
@ -663,8 +646,7 @@ class PlantTycoon(commands.Cog):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
gardener.current = {}
|
|
|
|
gardener.current = {}
|
|
|
|
message = "You successfully shovelled your plant out."
|
|
|
|
message = "You successfully shovelled your plant out."
|
|
|
|
if gardener.points < 0:
|
|
|
|
gardener.points = max(gardener.points, 0)
|
|
|
|
gardener.points = 0
|
|
|
|
|
|
|
|
await gardener.save_gardener()
|
|
|
|
await gardener.save_gardener()
|
|
|
|
|
|
|
|
|
|
|
|
em = discord.Embed(description=message, color=discord.Color.dark_grey())
|
|
|
|
em = discord.Embed(description=message, color=discord.Color.dark_grey())
|
|
|
@ -681,12 +663,12 @@ class PlantTycoon(commands.Cog):
|
|
|
|
except discord.Forbidden:
|
|
|
|
except discord.Forbidden:
|
|
|
|
# Couldn't DM the degradation
|
|
|
|
# Couldn't DM the degradation
|
|
|
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
|
|
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
|
|
|
product = "water"
|
|
|
|
|
|
|
|
product_category = "water"
|
|
|
|
|
|
|
|
if not gardener.current:
|
|
|
|
if not gardener.current:
|
|
|
|
message = "You're currently not growing a plant."
|
|
|
|
message = "You're currently not growing a plant."
|
|
|
|
await _send_message(channel, message)
|
|
|
|
await _send_message(channel, message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
product = "water"
|
|
|
|
|
|
|
|
product_category = "water"
|
|
|
|
await self._add_health(channel, gardener, product, product_category)
|
|
|
|
await self._add_health(channel, gardener, product, product_category)
|
|
|
|
|
|
|
|
|
|
|
|
@commands.command(name="fertilize")
|
|
|
|
@commands.command(name="fertilize")
|
|
|
@ -700,11 +682,11 @@ class PlantTycoon(commands.Cog):
|
|
|
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
|
|
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
|
|
|
channel = ctx.channel
|
|
|
|
channel = ctx.channel
|
|
|
|
product = fertilizer
|
|
|
|
product = fertilizer
|
|
|
|
product_category = "fertilizer"
|
|
|
|
|
|
|
|
if not gardener.current:
|
|
|
|
if not gardener.current:
|
|
|
|
message = "You're currently not growing a plant."
|
|
|
|
message = "You're currently not growing a plant."
|
|
|
|
await _send_message(channel, message)
|
|
|
|
await _send_message(channel, message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
product_category = "fertilizer"
|
|
|
|
await self._add_health(channel, gardener, product, product_category)
|
|
|
|
await self._add_health(channel, gardener, product, product_category)
|
|
|
|
|
|
|
|
|
|
|
|
@commands.command(name="prune")
|
|
|
|
@commands.command(name="prune")
|
|
|
@ -717,12 +699,12 @@ class PlantTycoon(commands.Cog):
|
|
|
|
# Couldn't DM the degradation
|
|
|
|
# Couldn't DM the degradation
|
|
|
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
|
|
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
|
|
|
channel = ctx.channel
|
|
|
|
channel = ctx.channel
|
|
|
|
product = "pruner"
|
|
|
|
|
|
|
|
product_category = "tool"
|
|
|
|
|
|
|
|
if not gardener.current:
|
|
|
|
if not gardener.current:
|
|
|
|
message = "You're currently not growing a plant."
|
|
|
|
message = "You're currently not growing a plant."
|
|
|
|
await _send_message(channel, message)
|
|
|
|
await _send_message(channel, message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
product = "pruner"
|
|
|
|
|
|
|
|
product_category = "tool"
|
|
|
|
await self._add_health(channel, gardener, product, product_category)
|
|
|
|
await self._add_health(channel, gardener, product, product_category)
|
|
|
|
|
|
|
|
|
|
|
|
# async def check_degradation(self):
|
|
|
|
# async def check_degradation(self):
|
|
|
|