initial_resource_calculation
This commit is contained in:
1 parent
e73b136d57
commit
00b2ce7d49
1 file changed
+528
+528
@@ -15,6 +15,7 @@ from discord.ext import commands
|
|||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.utils import format_dt
|
from discord.utils import format_dt
|
||||||
from numerize_denumerize import denumerize, numerize
|
from numerize_denumerize import denumerize, numerize
|
||||||
|
import math
|
||||||
|
|
||||||
from botclass import Brahmos, CustomCtx
|
from botclass import Brahmos, CustomCtx
|
||||||
from utils.base import BasicView
|
from utils.base import BasicView
|
||||||
@@ -924,7 +925,534 @@ class Banking(commands.Cog):
|
|||||||
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.command(aliases=["refill"])
|
||||||
|
async def refill(self, ctx: commands.Context, ids: commands.Greedy[int]):
|
||||||
|
"""
|
||||||
|
Revenue calculation from nations by fetching cities and projects.
|
||||||
|
"""
|
||||||
|
data = await self.kit.query(
|
||||||
|
"alliances",
|
||||||
|
{"id": [10177, 10198]},
|
||||||
|
"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, " \
|
||||||
|
"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, " \
|
||||||
|
"clinical_research_center, specialized_police_training_program, uranium_enrichment_program, cities {infrastructure, " \
|
||||||
|
"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}}"
|
||||||
|
)
|
||||||
|
|
||||||
|
nations = []
|
||||||
|
for alliance in data.alliances:
|
||||||
|
nations.extend(alliance.nations)
|
||||||
|
|
||||||
|
if ids:
|
||||||
|
notinalliance = [n for n in ids if n not in [n.id for n in nations]]
|
||||||
|
nations = [n for n in nations if n.id in ids]
|
||||||
|
if not nations:
|
||||||
|
return await ctx.send(f"> {ids} not in MILF or DILF")
|
||||||
|
if notinalliance:
|
||||||
|
await ctx.send(f"> {notinalliance} not in MILF or DILF")
|
||||||
|
|
||||||
|
revenue_data = []
|
||||||
|
message = await ctx.send("Calculating revenue for nations...")
|
||||||
|
|
||||||
|
try:
|
||||||
|
game_data = await self.get_game_data()
|
||||||
|
|
||||||
|
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_data.append({
|
||||||
|
'nation_id': nation.id,
|
||||||
|
'nation_name': nation.nation_name,
|
||||||
|
'revenue': revenue
|
||||||
|
})
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
await ctx.send(f"> Error calculating revenue for {nation.nation_name}: {str(e)}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 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(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
|
||||||
|
base_com = 0
|
||||||
|
hos_dis_red = 2.5
|
||||||
|
alu_mod = 1
|
||||||
|
mun_mod = 1
|
||||||
|
gas_mod = 1
|
||||||
|
manu_poll_mod = 1
|
||||||
|
farm_poll_mod = 0.5
|
||||||
|
subw_poll_red = 45
|
||||||
|
rss_upkeep_mod = 1
|
||||||
|
ste_mod = 1
|
||||||
|
rec_poll = 70
|
||||||
|
pol_cri_red = 2.5
|
||||||
|
food_land_mod = 500
|
||||||
|
uranium_mod = 1
|
||||||
|
rss_upkeep = 0
|
||||||
|
civil_upkeep = 0
|
||||||
|
military_upkeep = 0
|
||||||
|
money_income = 0
|
||||||
|
power_upkeep = 0
|
||||||
|
nationpop = 0
|
||||||
|
color_bonus = 0
|
||||||
|
policy_bonus = 1
|
||||||
|
new_player_bonus = 1
|
||||||
|
mil_cost = 1
|
||||||
|
total_infra = 0
|
||||||
|
starve_net_text = ""
|
||||||
|
starve_money_text = ""
|
||||||
|
starve_exp_text = ""
|
||||||
|
color_text = ""
|
||||||
|
new_player_text = ""
|
||||||
|
policy_bonus_text = ""
|
||||||
|
treasure_text = ""
|
||||||
|
footer = ""
|
||||||
|
|
||||||
|
if nation['iron_works'] == True:
|
||||||
|
ste_mod = 1.36
|
||||||
|
if nation['bauxite_works'] == True:
|
||||||
|
alu_mod = 1.36
|
||||||
|
if nation['arms_stockpile'] == True:
|
||||||
|
mun_mod = 1.34
|
||||||
|
if nation['emergency_gasoline_reserve'] == True:
|
||||||
|
gas_mod = 2
|
||||||
|
if nation['mass_irrigation'] == True:
|
||||||
|
food_land_mod = 400
|
||||||
|
if nation['international_trade_center'] == True:
|
||||||
|
max_commerce = 115
|
||||||
|
if nation['telecommunications_satellite'] == True:
|
||||||
|
max_commerce = 125
|
||||||
|
base_com = 2
|
||||||
|
if nation['recycling_initiative'] == True:
|
||||||
|
rec_poll = 75
|
||||||
|
if nation['green_technologues'] == True:
|
||||||
|
manu_poll_mod = 0.75
|
||||||
|
farm_poll_mod = 0.5
|
||||||
|
subw_poll_red = 70
|
||||||
|
rss_upkeep_mod = 0.9
|
||||||
|
if nation['clinical_research_center'] == True:
|
||||||
|
hos_dis_red = 3.5
|
||||||
|
if nation['specialized_police_training'] == True:
|
||||||
|
hos_dis_red = 3.5
|
||||||
|
if nation['uranium_enrichment_program'] == True:
|
||||||
|
uranium_mod = 2
|
||||||
|
|
||||||
|
coal = 0
|
||||||
|
oil = 0
|
||||||
|
uranium = 0
|
||||||
|
lead = 0
|
||||||
|
iron = 0
|
||||||
|
bauxite = 0
|
||||||
|
gasoline = 0
|
||||||
|
munitions = 0
|
||||||
|
steel = 0
|
||||||
|
aluminum = 0
|
||||||
|
food = 0
|
||||||
|
|
||||||
|
if build != None:
|
||||||
|
try:
|
||||||
|
build = json.loads(build)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
await message.edit(content="Something is wrong with the build you sent!")
|
||||||
|
return
|
||||||
|
land = 0
|
||||||
|
for city in nation['cities']:
|
||||||
|
land += city['land']
|
||||||
|
city = {}
|
||||||
|
for key, value in build.items():
|
||||||
|
city[key[4:]] = int(value)
|
||||||
|
city['infrastructure'] = city.pop('a_needed')
|
||||||
|
city['land'] = round(land/nation['num_cities'])
|
||||||
|
city['powered'] = True
|
||||||
|
city['date'] = nation['cities'][math.ceil(nation['num_cities']/2)]['date']
|
||||||
|
nation['cities'] = [city]
|
||||||
|
#print(city)
|
||||||
|
|
||||||
|
for city in nation['cities']:
|
||||||
|
total_infra += city['infrastructure']
|
||||||
|
base_pop = city['infrastructure'] * 100
|
||||||
|
pollution = 0
|
||||||
|
unpowered_infra = city['infrastructure']
|
||||||
|
for wind_plant in range(city['wind_power']): #can add something about wasted slots
|
||||||
|
if unpowered_infra > 0:
|
||||||
|
unpowered_infra -= 250
|
||||||
|
power_upkeep += 42
|
||||||
|
for nucl_plant in range(city['nuclear_power']):
|
||||||
|
power_upkeep += 10500
|
||||||
|
for level in range(2):
|
||||||
|
if unpowered_infra > 0:
|
||||||
|
unpowered_infra -= 1000
|
||||||
|
uranium -= 1.2
|
||||||
|
for oil_plant in range(city['oil_power']):
|
||||||
|
power_upkeep += 1800
|
||||||
|
pollution += 6
|
||||||
|
for level in range(5):
|
||||||
|
if unpowered_infra > 0:
|
||||||
|
unpowered_infra -= 100
|
||||||
|
oil -= 1.2
|
||||||
|
for coal_plant in range(city['coal_power']):
|
||||||
|
power_upkeep += 1200
|
||||||
|
pollution += 8
|
||||||
|
for level in range(5):
|
||||||
|
if unpowered_infra > 0:
|
||||||
|
unpowered_infra -= 100
|
||||||
|
coal -= 1.2
|
||||||
|
|
||||||
|
rss_upkeep += 400 * city['coal_mine'] * rss_upkeep_mod
|
||||||
|
pollution += 12 * city['coal_mine']
|
||||||
|
coal += 3 * city['coal_mine'] * (1 + ((0.5 * (city['coal_mine'] - 1)) / (10 - 1)))
|
||||||
|
|
||||||
|
rss_upkeep += 600 * city['oil_well'] * rss_upkeep_mod
|
||||||
|
pollution += 12 * city['oil_well']
|
||||||
|
oil += 3 * city['oil_well'] * (1 + ((0.5 * (city['oil_well'] - 1)) / (10 - 1)))
|
||||||
|
|
||||||
|
rss_upkeep += 5000 * city['uranium_mine'] * rss_upkeep_mod
|
||||||
|
pollution += 20 * city['uranium_mine']
|
||||||
|
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
|
||||||
|
pollution += 12 * city['lead_mine']
|
||||||
|
lead += 3 * city['lead_mine'] * (1 + ((0.5 * (city['lead_mine'] - 1)) / (10 - 1)))
|
||||||
|
|
||||||
|
rss_upkeep += 1600 * city['iron_mine'] * rss_upkeep_mod
|
||||||
|
pollution += 12 * city['iron_mine']
|
||||||
|
iron += 3 * city['iron_mine'] * (1 + ((0.5 * (city['iron_mine'] - 1)) / (10 - 1)))
|
||||||
|
|
||||||
|
rss_upkeep += 1600 * city['bauxite_mine'] * rss_upkeep_mod
|
||||||
|
pollution += 12 * city['bauxite_mine']
|
||||||
|
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
|
||||||
|
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
|
||||||
|
if food_prod < 0:
|
||||||
|
food += 0
|
||||||
|
else:
|
||||||
|
food += food_prod
|
||||||
|
|
||||||
|
commerce = base_com
|
||||||
|
if city['powered']:
|
||||||
|
rss_upkeep += 4000 * city['oil_refinery'] * rss_upkeep_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
|
||||||
|
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
|
||||||
|
pollution += 40 * city['steel_mill'] * manu_poll_mod
|
||||||
|
iron -= 3 * 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
|
||||||
|
pollution += 40 * city['aluminum_refinery'] * manu_poll_mod
|
||||||
|
bauxite -= 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
|
||||||
|
pollution += 32 * city['munitions_factory'] * manu_poll_mod
|
||||||
|
lead -= 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['hospital'] * 1000
|
||||||
|
civil_upkeep += city['recycling_center'] * 2500
|
||||||
|
civil_upkeep += city['subway'] * 3250
|
||||||
|
civil_upkeep += city['supermarket'] * 600
|
||||||
|
civil_upkeep += city['bank'] * 1800
|
||||||
|
civil_upkeep += city['mall'] * 5400
|
||||||
|
civil_upkeep += city['stadium'] * 12150
|
||||||
|
|
||||||
|
police_stations = city['police_station']
|
||||||
|
hospitals = city['hospital']
|
||||||
|
|
||||||
|
pollution += city['police_station']
|
||||||
|
pollution += city['hospital'] * 4
|
||||||
|
pollution -= city['recycling_center'] * rec_poll
|
||||||
|
pollution -= city['subway'] * subw_poll_red
|
||||||
|
pollution += city['mall'] * 2
|
||||||
|
pollution += city['stadium'] * 5
|
||||||
|
|
||||||
|
city['real_pollution'] = pollution
|
||||||
|
if pollution < 0:
|
||||||
|
pollution = 0
|
||||||
|
city['pollution'] = pollution
|
||||||
|
|
||||||
|
commerce += city['subway'] * 8
|
||||||
|
commerce += city['supermarket'] * 3
|
||||||
|
commerce += city['bank'] * 5
|
||||||
|
commerce += city['mall'] * 9
|
||||||
|
commerce += city['stadium'] * 12
|
||||||
|
|
||||||
|
city['real_commerce'] = commerce
|
||||||
|
if commerce > max_commerce:
|
||||||
|
commerce = max_commerce
|
||||||
|
city['commerce'] = commerce
|
||||||
|
|
||||||
|
else:
|
||||||
|
police_stations = 0
|
||||||
|
hospitals = 0
|
||||||
|
|
||||||
|
crime_rate = ((103 - commerce)**2 + (city['infrastructure'] * 100))/(111111) - police_stations * pol_cri_red
|
||||||
|
city['real_crime_rate'] = crime_rate
|
||||||
|
if crime_rate < 0:
|
||||||
|
crime_rate = 0
|
||||||
|
city['crime_rate'] = crime_rate
|
||||||
|
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
|
||||||
|
city['real_disease_rate'] = disease_rate
|
||||||
|
if disease_rate > 100:
|
||||||
|
disease_rate = 100
|
||||||
|
elif disease_rate < 0:
|
||||||
|
disease_rate = 0
|
||||||
|
city['disease_rate'] = disease_rate
|
||||||
|
disease_deaths = base_pop * (disease_rate/100)
|
||||||
|
if disease_deaths < 0:
|
||||||
|
disease_deaths = 0
|
||||||
|
city_age = (datetime.datetime.utcnow() - datetime.datetime.strptime(city['date'], "%Y-%m-%d")).days
|
||||||
|
if city_age == 0:
|
||||||
|
city_age = 1
|
||||||
|
population = ((base_pop - disease_deaths - crime_deaths) * (1 + math.log(city_age)/15))
|
||||||
|
nationpop += population
|
||||||
|
money_income += (((commerce / 50) * 0.725) + 0.725) * population
|
||||||
|
|
||||||
|
alliance_treasures = 0
|
||||||
|
nation_treasure_bonus = 1
|
||||||
|
for treasure in treasures:
|
||||||
|
if treasure['nation'] == None:
|
||||||
|
continue
|
||||||
|
if treasure['nation']['id'] == nation['id']:
|
||||||
|
nation_treasure_bonus += treasure['bonus'] / 100
|
||||||
|
if nation['alliance']:
|
||||||
|
if treasure['nation']['alliance_id'] == nation['alliance_id']:
|
||||||
|
alliance_treasures += 1
|
||||||
|
if alliance_treasures > 0:
|
||||||
|
nation_treasure_bonus += math.sqrt(alliance_treasures * 4) / 100
|
||||||
|
if nation_treasure_bonus > 1:
|
||||||
|
treasure_text = f"\n\nTreasure Bonus: ${round(money_income * (nation_treasure_bonus - 1)):,}"
|
||||||
|
|
||||||
|
if not single_city:
|
||||||
|
color_bonus = colors[nation['color']]
|
||||||
|
color_text = f"\n\nColor Trade Bloc Bonus: ${round(color_bonus):,}"
|
||||||
|
food -= nationpop / 1000
|
||||||
|
|
||||||
|
if nation['num_cities'] < 11:
|
||||||
|
new_player_bonus = 2.1 - 0.1 * nation['num_cities']
|
||||||
|
new_player_text = f"\n\nNew Player Bonus: ${round((new_player_bonus - 1) * money_income):,}"
|
||||||
|
if nation['dompolicy'] == "Open Markets":
|
||||||
|
policy_bonus = 1.01
|
||||||
|
policy_bonus_text = f"\n\nOpen Markets Bonus: ${round(money_income * 0.01):,}"
|
||||||
|
|
||||||
|
at_war = False
|
||||||
|
if not single_city:
|
||||||
|
for war in nation['wars']:
|
||||||
|
if war['turnsleft'] > 0:
|
||||||
|
at_war = True
|
||||||
|
if include_spies:
|
||||||
|
military_upkeep += nation['spies'] * 2400
|
||||||
|
if not at_war:
|
||||||
|
military_upkeep += nation['soldiers'] * 1.25
|
||||||
|
food -= nation['soldiers'] / 750
|
||||||
|
military_upkeep += nation['tanks'] * 50
|
||||||
|
military_upkeep += nation['aircraft'] * 500
|
||||||
|
military_upkeep += nation['ships'] * 3750
|
||||||
|
military_upkeep += nation['missiles'] * 21000
|
||||||
|
military_upkeep += nation['nukes'] * 31500
|
||||||
|
else:
|
||||||
|
military_upkeep += nation['soldiers'] * 1.88
|
||||||
|
food -= nation['soldiers'] / 500
|
||||||
|
military_upkeep += nation['tanks'] * 75
|
||||||
|
military_upkeep += nation['aircraft'] * 750
|
||||||
|
military_upkeep += nation['ships'] * 5625
|
||||||
|
military_upkeep += nation['missiles'] * 35000
|
||||||
|
military_upkeep += nation['nukes'] * 52500
|
||||||
|
else:
|
||||||
|
military_upkeep += int(city['barracks']) * 3000 * 1.25
|
||||||
|
military_upkeep += int(city['factory']) * 250 * 50
|
||||||
|
military_upkeep += int(city['hangar']) * 15 * 500
|
||||||
|
military_upkeep += int(city['drydock']) * 5 * 3750
|
||||||
|
|
||||||
|
if nation['dompolicy'] == "Imperialism":
|
||||||
|
mil_cost = 0.95
|
||||||
|
policy_bonus_text = f"\n\nImperialism Bonus: ${round(military_upkeep * 0.05):,}"
|
||||||
|
if food < 0:
|
||||||
|
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_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"
|
||||||
|
|
||||||
|
max_infra = sorted(nation['cities'], key=lambda k: k['infrastructure'], reverse=True)[0]['infrastructure']
|
||||||
|
|
||||||
|
if single_city:
|
||||||
|
rev_obj = nation['cities'][0]
|
||||||
|
else:
|
||||||
|
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['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:
|
||||||
|
rev_obj['money'] = rev_obj['net_cash_num']
|
||||||
|
rev_obj['net income'] = rev_obj['monetary_net_num']
|
||||||
|
rev_obj['aluminum'] = aluminum
|
||||||
|
rev_obj['bauxite'] = bauxite
|
||||||
|
rev_obj['coal'] = coal
|
||||||
|
rev_obj['gasoline'] = gasoline
|
||||||
|
rev_obj['iron'] = iron
|
||||||
|
rev_obj['lead'] = lead
|
||||||
|
rev_obj['munitions'] = munitions
|
||||||
|
rev_obj['oil'] = oil
|
||||||
|
rev_obj['steel'] = steel
|
||||||
|
rev_obj['uranium'] = uranium
|
||||||
|
rev_obj['disease_rate'] = disease_rate
|
||||||
|
rev_obj['crime_rate'] = crime_rate
|
||||||
|
rev_obj['commerce'] = commerce
|
||||||
|
rev_obj['pollution'] = pollution
|
||||||
|
return rev_obj
|
||||||
|
else:
|
||||||
|
rev_obj['nation'] = nation
|
||||||
|
rev_obj['footer'] = footer
|
||||||
|
rev_obj['max_infra'] = max_infra
|
||||||
|
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['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}"
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
async def calculate_revenue(self, message: discord.Message, nation: dict, game_data: dict) -> dict:
|
||||||
|
"""Calculate revenue for a nation."""
|
||||||
|
revenue = await revenue_calc(
|
||||||
|
message=message,
|
||||||
|
nation=nation,
|
||||||
|
radiation=game_data['radiation'],
|
||||||
|
treasures=game_data['treasures'],
|
||||||
|
prices=game_data['prices'],
|
||||||
|
colors=game_data['colors'],
|
||||||
|
seasonal_mod=game_data['seasonal_mod']
|
||||||
|
)
|
||||||
|
|
||||||
|
return revenue
|
||||||
|
|
||||||
|
async def get_game_data(self) -> dict:
|
||||||
|
"""
|
||||||
|
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")
|
||||||
|
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}")
|
||||||
|
treasures_query = await self.kit.query("treasures", {}, "name, bonus, spawn_date, nation_id, nation { alliance_id }")
|
||||||
|
|
||||||
|
# color bloc bonus
|
||||||
|
colors = {}
|
||||||
|
for color in colors_query.colors:
|
||||||
|
colors[color.color] = color.turn_bonus * 12
|
||||||
|
|
||||||
|
# radiation
|
||||||
|
rad = game_info_query.game_info.radiation
|
||||||
|
radiation = {
|
||||||
|
"na": 1 - (rad.north_america + rad.global_)/1000,
|
||||||
|
"sa": 1 - (rad.south_america + rad.global_)/1000,
|
||||||
|
"eu": 1 - (rad.europe + rad.global_)/1000,
|
||||||
|
"as": 1 - (rad.asia + rad.global_)/1000,
|
||||||
|
"af": 1 - (rad.africa + rad.global_)/1000,
|
||||||
|
"au": 1 - (rad.australia + rad.global_)/1000,
|
||||||
|
"an": 1 - (rad.antarctica + rad.global_)/1000
|
||||||
|
}
|
||||||
|
|
||||||
|
# seasons
|
||||||
|
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}
|
||||||
|
if month in [6,7,8]:
|
||||||
|
seasonal_mod['na'] = 1.2
|
||||||
|
seasonal_mod['as'] = 1.2
|
||||||
|
seasonal_mod['eu'] = 1.2
|
||||||
|
seasonal_mod['sa'] = 0.8
|
||||||
|
seasonal_mod['af'] = 0.8
|
||||||
|
seasonal_mod['au'] = 0.8
|
||||||
|
elif month in [12,1,2]:
|
||||||
|
seasonal_mod['na'] = 0.8
|
||||||
|
seasonal_mod['as'] = 0.8
|
||||||
|
seasonal_mod['eu'] = 0.8
|
||||||
|
seasonal_mod['sa'] = 1.2
|
||||||
|
seasonal_mod['af'] = 1.2
|
||||||
|
seasonal_mod['au'] = 1.2
|
||||||
|
|
||||||
|
# market price
|
||||||
|
prices_data = trade_prices_query.tradeprices[0]
|
||||||
|
prices = {
|
||||||
|
'coal': prices_data.coal,
|
||||||
|
'oil' : prices_data.oil,
|
||||||
|
'uranium' : prices_data.uranium,
|
||||||
|
'iron' : prices_data.iron,
|
||||||
|
'bauxite' : prices_data.bauxite,
|
||||||
|
'lead' : prices_data.lead,
|
||||||
|
'gasoline' : prices_data.gasoline,
|
||||||
|
'munitions' : prices_data.munitions,
|
||||||
|
'steel' : prices_data.steel,
|
||||||
|
'aluminum' : prices_data.aluminum,
|
||||||
|
'food' : prices_data.food
|
||||||
|
}
|
||||||
|
|
||||||
|
treasures = {
|
||||||
|
'name': [], 'bonus':[]
|
||||||
|
}
|
||||||
|
treasures_data = treasures_query.treasures
|
||||||
|
for treasure in treasures_data:
|
||||||
|
if treasure.nation.alliance_id == 10177:
|
||||||
|
treasures['name'].append(treasure.name)
|
||||||
|
treasures['bonus'].append(treasure.bonus)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'prices': prices,
|
||||||
|
'treasures': treasures,
|
||||||
|
'radiation': radiation,
|
||||||
|
'seasonal_mod': seasonal_mod,
|
||||||
|
'colors': colors
|
||||||
|
}
|
||||||
|
|
||||||
|
async def send_revenue_results(self, ctx: commands.Context, revenue_data: list):
|
||||||
|
"""Format and send the revenue calculation results."""
|
||||||
|
if not revenue_data:
|
||||||
|
return await ctx.send("> No revenue data to display.")
|
||||||
|
|
||||||
|
# Create embeds for each nation's revenue
|
||||||
|
embeds = []
|
||||||
|
for data in revenue_data:
|
||||||
|
revenue = data['revenue']
|
||||||
|
e = discord.Embed(
|
||||||
|
title=f"Revenue for {data['nation_name']}",
|
||||||
|
color=ctx.author.color,
|
||||||
|
timestamp=datetime.datetime.utcnow()
|
||||||
|
)
|
||||||
|
|
||||||
|
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="Net Revenue", value=revenue['net_rev_txt'], inline=False)
|
||||||
|
e.add_field(name="Monetary Net", value=revenue['mon_net_txt'], inline=False)
|
||||||
|
|
||||||
|
if revenue['footer']:
|
||||||
|
e.set_footer(text=revenue['footer'])
|
||||||
|
|
||||||
|
embeds.append(e)
|
||||||
|
|
||||||
|
# Paginate the results
|
||||||
|
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))
|
||||||
Reference in new issue
Block a user