diff --git a/exts/banking.py b/exts/banking.py index 4210e08..012de61 100644 --- a/exts/banking.py +++ b/exts/banking.py @@ -23,6 +23,7 @@ from utils.base import BasicView from utils.emojis import Emojis from utils.paginator import Paginator + class BaseMul: money = 1000000 food = 5000 @@ -921,14 +922,22 @@ class Banking(commands.Cog): ) @commands.has_any_role("The Croak Council", "Government") - @commands.command(aliases=["refill"]) - async def resource_refill(self, ctx: CustomCtx, ids: commands.Greedy[int]): + @commands.command() + async def raws(self, ctx: CustomCtx, ids: commands.Greedy[int]): """ Revenue calculation from nations by fetching cities and projects. """ - data = await self.kit.query( - "alliances", - {"id": [10198, 10177]}, + try: + revenue_data = await self.get_alliance_rev(ids) + + # Format and send the results + await self.send_revenue_results(ctx, revenue_data) + + except Exception as e: + await ctx.send(f"> Error getting game data: {str(e)}") + + async def get_alliance_rev(self, ids: list): + query_text = ( "id, nations {id, alliance_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, " "money, food, steel, gasoline, munitions, aluminum, iron_works, bauxite_works, arms_stockpile, emergency_gasoline_reserve, " @@ -937,12 +946,17 @@ class Banking(commands.Cog): "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," "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}}" ) + data = await self.kit.query("alliances", {"id": [10177]}, query_text) + data2 = data = await self.dkit.query("alliances", {"id": [10198]}, query_text) + nations = [] for alliance in data.alliances: nations.extend(alliance.nations) + for alliance in data2.alliances: + nations.extend(alliance.nations) if ids: notinalliance = [n for n in ids if n not in [n.id for n in nations]] @@ -955,37 +969,31 @@ class Banking(commands.Cog): revenue_data = [] message = await ctx.send("Calculating revenue for nations...") - try: - game_data = await self.get_game_data() + game_data = await self.get_game_data() - for nation in nations: - try: - if (nation.id not in self.WARCHEST_IDS) and (not ids): - continue + for nation in nations: + try: + if (nation.id not in self.WARCHEST_IDS) and (not ids): + continue - revenue = await self.calculate_revenue(message, nation, game_data) + revenue = await self.calculate_revenue(message, nation, game_data) - revenue_data.append( - { - "nation_id": nation.id, - "nation_name": nation.nation_name, - "revenue": revenue, - "nation_coal": nation.coal, - "nation_oil": nation.oil, - "nation_iron": nation.iron, - "nation_bauxite": nation.bauxite, - "nation_lead": nation.lead, - } - ) + revenue_data.append( + { + "nation_id": nation.id, + "nation_name": nation.nation_name, + "revenue": revenue, + "nation_coal": nation.coal, + "nation_oil": nation.oil, + "nation_iron": nation.iron, + "nation_bauxite": nation.bauxite, + "nation_lead": nation.lead, + } + ) - except Exception as e: - await ctx.cbsend(f"{traceback.format_exc()}") - - # Format and send the results - await self.send_revenue_results(ctx, revenue_data) - - except Exception as e: - await ctx.send(f"> Error getting game data: {str(e)}") + except Exception as e: + await ctx.cbsend(f"{traceback.format_exc()}") + return revenue_data async def revenue_calc( message: discord.Message, @@ -1116,8 +1124,17 @@ class Banking(commands.Cog): unpowered_infra -= 100 coal -= 1.2 - pollution += (12 * city.coal_mine) + (12 * city.oil_well) + (20 * city.uranium_mine) + (12 * city.lead_mine) - + (12 * city.iron_mine) + (12 * city.bauxite_mine) + (2 * city.farm * farm_poll_mod) + pollution += ( + (12 * city.coal_mine) + + (12 * city.oil_well) + + (20 * city.uranium_mine) + + (12 * city.lead_mine) + ) + ( + +(12 * city.iron_mine) + + (12 * city.bauxite_mine) + + (2 * city.farm * farm_poll_mod) + ) coal += 3 * city.coal_mine * (1 + ((0.5 * (city.coal_mine - 1)) / (10 - 1))) oil += 3 * city.oil_well * (1 + ((0.5 * (city.oil_well - 1)) / (10 - 1))) uranium += ( @@ -1333,8 +1350,14 @@ class Banking(commands.Cog): timestamp=datetime.datetime.utcnow(), ) - e.add_field(name="Net raws production", value=revenue["net_rev_txt"], inline=False) - e.add_field(name="On Nation", value=f"Coal: {data['nation_coal']}\nOil: {data['nation_oil']}\nIron: {data['nation_iron']}\nBauxite: {data['nation_bauxite']}\nLead: {data['nation_lead']}", inline=False) + e.add_field( + name="Net raws production", value=revenue["net_rev_txt"], inline=False + ) + e.add_field( + name="On Nation", + value=f"Coal: {data['nation_coal']}\nOil: {data['nation_oil']}\nIron: {data['nation_iron']}\nBauxite: {data['nation_bauxite']}\nLead: {data['nation_lead']}", + inline=False, + ) if revenue["footer"]: e.set_footer(text=revenue["footer"]) @@ -1344,6 +1367,10 @@ class Banking(commands.Cog): # Paginate the results await ctx.paginate(pages=embeds) + @commands.has_any_role("The Croak Council", "Government") + @commands.command() + async def refill(): ... + async def setup(bot: Brahmos): await bot.add_cog(Banking(bot))