misc: changed how insurance command functions
This commit is contained in:
parent
dcad41e10e
commit
bbd0426d90
1 changed files with 49 additions and 90 deletions
139
galaxy/galaxy.py
139
galaxy/galaxy.py
|
@ -123,135 +123,94 @@ class Galaxy(commands.Cog):
|
||||||
"""Calculates insurance.
|
"""Calculates insurance.
|
||||||
Please only use the value of a ship (from ``/shipinfo``) to calculate insurance and **not** ship cost."""
|
Please only use the value of a ship (from ``/shipinfo``) to calculate insurance and **not** ship cost."""
|
||||||
|
|
||||||
|
async def _insurance(self, ship_class: str, cost: int):
|
||||||
|
"""This function does the actual math and configures the embed.
|
||||||
|
|
||||||
|
Attributes
|
||||||
|
-----------
|
||||||
|
ship_class: Required[:class:`str`]
|
||||||
|
The class of the ship whose insurance you're checking.
|
||||||
|
|
||||||
|
cost: Required[:class:`int`]
|
||||||
|
The cost of the ship you're checking."""
|
||||||
|
insurance_dict = {
|
||||||
|
"miner": 0.7,
|
||||||
|
"freighter": 0.65,
|
||||||
|
"frigate": 0.6,
|
||||||
|
"destroyer": 0.55,
|
||||||
|
"cruiser": 0.5,
|
||||||
|
"battlecruiser": 0.4,
|
||||||
|
"battleship": 0.35,
|
||||||
|
"dreadnought": 0.3,
|
||||||
|
"carrier": 0.3,
|
||||||
|
"super_capital": 0.25
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
insurance_dict[f'{ship_class}']
|
||||||
|
except KeyError:
|
||||||
|
raise ValueError("Received value is not a valid ship class!")
|
||||||
|
if ship_class == "super_capital":
|
||||||
|
humanized_class = ship_class.replace("_", " ").title()
|
||||||
|
else:
|
||||||
|
humanized_class = ship_class.capitalize()
|
||||||
|
insurance_amount = round(cost * insurance_dict[f'{ship_class}'])
|
||||||
|
output = (f'{insurance_amount:,}')
|
||||||
|
cost_output = (f'{cost:,}')
|
||||||
|
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
||||||
|
embed.add_field(name="Ship Class", value=f"{humanized_class}", inline=False)
|
||||||
|
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
||||||
|
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
||||||
|
return embed
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def miner(self, ctx: commands.Context, cost: int):
|
async def miner(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for miners. (70%)"""
|
"""Calculates insurance for miners. (70%)"""
|
||||||
insurance_amount = round(cost * 0.7)
|
await ctx.send(embed=await self._insurance('miner', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Miner"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def freighter(self, ctx: commands.Context, cost: int):
|
async def freighter(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for freighters. (65%)"""
|
"""Calculates insurance for freighters. (65%)"""
|
||||||
insurance_amount = round(cost * 0.65)
|
await ctx.send(embed=await self._insurance('freighter', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Freighter"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def frigate(self, ctx: commands.Context, cost: int):
|
async def frigate(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for frigates. (60%)"""
|
"""Calculates insurance for frigates. (60%)"""
|
||||||
insurance_amount = round(cost * 0.6)
|
await ctx.send(embed=await self._insurance('frigate', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Frigate"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def destroyer(self, ctx: commands.Context, cost: int):
|
async def destroyer(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for destroyers. (55%)"""
|
"""Calculates insurance for destroyers. (55%)"""
|
||||||
insurance_amount = round(cost * 0.55)
|
await ctx.send(embed=await self._insurance('destroyer', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Destroyer"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def cruiser(self, ctx: commands.Context, cost: int):
|
async def cruiser(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for cruisers. (50%)"""
|
"""Calculates insurance for cruisers. (50%)"""
|
||||||
insurance_amount = round(cost * 0.5)
|
await ctx.send(embed=await self._insurance('cruiser', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Cruiser"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def battlecruiser(self, ctx: commands.Context, cost: int):
|
async def battlecruiser(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for battlecruisers. (40%)"""
|
"""Calculates insurance for battlecruisers. (40%)"""
|
||||||
insurance_amount = round(cost * 0.4)
|
await ctx.send(embed=await self._insurance('battlecruiser', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Battlecruiser"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def battleship(self, ctx: commands.Context, cost: int):
|
async def battleship(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for battleships. (35%)"""
|
"""Calculates insurance for battleships. (35%)"""
|
||||||
insurance_amount = round(cost * 0.35)
|
await ctx.send(embed=await self._insurance('battleship', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Battleship"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def dreadnought(self, ctx: commands.Context, cost: int):
|
async def dreadnought(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for dreadnoughts. (30%)"""
|
"""Calculates insurance for dreadnoughts. (30%)"""
|
||||||
insurance_amount = round(cost * 0.3)
|
await ctx.send(embed=await self._insurance('dreadnought', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Dreadnought"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def carrier(self, ctx: commands.Context, cost: int):
|
async def carrier(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for carriers. (30%)"""
|
"""Calculates insurance for carriers. (30%)"""
|
||||||
insurance_amount = round(cost * 0.3)
|
await ctx.send(embed=await self._insurance('carrier', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Carrier"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@insurance.command()
|
@insurance.command()
|
||||||
async def supercapital(self, ctx: commands.Context, cost: int):
|
async def supercapital(self, ctx: commands.Context, cost: int):
|
||||||
"""Calculates insurance for super capitals. (25%)"""
|
"""Calculates insurance for super capitals. (25%)"""
|
||||||
insurance_amount = round(cost * 0.25)
|
await ctx.send(embed=await self._insurance('super_capital', cost))
|
||||||
output = (f'{insurance_amount:,}')
|
|
||||||
cost_output = (f'{cost:,}')
|
|
||||||
ship_class = "Super Capital"
|
|
||||||
embed = discord.Embed(title="Insurance Cost", color=await self.bot.get_embed_color(None))
|
|
||||||
embed.add_field(name="Ship Class", value=f"{ship_class}", inline=False)
|
|
||||||
embed.add_field(name="Ship Cost", value=f"{cost_output}", inline=False)
|
|
||||||
embed.add_field(name="Insurance Amount", value=f"{output}", inline=False)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@commands.command(aliases=["wh"])
|
@commands.command(aliases=["wh"])
|
||||||
async def warehouse(self, ctx: commands.Context, lvlfrom: int = 1, lvlto: int = 38):
|
async def warehouse(self, ctx: commands.Context, lvlfrom: int = 1, lvlto: int = 38):
|
||||||
|
|
Loading…
Reference in a new issue