update raws cmd

This commit is contained in:
un1xx committed 2025-06-06 19:04:21 +05:30
1 parent f29a3c08f4
commit e4148743d1
1 file changed
+44 -17
+44 -17
View File
@@ -23,6 +23,7 @@ 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
@@ -921,14 +922,22 @@ class Banking(commands.Cog):
) )
@commands.has_any_role("The Croak Council", "Government") @commands.has_any_role("The Croak Council", "Government")
@commands.command(aliases=["refill"]) @commands.command()
async def resource_refill(self, ctx: CustomCtx, ids: commands.Greedy[int]): async def raws(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( try:
"alliances", revenue_data = await self.get_alliance_rev(ids)
{"id": [10198, 10177]},
# 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" "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, " ", 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, "
@@ -937,12 +946,17 @@ class Banking(commands.Cog):
"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}}"
) )
data = await self.kit.query("alliances", {"id": [10177]}, query_text)
data2 = data = await self.dkit.query("alliances", {"id": [10198]}, query_text)
nations = [] nations = []
for alliance in data.alliances: for alliance in data.alliances:
nations.extend(alliance.nations) nations.extend(alliance.nations)
for alliance in data2.alliances:
nations.extend(alliance.nations)
if ids: if ids:
notinalliance = [n for n in ids if n not in [n.id for n in nations]] notinalliance = [n for n in ids if n not in [n.id for n in nations]]
@@ -955,7 +969,6 @@ class Banking(commands.Cog):
revenue_data = [] revenue_data = []
message = await ctx.send("Calculating revenue for nations...") 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: for nation in nations:
@@ -980,12 +993,7 @@ class Banking(commands.Cog):
except Exception as e: except Exception as e:
await ctx.cbsend(f"{traceback.format_exc()}") await ctx.cbsend(f"{traceback.format_exc()}")
return revenue_data
# 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 revenue_calc( async def revenue_calc(
message: discord.Message, message: discord.Message,
@@ -1116,8 +1124,17 @@ class Banking(commands.Cog):
unpowered_infra -= 100 unpowered_infra -= 100
coal -= 1.2 coal -= 1.2
pollution += (12 * city.coal_mine) + (12 * city.oil_well) + (20 * city.uranium_mine) + (12 * city.lead_mine) pollution += (
+ (12 * city.iron_mine) + (12 * city.bauxite_mine) + (2 * city.farm * farm_poll_mod) (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))) 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))) oil += 3 * city.oil_well * (1 + ((0.5 * (city.oil_well - 1)) / (10 - 1)))
uranium += ( uranium += (
@@ -1333,8 +1350,14 @@ class Banking(commands.Cog):
timestamp=datetime.datetime.utcnow(), timestamp=datetime.datetime.utcnow(),
) )
e.add_field(name="Net raws production", value=revenue["net_rev_txt"], inline=False) e.add_field(
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) 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"]: if revenue["footer"]:
e.set_footer(text=revenue["footer"]) e.set_footer(text=revenue["footer"])
@@ -1344,6 +1367,10 @@ class Banking(commands.Cog):
# Paginate the results # Paginate the results
await ctx.paginate(pages=embeds) await ctx.paginate(pages=embeds)
@commands.has_any_role("The Croak Council", "Government")
@commands.command()
async def refill(): ...
async def setup(bot: Brahmos): async def setup(bot: Brahmos):
await bot.add_cog(Banking(bot)) await bot.add_cog(Banking(bot))