This commit is contained in:
un1xx committed 2025-05-25 22:40:14 +05:30
1 parent 58fcd42961
commit b30bade32e
1 file changed
+346 -210
+346 -210
View File
@@ -5,6 +5,7 @@ import json
import os import os
import pprint import pprint
import random import random
import traceback
from typing import List, Literal, Optional from typing import List, Literal, Optional
import aiohttp import aiohttp
@@ -22,8 +23,6 @@ from utils.base import BasicView
from utils.emojis import Emojis from utils.emojis import Emojis
from utils.paginator import Paginator from utils.paginator import Paginator
class BaseMul: class BaseMul:
money = 1000000 money = 1000000
food = 5000 food = 5000
@@ -78,12 +77,10 @@ class Banking(commands.Cog):
) )
self.WARCHEST_IDS = None self.WARCHEST_IDS = None
async def cog_load(self): async def cog_load(self):
"""Called when the cog is loaded.""" """Called when the cog is loaded."""
await self.fetch_warchest_ids() await self.fetch_warchest_ids()
async def fetch_warchest_ids(self): async def fetch_warchest_ids(self):
"""Fetch nation IDs from the warchest table.""" """Fetch nation IDs from the warchest table."""
try: try:
@@ -174,6 +171,7 @@ class Banking(commands.Cog):
) )
await i.message.edit(embed=e, view=None) await i.message.edit(embed=e, view=None)
self.stop() self.stop()
v = View(kit=self.kit) v = View(kit=self.kit)
v.author = ctx.message.author v.author = ctx.message.author
m = await ctx.send(embed=e, view=v) m = await ctx.send(embed=e, view=v)
@@ -282,7 +280,6 @@ class Banking(commands.Cog):
i += 1 i += 1
e.description += f"{i}. [{rd.get('name')}](https://politicsandwar.com/nation/id={rd.get('id')})\n" e.description += f"{i}. [{rd.get('name')}](https://politicsandwar.com/nation/id={rd.get('id')})\n"
total["money"] += max(0, rd.get("money")) total["money"] += max(0, rd.get("money"))
total["steel100"] += max(0, rd.get("steel100")) total["steel100"] += max(0, rd.get("steel100"))
total["steel40"] += max(0, rd.get("steel40")) total["steel40"] += max(0, rd.get("steel40"))
@@ -377,7 +374,9 @@ class Banking(commands.Cog):
logmsg += f"{rd.get('name')} <:tick:1275839665819353148>\n" logmsg += f"{rd.get('name')} <:tick:1275839665819353148>\n"
else: else:
pprint.pprint( pprint.pprint(
f"{rd.get('name')} (already filled)", stream=logstream, indent=3 f"{rd.get('name')} (already filled)",
stream=logstream,
indent=3,
) )
logmsg += f"{rd.get('name')} (already filled)\n" logmsg += f"{rd.get('name')} (already filled)\n"
e.description = logmsg e.description = logmsg
@@ -422,9 +421,7 @@ class Banking(commands.Cog):
if nation_names: if nation_names:
nation_names = nation_names.split(",") nation_names = nation_names.split(",")
result = await self.kit.query( result = await self.kit.query(
"nations", "nations", {"nation_name": nation_names}, "id"
{"nation_name": nation_names},
"id"
) )
for nation in result.nations: for nation in result.nations:
ids.append(nation.id) ids.append(nation.id)
@@ -532,12 +529,16 @@ class Banking(commands.Cog):
]: ]:
return await ctx.send("-# You are not in list of authorized users") return await ctx.send("-# You are not in list of authorized users")
alliances = {10177: "Man I Love Frogs", 10198: "Damn I Love Frogs"} alliances = {10177: "Man I Love Frogs", 10198: "Damn I Love Frogs"}
m_flag = (await self.kit.query( m_flag = (
"alliances", {"id": 10177, "first": 1}, "flag" (await self.kit.query("alliances", {"id": 10177, "first": 1}, "flag"))
)).alliances[0].flag .alliances[0]
d_flag = (await self.dkit.query( .flag
"alliances", {"id": 10198, "first": 1}, "flag" )
)).alliances[0].flag d_flag = (
(await self.dkit.query("alliances", {"id": 10198, "first": 1}, "flag"))
.alliances[0]
.flag
)
e = discord.Embed( e = discord.Embed(
timestamp=datetime.datetime.now(), timestamp=datetime.datetime.now(),
title=f"Transfer Resources (`EXPIRES IN` {format_dt(datetime.datetime.now() + datetime.timedelta(seconds=200), 'R')})", title=f"Transfer Resources (`EXPIRES IN` {format_dt(datetime.datetime.now() + datetime.timedelta(seconds=200), 'R')})",
@@ -547,7 +548,13 @@ class Banking(commands.Cog):
e.set_thumbnail(url=m_flag) e.set_thumbnail(url=m_flag)
class TransferView(BasicView): class TransferView(BasicView):
def __init__(self, timeout: float | None = 200, clear: bool | None = False, kit: pnwkit.QueryKit = None, dkit: pnwkit.QueryKit = None): def __init__(
self,
timeout: float | None = 200,
clear: bool | None = False,
kit: pnwkit.QueryKit = None,
dkit: pnwkit.QueryKit = None,
):
super().__init__(timeout=timeout, clear=clear) super().__init__(timeout=timeout, clear=clear)
self.alliance_id = None self.alliance_id = None
self.nation_id = None self.nation_id = None
@@ -587,15 +594,10 @@ class Banking(commands.Cog):
label="Resources", label="Resources",
style=discord.TextStyle.long, style=discord.TextStyle.long,
max_length=1024, max_length=1024,
placeholder=( placeholder=("money: 1000\n" "food: 1000\n" "... and so on"),
"money: 1000\n"
"food: 1000\n"
"... and so on"
),
required=True, required=True,
) )
def __init__(self, view: TransferView, kit: pnwkit.QueryKit): def __init__(self, view: TransferView, kit: pnwkit.QueryKit):
super().__init__(timeout=200) super().__init__(timeout=200)
self.view = view self.view = view
@@ -609,13 +611,13 @@ class Banking(commands.Cog):
nation = await self.kit.query( nation = await self.kit.query(
"nations", "nations",
{"id": int(inp), "first": 1}, {"id": int(inp), "first": 1},
"id, nation_name, leader_name, flag" "id, nation_name, leader_name, flag",
) )
else: else:
nation = await self.kit.query( nation = await self.kit.query(
"nations", "nations",
{"nation_name": inp, "first": 1}, {"nation_name": inp, "first": 1},
"id, nation_name, leader_name, flag" "id, nation_name, leader_name, flag",
) )
nation = nation.nations[0] nation = nation.nations[0]
rss = self.rss.value.split("\n") rss = self.rss.value.split("\n")
@@ -626,11 +628,10 @@ class Banking(commands.Cog):
else: else:
key, value = r.split(" ") key, value = r.split(" ")
key = key.strip().lower() key = key.strip().lower()
value = value.replace(',', '') value = value.replace(",", "")
value = int(denumerize.denumerize(value.upper())) value = int(denumerize.denumerize(value.upper()))
resources[key] = value resources[key] = value
e.description = ( e.description = (
"**Resources** \n" "**Resources** \n"
f"{Emojis.money} {resources.get('money', 0):,}\n" f"{Emojis.money} {resources.get('money', 0):,}\n"
@@ -660,27 +661,30 @@ class Banking(commands.Cog):
) )
self.view.nation_id = nation.id self.view.nation_id = nation.id
self.view.resources = { self.view.resources = {
"money" : resources.get('money', 0), "money": resources.get("money", 0),
"food" : resources.get('food', 0), "food": resources.get("food", 0),
"uranium" : resources.get('uranium', 0), "uranium": resources.get("uranium", 0),
"coal" : resources.get('coal', 0), "coal": resources.get("coal", 0),
"iron" : resources.get('iron', 0), "iron": resources.get("iron", 0),
"oil" : resources.get('oil', 0), "oil": resources.get("oil", 0),
"bauxite" : resources.get('bauxite', 0), "bauxite": resources.get("bauxite", 0),
"lead" : resources.get('lead', 0), "lead": resources.get("lead", 0),
"munitions" : resources.get('munitions', 0), "munitions": resources.get("munitions", 0),
"gasoline" : resources.get('gasoline', 0), "gasoline": resources.get("gasoline", 0),
"aluminum" : resources.get('aluminum', 0), "aluminum": resources.get("aluminum", 0),
"steel" : resources.get('steel', 0), "steel": resources.get("steel", 0),
} }
self.view.confirm.disabled = False self.view.confirm.disabled = False
self.view.transfer_to_nation.disabled = True self.view.transfer_to_nation.disabled = True
self.view.transfer_to_alliance.disabled = True self.view.transfer_to_alliance.disabled = True
self.view.change_alliance.disabled = True self.view.change_alliance.disabled = True
await i.message.edit(embed=e, view=self.view) await i.message.edit(embed=e, view=self.view)
await i.response.send_modal(NationModal(self, self.kit)) await i.response.send_modal(NationModal(self, self.kit))
@discord.ui.button(label="transfer to alliance", style=discord.ButtonStyle.blurple, row=1) @discord.ui.button(
label="transfer to alliance", style=discord.ButtonStyle.blurple, row=1
)
async def transfer_to_alliance(self, i: discord.Interaction, _): async def transfer_to_alliance(self, i: discord.Interaction, _):
class AllianceModal(discord.ui.Modal, title="Alliance Details"): class AllianceModal(discord.ui.Modal, title="Alliance Details"):
def __init__(self, view: TransferView, kit: pnwkit.QueryKit): def __init__(self, view: TransferView, kit: pnwkit.QueryKit):
@@ -699,11 +703,7 @@ class Banking(commands.Cog):
label="Resources", label="Resources",
style=discord.TextStyle.long, style=discord.TextStyle.long,
max_length=1024, max_length=1024,
placeholder=( placeholder=("money: 1000\n" "food: 1000\n" "... and so on"),
"money: 1000\n"
"food: 1000\n"
"... and so on"
),
required=True, required=True,
) )
@@ -715,13 +715,11 @@ class Banking(commands.Cog):
alliance = await self.kit.query( alliance = await self.kit.query(
"alliances", "alliances",
{"id": int(inp), "first": 1}, {"id": int(inp), "first": 1},
"id, name, flag" "id, name, flag",
) )
else: else:
alliance = await self.kit.query( alliance = await self.kit.query(
"alliances", "alliances", {"name": inp, "first": 1}, "id, name, flag"
{"name": inp, "first": 1},
"id, name, flag"
) )
alliance = alliance.alliances[0] alliance = alliance.alliances[0]
rss = self.rss.value.split("\n") rss = self.rss.value.split("\n")
@@ -732,7 +730,7 @@ class Banking(commands.Cog):
else: else:
key, value = r.split(" ") key, value = r.split(" ")
key = key.strip().lower() key = key.strip().lower()
value = value.replace(',', '') value = value.replace(",", "")
value = int(denumerize.denumerize(value.upper())) value = int(denumerize.denumerize(value.upper()))
resources[key] = value resources[key] = value
@@ -750,7 +748,6 @@ class Banking(commands.Cog):
f"{Emojis.gasoline} {resources.get('gasoline', 0):,}\n" f"{Emojis.gasoline} {resources.get('gasoline', 0):,}\n"
f"{Emojis.aluminum} {resources.get('aluminum', 0):,}\n" f"{Emojis.aluminum} {resources.get('aluminum', 0):,}\n"
f"{Emojis.steel} {resources.get('steel', 0):,}\n" f"{Emojis.steel} {resources.get('steel', 0):,}\n"
) )
e.set_image(url=alliance.flag) e.set_image(url=alliance.flag)
e.add_field( e.add_field(
@@ -759,28 +756,30 @@ class Banking(commands.Cog):
) )
self.view.alliance_id = alliance.id self.view.alliance_id = alliance.id
self.view.resources = { self.view.resources = {
"money" : resources.get('money', 0), "money": resources.get("money", 0),
"food" : resources.get('food', 0), "food": resources.get("food", 0),
"uranium" : resources.get('uranium', 0), "uranium": resources.get("uranium", 0),
"coal" : resources.get('coal', 0), "coal": resources.get("coal", 0),
"iron" : resources.get('iron', 0), "iron": resources.get("iron", 0),
"oil" : resources.get('oil', 0), "oil": resources.get("oil", 0),
"bauxite" : resources.get('bauxite', 0), "bauxite": resources.get("bauxite", 0),
"lead" : resources.get('lead', 0), "lead": resources.get("lead", 0),
"munitions" : resources.get('munitions', 0), "munitions": resources.get("munitions", 0),
"gasoline" : resources.get('gasoline', 0), "gasoline": resources.get("gasoline", 0),
"aluminum" : resources.get('aluminum', 0), "aluminum": resources.get("aluminum", 0),
"steel" : resources.get('steel', 0), "steel": resources.get("steel", 0),
} }
self.view.confirm.disabled = False self.view.confirm.disabled = False
self.view.transfer_to_nation.disabled = True self.view.transfer_to_nation.disabled = True
self.view.transfer_to_alliance.disabled = True self.view.transfer_to_alliance.disabled = True
self.view.change_alliance.disabled = True self.view.change_alliance.disabled = True
await i.message.edit(embed=e, view=self.view) await i.message.edit(embed=e, view=self.view)
await i.response.send_modal(AllianceModal(self, self.kit)) await i.response.send_modal(AllianceModal(self, self.kit))
@discord.ui.button(
@discord.ui.button(label="confirm", style=discord.ButtonStyle.blurple, disabled=True, row=2) label="confirm", style=discord.ButtonStyle.blurple, disabled=True, row=2
)
async def confirm(self, i: discord.Interaction, _): async def confirm(self, i: discord.Interaction, _):
kit = self.kit if self.sel_alliance == 10177 else self.dkit kit = self.kit if self.sel_alliance == 10177 else self.dkit
if self.nation_id: if self.nation_id:
@@ -839,7 +838,6 @@ class Banking(commands.Cog):
m = await ctx.send(embed=e, view=v) m = await ctx.send(embed=e, view=v)
v.message = m v.message = m
@commands.has_any_role("The Croak Council", "Government") @commands.has_any_role("The Croak Council", "Government")
@commands.command(aliases=["wca"]) @commands.command(aliases=["wca"])
async def wcadd(self, ctx: CustomCtx, ids: commands.Greedy[int]): async def wcadd(self, ctx: CustomCtx, ids: commands.Greedy[int]):
@@ -864,24 +862,17 @@ class Banking(commands.Cog):
async with self.bot.db_pool.acquire() as conn: async with self.bot.db_pool.acquire() as conn:
async with conn.transaction(): async with conn.transaction():
for nation in notin_list: for nation in notin_list:
await conn.execute( await conn.execute("INSERT INTO warchest (id) VALUES ($1)", nation)
"INSERT INTO warchest (id) VALUES ($1)",
nation
)
await ctx.send(f"> inserted nations in war refill list: {notin_list}") await ctx.send(f"> inserted nations in war refill list: {notin_list}")
await ctx.invoke(discord.utils.get(self.bot.commands, name='wclist')) await ctx.invoke(discord.utils.get(self.bot.commands, name="wclist"))
@commands.has_any_role("The Croak Council", "Government") @commands.has_any_role("The Croak Council", "Government")
@commands.command(aliases=["wcl"]) @commands.command(aliases=["wcl"])
async def wclist(self, ctx: CustomCtx): async def wclist(self, ctx: CustomCtx):
await self.fetch_warchest_ids() await self.fetch_warchest_ids()
result = await self.kit.query( result = await self.kit.query(
"nations", "nations", {"id": self.WARCHEST_IDS}, "id, nation_name"
{"id": self.WARCHEST_IDS},
"id, nation_name"
) )
i = 0 i = 0
content = "Nations in warchest refill list\n" content = "Nations in warchest refill list\n"
@@ -890,7 +881,6 @@ class Banking(commands.Cog):
content += f"{i:>3}. {nation.id} {nation.nation_name}\n" content += f"{i:>3}. {nation.id} {nation.nation_name}\n"
await ctx.cbsend(content=content) await ctx.cbsend(content=content)
@commands.has_any_role("The Croak Council", "Government") @commands.has_any_role("The Croak Council", "Government")
@commands.command(aliases=["wcr"]) @commands.command(aliases=["wcr"])
async def wcremove(self, ctx: commands.Context, ids: commands.Greedy[int]): async def wcremove(self, ctx: commands.Context, ids: commands.Greedy[int]):
@@ -910,39 +900,44 @@ class Banking(commands.Cog):
not_in_list.append(nation) not_in_list.append(nation)
if not_in_list: if not_in_list:
await ctx.send(f"> Nations not found in warchest refill list: `{not_in_list}`") await ctx.send(
f"> Nations not found in warchest refill list: `{not_in_list}`"
)
if removed_list: if removed_list:
async with self.bot.db_pool.acquire() as conn: async with self.bot.db_pool.acquire() as conn:
async with conn.transaction(): async with conn.transaction():
for nation in removed_list: for nation in removed_list:
await conn.execute( await conn.execute(
"DELETE FROM warchest WHERE id = ($1)", "DELETE FROM warchest WHERE id = ($1)", nation
nation
) )
await ctx.send(f"> Removed nations from warchest refill list: `{removed_list}`") await ctx.send(
await ctx.invoke(discord.utils.get(self.bot.commands, name='wclist')) f"> Removed nations from warchest refill list: `{removed_list}`"
)
await ctx.invoke(discord.utils.get(self.bot.commands, name="wclist"))
else: else:
await ctx.send("> None of the provided nations were in the warchest refill list.") await ctx.send(
"> None of the provided nations were in the warchest refill list."
)
@commands.has_any_role("The Croak Council", "Government") @commands.has_any_role("The Croak Council", "Government")
@commands.command(aliases=["refill"]) @commands.command(aliases=["refill"])
async def resource_refill(self, ctx: commands.Context, ids: commands.Greedy[int]): async def resource_refill(self, ctx: CustomCtx, ids: commands.Greedy[int]):
""" """
Revenue calculation from nations by fetching cities and projects. Revenue calculation from nations by fetching cities and projects.
""" """
data = await self.kit.query( data = await self.kit.query(
"alliances", "alliances",
{"id": [10198]}, {"id": [10198]},
"id, nations {id, nation_name, continent, color, war_policy, domestic_policy, beige_turns, num_cities, soldiers, tanks" \ "id, nations {id, nation_name, continent, color, war_policy, domestic_policy, beige_turns, num_cities, soldiers, tanks"
", aircraft, ships, missiles, nukes, spies, wars { date, turnsleft, attid, winner }, coal, oil, uranium, iron, bauxite, lead, " \ ", aircraft, ships, missiles, nukes, spies, wars { date, turnsleft, attid, winner }, coal, oil, uranium, iron, bauxite, lead, "
"money, food, steel, gasoline, munitions, aluminum, iron_works, bauxite_works, arms_stockpile, emergency_gasoline_reserve, " \ "money, food, steel, gasoline, munitions, aluminum, iron_works, bauxite_works, arms_stockpile, emergency_gasoline_reserve, "
"mass_irrigation, international_trade_center, telecommunications_satellite, recycling_initiative, green_technologies, " \ "mass_irrigation, international_trade_center, telecommunications_satellite, recycling_initiative, green_technologies, "
"clinical_research_center, specialized_police_training_program, uranium_enrichment_program, cities {infrastructure, " \ "clinical_research_center, specialized_police_training_program, uranium_enrichment_program, cities {infrastructure, "
"land, powered, date, name, coal_power, oil_power," \ "land, powered, date, name, coal_power, oil_power,"
"wind_power, nuclear_power, coal_mine, oil_well, uranium_mine, lead_mine, iron_mine, bauxite_mine, farm, oil_refinery," \ "wind_power, nuclear_power, coal_mine, oil_well, uranium_mine, lead_mine, iron_mine, bauxite_mine, farm, oil_refinery,"
"aluminum_refinery, munitions_factory, steel_mill, police_station, hospital, recycling_center, subway, supermarket," \ "aluminum_refinery, munitions_factory, steel_mill, police_station, hospital, recycling_center, subway, supermarket,"
"bank, shopping_mall, stadium, barracks, factory, hangar, drydock}}" "bank, shopping_mall, stadium, barracks, factory, hangar, drydock}}",
) )
nations = [] nations = []
@@ -970,14 +965,16 @@ class Banking(commands.Cog):
revenue = await self.calculate_revenue(message, nation, game_data) revenue = await self.calculate_revenue(message, nation, game_data)
revenue_data.append({ revenue_data.append(
'nation_id': nation.id, {
'nation_name': nation.nation_name, "nation_id": nation.id,
'revenue': revenue "nation_name": nation.nation_name,
}) "revenue": revenue,
}
)
except Exception as e: except Exception as e:
raise e await ctx.cbsend(f"{traceback.format_exc()}")
# Format and send the results # Format and send the results
await self.send_revenue_results(ctx, revenue_data) await self.send_revenue_results(ctx, revenue_data)
@@ -985,8 +982,18 @@ class Banking(commands.Cog):
except Exception as e: except Exception as e:
await ctx.send(f"> Error getting game data: {str(e)}") await ctx.send(f"> Error getting game data: {str(e)}")
async def revenue_calc(
async def revenue_calc(message: discord.Message, nation: dict, radiation: dict, treasures: dict, prices: dict, colors: dict, seasonal_mod: dict, build: str = None, single_city: bool = False, include_spies: bool = False) -> dict: message: discord.Message,
nation: dict,
radiation: dict,
treasures: dict,
prices: dict,
colors: dict,
seasonal_mod: dict,
build: str = None,
single_city: bool = False,
include_spies: bool = False,
) -> dict:
max_commerce = 100 max_commerce = 100
base_com = 0 base_com = 0
hos_dis_red = 2.5 hos_dis_red = 2.5
@@ -1022,7 +1029,6 @@ class Banking(commands.Cog):
treasure_text = "" treasure_text = ""
footer = "" footer = ""
if nation.iron_works == True: if nation.iron_works == True:
ste_mod = 1.36 ste_mod = 1.36
if nation.bauxite_works == True: if nation.bauxite_works == True:
@@ -1068,7 +1074,9 @@ class Banking(commands.Cog):
try: try:
build = json.loads(build) build = json.loads(build)
except json.JSONDecodeError: except json.JSONDecodeError:
await message.edit(content="Something is wrong with the build you sent!") await message.edit(
content="Something is wrong with the build you sent!"
)
return return
land = 0 land = 0
for city in nation.cities: for city in nation.cities:
@@ -1076,10 +1084,10 @@ class Banking(commands.Cog):
city = {} city = {}
for key, value in build.items(): for key, value in build.items():
city[key[4:]] = int(value) city[key[4:]] = int(value)
city.infrastructure = city.pop('a_needed') city.infrastructure = city.pop("a_needed")
city.land = round(land / nation.num_cities) city.land = round(land / nation.num_cities)
city.powered = True city.powered = True
city.date = nation.cities[math.ceil(nation.num_cities/2)]['date'] city.date = nation.cities[math.ceil(nation.num_cities / 2)]["date"]
nation.cities = [city] nation.cities = [city]
# print(city) # print(city)
@@ -1088,7 +1096,9 @@ class Banking(commands.Cog):
base_pop = city.infrastructure * 100 base_pop = city.infrastructure * 100
pollution = 0 pollution = 0
unpowered_infra = city.infrastructure unpowered_infra = city.infrastructure
for wind_plant in range(city.wind_power): #can add something about wasted slots for wind_plant in range(
city.wind_power
): # can add something about wasted slots
if unpowered_infra > 0: if unpowered_infra > 0:
unpowered_infra -= 250 unpowered_infra -= 250
power_upkeep += 42 power_upkeep += 42
@@ -1123,7 +1133,12 @@ class Banking(commands.Cog):
rss_upkeep += 5000 * city.uranium_mine * rss_upkeep_mod rss_upkeep += 5000 * city.uranium_mine * rss_upkeep_mod
pollution += 20 * city.uranium_mine pollution += 20 * city.uranium_mine
uranium += 3 * city.uranium_mine * (1 + ((0.5 * (city.uranium_mine - 1)) / (5 - 1))) * uranium_mod uranium += (
3
* city.uranium_mine
* (1 + ((0.5 * (city.uranium_mine - 1)) / (5 - 1)))
* uranium_mod
)
rss_upkeep += 1500 * city.lead_mine * rss_upkeep_mod rss_upkeep += 1500 * city.lead_mine * rss_upkeep_mod
pollution += 12 * city.lead_mine pollution += 12 * city.lead_mine
@@ -1135,11 +1150,25 @@ class Banking(commands.Cog):
rss_upkeep += 1600 * city.bauxite_mine * rss_upkeep_mod rss_upkeep += 1600 * city.bauxite_mine * rss_upkeep_mod
pollution += 12 * city.bauxite_mine pollution += 12 * city.bauxite_mine
bauxite += 3 * city.bauxite_mine * (1 + ((0.5 * (city.bauxite_mine - 1)) / (10 - 1))) bauxite += (
3
* city.bauxite_mine
* (1 + ((0.5 * (city.bauxite_mine - 1)) / (10 - 1)))
)
rss_upkeep += 300 * city.farm * rss_upkeep_mod ## seasonal modifiers and radiation rss_upkeep += (
300 * city.farm * rss_upkeep_mod
) ## seasonal modifiers and radiation
pollution += 2 * city.farm * farm_poll_mod pollution += 2 * city.farm * farm_poll_mod
food_prod = city.land/food_land_mod * city.farm * (1 + ((0.5 * (city.farm - 1)) / (20 - 1))) * seasonal_mod[nation.continent] * radiation[nation.continent] * 12 food_prod = (
city.land
/ food_land_mod
* city.farm
* (1 + ((0.5 * (city.farm - 1)) / (20 - 1)))
* seasonal_mod[nation.continent]
* radiation[nation.continent]
* 12
)
if food_prod < 0: if food_prod < 0:
food += 0 food += 0
else: else:
@@ -1149,24 +1178,69 @@ class Banking(commands.Cog):
if city.powered: if city.powered:
rss_upkeep += 4000 * city.oil_refinery * rss_upkeep_mod rss_upkeep += 4000 * city.oil_refinery * rss_upkeep_mod
pollution += 32 * city.oil_refinery * manu_poll_mod pollution += 32 * city.oil_refinery * manu_poll_mod
oil -= 3 * city.oil_refinery * (1 + ((0.5 * (city.oil_refinery - 1)) / (5 - 1))) * gas_mod oil -= (
gasoline += 6 * city.oil_refinery * (1 + ((0.5 * (city.oil_refinery - 1)) / (5 - 1))) * gas_mod 3
* city.oil_refinery
* (1 + ((0.5 * (city.oil_refinery - 1)) / (5 - 1)))
* gas_mod
)
gasoline += (
6
* city.oil_refinery
* (1 + ((0.5 * (city.oil_refinery - 1)) / (5 - 1)))
* gas_mod
)
rss_upkeep += 4000 * city.steel_mill * rss_upkeep_mod rss_upkeep += 4000 * city.steel_mill * rss_upkeep_mod
pollution += 40 * city.steel_mill * manu_poll_mod pollution += 40 * city.steel_mill * manu_poll_mod
iron -= 3 * city.steel_mill * (1 + ((0.5 * (city.steel_mill - 1)) / (5 - 1))) * ste_mod iron -= (
coal -= 3 * city.steel_mill * (1 + ((0.5 * (city.steel_mill - 1)) / (5 - 1))) * ste_mod 3
steel += 9 * city.steel_mill * (1 + ((0.5 * (city.steel_mill - 1)) / (5 - 1))) * ste_mod * city.steel_mill
* (1 + ((0.5 * (city.steel_mill - 1)) / (5 - 1)))
* ste_mod
)
coal -= (
3
* city.steel_mill
* (1 + ((0.5 * (city.steel_mill - 1)) / (5 - 1)))
* ste_mod
)
steel += (
9
* city.steel_mill
* (1 + ((0.5 * (city.steel_mill - 1)) / (5 - 1)))
* ste_mod
)
rss_upkeep += 2500 * city.aluminum_refinery * rss_upkeep_mod rss_upkeep += 2500 * city.aluminum_refinery * rss_upkeep_mod
pollution += 40 * city.aluminum_refinery * manu_poll_mod pollution += 40 * city.aluminum_refinery * manu_poll_mod
bauxite -= 3 * city.aluminum_refinery * (1 + ((0.5 * (city.aluminum_refinery - 1)) / (5 - 1))) * alu_mod bauxite -= (
aluminum += 9 * city.aluminum_refinery * (1 + ((0.5 * (city.aluminum_refinery - 1)) / (5 - 1))) * alu_mod 3
* city.aluminum_refinery
* (1 + ((0.5 * (city.aluminum_refinery - 1)) / (5 - 1)))
* alu_mod
)
aluminum += (
9
* city.aluminum_refinery
* (1 + ((0.5 * (city.aluminum_refinery - 1)) / (5 - 1)))
* alu_mod
)
rss_upkeep += 3500 * city.munitions_factory * rss_upkeep_mod rss_upkeep += 3500 * city.munitions_factory * rss_upkeep_mod
pollution += 32 * city.munitions_factory * manu_poll_mod pollution += 32 * city.munitions_factory * manu_poll_mod
lead -= 6 * city.munitions_factory * (1 + ((0.5 * (city.munitions_factory - 1)) / (5 - 1))) * mun_mod lead -= (
munitions += 18 * city.munitions_factory * (1 + ((0.5 * (city.munitions_factory - 1)) / (5 - 1))) * mun_mod 6
* city.munitions_factory
* (1 + ((0.5 * (city.munitions_factory - 1)) / (5 - 1)))
* mun_mod
)
munitions += (
18
* city.munitions_factory
* (1 + ((0.5 * (city.munitions_factory - 1)) / (5 - 1)))
* mun_mod
)
civil_upkeep += city.police_station * 750 civil_upkeep += city.police_station * 750
civil_upkeep += city.hospital * 1000 civil_upkeep += city.hospital * 1000
@@ -1207,13 +1281,20 @@ class Banking(commands.Cog):
police_stations = 0 police_stations = 0
hospitals = 0 hospitals = 0
crime_rate = ((103 - commerce)**2 + (city.infrastructure * 100))/(111111) - police_stations * pol_cri_red crime_rate = ((103 - commerce) ** 2 + (city.infrastructure * 100)) / (
111111
) - police_stations * pol_cri_red
city.real_crime_rate = crime_rate city.real_crime_rate = crime_rate
if crime_rate < 0: if crime_rate < 0:
crime_rate = 0 crime_rate = 0
city.crime_rate = crime_rate city.crime_rate = crime_rate
crime_deaths = ((crime_rate) / 10) * (100 * city.infrastructure) - 25 crime_deaths = ((crime_rate) / 10) * (100 * city.infrastructure) - 25
disease_rate = (((((base_pop / city.land)**2) * 0.01) - 25)/100) + (base_pop/100000) + pollution * 0.05 - hospitals * hos_dis_red disease_rate = (
(((((base_pop / city.land) ** 2) * 0.01) - 25) / 100)
+ (base_pop / 100000)
+ pollution * 0.05
- hospitals * hos_dis_red
)
city.real_disease_rate = disease_rate city.real_disease_rate = disease_rate
if disease_rate > 100: if disease_rate > 100:
disease_rate = 100 disease_rate = 100
@@ -1230,19 +1311,21 @@ class Banking(commands.Cog):
city_age = (datetime.datetime.utcnow() - city_date).days city_age = (datetime.datetime.utcnow() - city_date).days
if city_age == 0: if city_age == 0:
city_age = 1 city_age = 1
population = ((base_pop - disease_deaths - crime_deaths) * (1 + math.log(city_age)/15)) population = (base_pop - disease_deaths - crime_deaths) * (
1 + math.log(city_age) / 15
)
nationpop += population nationpop += population
money_income += (((commerce / 50) * 0.725) + 0.725) * population money_income += (((commerce / 50) * 0.725) + 0.725) * population
alliance_treasures = 0 alliance_treasures = 0
nation_treasure_bonus = 1 nation_treasure_bonus = 1
for treasure in treasures: for treasure in treasures:
if treasure['nation'] == None: if treasure["nation"] == None:
continue continue
if treasure['nation']['id'] == nation.id: if treasure["nation"]["id"] == nation.id:
nation_treasure_bonus += treasure['bonus'] / 100 nation_treasure_bonus += treasure["bonus"] / 100
if nation.alliance: if nation.alliance:
if treasure['nation']['alliance_id'] == nation.alliance_id: if treasure["nation"]["alliance_id"] == nation.alliance_id:
alliance_treasures += 1 alliance_treasures += 1
if alliance_treasures > 0: if alliance_treasures > 0:
nation_treasure_bonus += math.sqrt(alliance_treasures * 4) / 100 nation_treasure_bonus += math.sqrt(alliance_treasures * 4) / 100
@@ -1259,12 +1342,14 @@ class Banking(commands.Cog):
new_player_text = f"\n\nNew Player Bonus: ${round((new_player_bonus - 1) * money_income):,}" new_player_text = f"\n\nNew Player Bonus: ${round((new_player_bonus - 1) * money_income):,}"
if nation.dompolicy == "Open Markets": if nation.dompolicy == "Open Markets":
policy_bonus = 1.01 policy_bonus = 1.01
policy_bonus_text = f"\n\nOpen Markets Bonus: ${round(money_income * 0.01):,}" policy_bonus_text = (
f"\n\nOpen Markets Bonus: ${round(money_income * 0.01):,}"
)
at_war = False at_war = False
if not single_city: if not single_city:
for war in nation.wars: for war in nation.wars:
if war['turnsleft'] > 0: if war["turnsleft"] > 0:
at_war = True at_war = True
if include_spies: if include_spies:
military_upkeep += nation.spies * 2400 military_upkeep += nation.spies * 2400
@@ -1292,65 +1377,105 @@ class Banking(commands.Cog):
if nation.dompolicy == "Imperialism": if nation.dompolicy == "Imperialism":
mil_cost = 0.95 mil_cost = 0.95
policy_bonus_text = f"\n\nImperialism Bonus: ${round(military_upkeep * 0.05):,}" policy_bonus_text = (
f"\n\nImperialism Bonus: ${round(military_upkeep * 0.05):,}"
)
if food < 0: if food < 0:
starve_exp_text = f"\n\nPossible Starvation Penalty: ${round(money_income * policy_bonus * new_player_bonus * 0.33):,}*" starve_exp_text = f"\n\nPossible Starvation Penalty: ${round(money_income * policy_bonus * new_player_bonus * 0.33):,}*"
starve_money_text = f" (${round(money_income * policy_bonus * new_player_bonus * 0.67 + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep):,}*)" starve_money_text = f" (${round(money_income * policy_bonus * new_player_bonus * 0.67 + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep):,}*)"
starve_net_text = f" (${round(money_income * policy_bonus * new_player_bonus * 0.67 + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep + coal * prices['coal'] + oil * prices['oil'] + uranium * prices['uranium'] + lead * prices['lead'] + iron * prices['iron'] + bauxite * prices['bauxite'] + gasoline * prices['gasoline'] + munitions * prices['munitions'] + steel * prices['steel'] + aluminum * prices['aluminum'] + food * prices['food']):,}*)" starve_net_text = f" (${round(money_income * policy_bonus * new_player_bonus * 0.67 + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep + coal * prices['coal'] + oil * prices['oil'] + uranium * prices['uranium'] + lead * prices['lead'] + iron * prices['iron'] + bauxite * prices['bauxite'] + gasoline * prices['gasoline'] + munitions * prices['munitions'] + steel * prices['steel'] + aluminum * prices['aluminum'] + food * prices['food']):,}*)"
footer = "* The income if the nation is suffering from a starvation penalty" footer = "* The income if the nation is suffering from a starvation penalty"
max_infra = sorted(nation.cities, key=lambda k: k['infrastructure'], reverse=True)[0]['infrastructure'] max_infra = sorted(
nation.cities, key=lambda k: k["infrastructure"], reverse=True
)[0]["infrastructure"]
if single_city: if single_city:
rev_obj = nation.cities[0] rev_obj = nation.cities[0]
else: else:
rev_obj = {} rev_obj = {}
rev_obj['monetary_net_num'] = round(money_income * policy_bonus * new_player_bonus * nation_treasure_bonus + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep + coal * prices['coal'] + oil * prices['oil'] + uranium * prices['uranium'] + lead * prices['lead'] + iron * prices['iron'] + bauxite * prices['bauxite'] + gasoline * prices['gasoline'] + munitions * prices['munitions'] + steel * prices['steel'] + aluminum * prices['aluminum'] + food * prices['food']) rev_obj["monetary_net_num"] = round(
rev_obj['net_cash_num'] = round(money_income * policy_bonus * new_player_bonus * nation_treasure_bonus + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep) money_income * policy_bonus * new_player_bonus * nation_treasure_bonus
rev_obj['food'] = food + color_bonus
- power_upkeep
- rss_upkeep
- military_upkeep * mil_cost
- civil_upkeep
+ coal * prices["coal"]
+ oil * prices["oil"]
+ uranium * prices["uranium"]
+ lead * prices["lead"]
+ iron * prices["iron"]
+ bauxite * prices["bauxite"]
+ gasoline * prices["gasoline"]
+ munitions * prices["munitions"]
+ steel * prices["steel"]
+ aluminum * prices["aluminum"]
+ food * prices["food"]
)
rev_obj["net_cash_num"] = round(
money_income * policy_bonus * new_player_bonus * nation_treasure_bonus
+ color_bonus
- power_upkeep
- rss_upkeep
- military_upkeep * mil_cost
- civil_upkeep
)
rev_obj["food"] = food
if single_city and not build: if single_city and not build:
rev_obj['money'] = rev_obj['net_cash_num'] rev_obj["money"] = rev_obj["net_cash_num"]
rev_obj['net income'] = rev_obj['monetary_net_num'] rev_obj["net income"] = rev_obj["monetary_net_num"]
rev_obj['aluminum'] = aluminum rev_obj["aluminum"] = aluminum
rev_obj['bauxite'] = bauxite rev_obj["bauxite"] = bauxite
rev_obj['coal'] = coal rev_obj["coal"] = coal
rev_obj['gasoline'] = gasoline rev_obj["gasoline"] = gasoline
rev_obj['iron'] = iron rev_obj["iron"] = iron
rev_obj['lead'] = lead rev_obj["lead"] = lead
rev_obj['munitions'] = munitions rev_obj["munitions"] = munitions
rev_obj['oil'] = oil rev_obj["oil"] = oil
rev_obj['steel'] = steel rev_obj["steel"] = steel
rev_obj['uranium'] = uranium rev_obj["uranium"] = uranium
rev_obj['disease_rate'] = disease_rate rev_obj["disease_rate"] = disease_rate
rev_obj['crime_rate'] = crime_rate rev_obj["crime_rate"] = crime_rate
rev_obj['commerce'] = commerce rev_obj["commerce"] = commerce
rev_obj['pollution'] = pollution rev_obj["pollution"] = pollution
return rev_obj return rev_obj
else: else:
rev_obj['nation'] = nation rev_obj["nation"] = nation
rev_obj['footer'] = footer rev_obj["footer"] = footer
rev_obj['max_infra'] = max_infra rev_obj["max_infra"] = max_infra
rev_obj['avg_infra'] = round(total_infra / nation.num_cities) rev_obj["avg_infra"] = round(total_infra / nation.num_cities)
rev_obj['income_txt']=f"National Tax Revenue: ${round(money_income):,}{color_text}{new_player_text}{policy_bonus_text}{treasure_text}" rev_obj["income_txt"] = (
rev_obj['expenses_txt']=f"Power Plant Upkeep: ${round(power_upkeep):,}\n\nResource Prod. Upkeep: ${round(rss_upkeep):,}\n\nMilitary Upkeep: ${round(military_upkeep * mil_cost):,}\n\nCity Improvement Upkeep: ${round(civil_upkeep):,}{starve_exp_text}" f"National Tax Revenue: ${round(money_income):,}{color_text}{new_player_text}{policy_bonus_text}{treasure_text}"
rev_obj['net_rev_txt']=f"Coal: {round(coal):,}\nOil: {round(oil):,}\nUranium: {round(uranium):,}\nLead: {round(lead):,}\nIron: {round(iron):,}\nBauxite: {round(bauxite):,}\nGasoline: {round(gasoline):,}\nMunitions: {round(munitions):,}\nSteel: {round(steel):,}\nAluminum: {round(aluminum):,}\nFood: {round(food):,}\nMoney: ${round(money_income * policy_bonus * new_player_bonus * nation_treasure_bonus + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep):,}{starve_money_text}" )
rev_obj['mon_net_txt']=f"${round(money_income * policy_bonus * new_player_bonus * nation_treasure_bonus + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep + coal * prices['coal'] + oil * prices['oil'] + uranium * prices['uranium'] + lead * prices['lead'] + iron * prices['iron'] + bauxite * prices['bauxite'] + gasoline * prices['gasoline'] + munitions * prices['munitions'] + steel * prices['steel'] + aluminum * prices['aluminum'] + food * prices['food']):,}{starve_net_text}" rev_obj["expenses_txt"] = (
rev_obj['money_txt']=f"${round(money_income * policy_bonus * new_player_bonus * nation_treasure_bonus + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep):,}{starve_money_text}" f"Power Plant Upkeep: ${round(power_upkeep):,}\n\nResource Prod. Upkeep: ${round(rss_upkeep):,}\n\nMilitary Upkeep: ${round(military_upkeep * mil_cost):,}\n\nCity Improvement Upkeep: ${round(civil_upkeep):,}{starve_exp_text}"
)
rev_obj["net_rev_txt"] = (
f"Coal: {round(coal):,}\nOil: {round(oil):,}\nUranium: {round(uranium):,}\nLead: {round(lead):,}\nIron: {round(iron):,}\nBauxite: {round(bauxite):,}\nGasoline: {round(gasoline):,}\nMunitions: {round(munitions):,}\nSteel: {round(steel):,}\nAluminum: {round(aluminum):,}\nFood: {round(food):,}\nMoney: ${round(money_income * policy_bonus * new_player_bonus * nation_treasure_bonus + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep):,}{starve_money_text}"
)
rev_obj["mon_net_txt"] = (
f"${round(money_income * policy_bonus * new_player_bonus * nation_treasure_bonus + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep + coal * prices['coal'] + oil * prices['oil'] + uranium * prices['uranium'] + lead * prices['lead'] + iron * prices['iron'] + bauxite * prices['bauxite'] + gasoline * prices['gasoline'] + munitions * prices['munitions'] + steel * prices['steel'] + aluminum * prices['aluminum'] + food * prices['food']):,}{starve_net_text}"
)
rev_obj["money_txt"] = (
f"${round(money_income * policy_bonus * new_player_bonus * nation_treasure_bonus + color_bonus - power_upkeep - rss_upkeep - military_upkeep * mil_cost - civil_upkeep):,}{starve_money_text}"
)
return rev_obj return rev_obj
async def calculate_revenue(
async def calculate_revenue(self, message: discord.Message, nation: dict, game_data: dict) -> dict: self, message: discord.Message, nation: dict, game_data: dict
) -> dict:
"""Calculate revenue for a nation.""" """Calculate revenue for a nation."""
revenue = await self.revenue_calc( revenue = await self.revenue_calc(
nation=nation, nation=nation,
radiation=game_data['radiation'], radiation=game_data["radiation"],
treasures=game_data['treasures'], treasures=game_data["treasures"],
prices=game_data['prices'], prices=game_data["prices"],
colors=game_data['colors'], colors=game_data["colors"],
seasonal_mod=game_data['seasonal_mod'], seasonal_mod=game_data["seasonal_mod"],
build=None, build=None,
single_city=False, single_city=False,
include_spies = True include_spies=True,
) )
return revenue return revenue
@@ -1359,10 +1484,22 @@ class Banking(commands.Cog):
""" """
Fetch game-wide data needed for revenue calculations. Fetch game-wide data needed for revenue calculations.
""" """
trade_prices_query = await self.kit.query("tradeprices", {"page":1, "first":1}, "coal, oil, uranium, iron, bauxite, lead, gasoline, munitions, steel, aluminum, food") trade_prices_query = await self.kit.query(
"tradeprices",
{"page": 1, "first": 1},
"coal, oil, uranium, iron, bauxite, lead, gasoline, munitions, steel, aluminum, food",
)
colors_query = await self.kit.query("colors", {}, "color, turn_bonus") colors_query = await self.kit.query("colors", {}, "color, turn_bonus")
game_info_query = await self.kit.query("game_info", {}, "game_date, radiation {global, north_america, south_america, africa, europe, asia, australia, antarctica}") game_info_query = await self.kit.query(
treasures_query = await self.kit.query("treasures", {}, "name, bonus, spawn_date, nation_id, nation { alliance_id }") "game_info",
{},
"game_date, radiation {global, north_america, south_america, africa, europe, asia, australia, antarctica}",
)
treasures_query = await self.kit.query(
"treasures",
{},
"name, bonus, spawn_date, nation_id, nation { alliance_id }",
)
# color bloc bonus # color bloc bonus
colors = {} colors = {}
@@ -1378,58 +1515,56 @@ class Banking(commands.Cog):
"as": 1 - (rad.asia + rad.global_) / 1000, "as": 1 - (rad.asia + rad.global_) / 1000,
"af": 1 - (rad.africa + rad.global_) / 1000, "af": 1 - (rad.africa + rad.global_) / 1000,
"au": 1 - (rad.australia + rad.global_) / 1000, "au": 1 - (rad.australia + rad.global_) / 1000,
"an": 1 - (rad.antarctica + rad.global_)/1000 "an": 1 - (rad.antarctica + rad.global_) / 1000,
} }
# seasons # seasons
month = int(game_info_query.game_info.game_date.month) month = int(game_info_query.game_info.game_date.month)
seasonal_mod = {"na": 1, "sa": 1, "eu": 1, "as": 1, "af": 1, "au": 1, "an": 0.5} seasonal_mod = {"na": 1, "sa": 1, "eu": 1, "as": 1, "af": 1, "au": 1, "an": 0.5}
if month in [6, 7, 8]: if month in [6, 7, 8]:
seasonal_mod['na'] = 1.2 seasonal_mod["na"] = 1.2
seasonal_mod['as'] = 1.2 seasonal_mod["as"] = 1.2
seasonal_mod['eu'] = 1.2 seasonal_mod["eu"] = 1.2
seasonal_mod['sa'] = 0.8 seasonal_mod["sa"] = 0.8
seasonal_mod['af'] = 0.8 seasonal_mod["af"] = 0.8
seasonal_mod['au'] = 0.8 seasonal_mod["au"] = 0.8
elif month in [12, 1, 2]: elif month in [12, 1, 2]:
seasonal_mod['na'] = 0.8 seasonal_mod["na"] = 0.8
seasonal_mod['as'] = 0.8 seasonal_mod["as"] = 0.8
seasonal_mod['eu'] = 0.8 seasonal_mod["eu"] = 0.8
seasonal_mod['sa'] = 1.2 seasonal_mod["sa"] = 1.2
seasonal_mod['af'] = 1.2 seasonal_mod["af"] = 1.2
seasonal_mod['au'] = 1.2 seasonal_mod["au"] = 1.2
# market price # market price
prices_data = trade_prices_query.tradeprices[0] prices_data = trade_prices_query.tradeprices[0]
prices = { prices = {
'coal': prices_data.coal, "coal": prices_data.coal,
'oil' : prices_data.oil, "oil": prices_data.oil,
'uranium' : prices_data.uranium, "uranium": prices_data.uranium,
'iron' : prices_data.iron, "iron": prices_data.iron,
'bauxite' : prices_data.bauxite, "bauxite": prices_data.bauxite,
'lead' : prices_data.lead, "lead": prices_data.lead,
'gasoline' : prices_data.gasoline, "gasoline": prices_data.gasoline,
'munitions' : prices_data.munitions, "munitions": prices_data.munitions,
'steel' : prices_data.steel, "steel": prices_data.steel,
'aluminum' : prices_data.aluminum, "aluminum": prices_data.aluminum,
'food' : prices_data.food "food": prices_data.food,
} }
treasures = { treasures = {"name": [], "bonus": []}
'name': [], 'bonus':[]
}
treasures_data = treasures_query.treasures treasures_data = treasures_query.treasures
for treasure in treasures_data: for treasure in treasures_data:
if treasure.nation.alliance_id == 10177: if treasure.nation.alliance_id == 10177:
treasures['name'].append(treasure.name) treasures["name"].append(treasure.name)
treasures['bonus'].append(treasure.bonus) treasures["bonus"].append(treasure.bonus)
return { return {
'prices': prices, "prices": prices,
'treasures': treasures, "treasures": treasures,
'radiation': radiation, "radiation": radiation,
'seasonal_mod': seasonal_mod, "seasonal_mod": seasonal_mod,
'colors': colors "colors": colors,
} }
async def send_revenue_results(self, ctx: commands.Context, revenue_data: list): async def send_revenue_results(self, ctx: commands.Context, revenue_data: list):
@@ -1440,25 +1575,26 @@ class Banking(commands.Cog):
# Create embeds for each nation's revenue # Create embeds for each nation's revenue
embeds = [] embeds = []
for data in revenue_data: for data in revenue_data:
revenue = data['revenue'] revenue = data["revenue"]
e = discord.Embed( e = discord.Embed(
title=f"Revenue for {data['nation_name']}", title=f"Revenue for {data['nation_name']}",
color=ctx.author.color, color=ctx.author.color,
timestamp=datetime.datetime.utcnow() timestamp=datetime.datetime.utcnow(),
) )
e.add_field(name="Income", value=revenue['income_txt'], inline=False) e.add_field(name="Income", value=revenue["income_txt"], inline=False)
e.add_field(name="Expenses", value=revenue['expenses_txt'], inline=False) e.add_field(name="Expenses", value=revenue["expenses_txt"], inline=False)
e.add_field(name="Net Revenue", value=revenue['net_rev_txt'], inline=False) e.add_field(name="Net Revenue", value=revenue["net_rev_txt"], inline=False)
e.add_field(name="Monetary Net", value=revenue['mon_net_txt'], inline=False) e.add_field(name="Monetary Net", value=revenue["mon_net_txt"], inline=False)
if revenue['footer']: if revenue["footer"]:
e.set_footer(text=revenue['footer']) e.set_footer(text=revenue["footer"])
embeds.append(e) embeds.append(e)
# Paginate the results # Paginate the results
await ctx.paginate(pages=embeds) await ctx.paginate(pages=embeds)
async def setup(bot: Brahmos): async def setup(bot: Brahmos):
await bot.add_cog(Banking(bot)) await bot.add_cog(Banking(bot))