Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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['ironw'] == True:
- ste_mod = 1.36
- if nation['bauxitew'] == True:
- alu_mod = 1.36
- if nation['armss'] == True:
- mun_mod = 1.34
- if nation['egr'] == True:
- gas_mod = 2
- if nation['massirr'] == True:
- food_land_mod = 400
- if nation['itc'] == True:
- max_commerce = 115
- if nation['telecom_satellite'] == True:
- max_commerce = 125
- base_com = 2
- if nation['recycling_initiative'] == True:
- rec_poll = 75
- if nation['green_tech'] == 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['uap'] == 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']
- city['airforcebase'] = city['hangars']
- 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['windpower']): #can add something about wasted slots
- if unpowered_infra > 0:
- unpowered_infra -= 250
- power_upkeep += 42
- for nucl_plant in range(city['nuclearpower']):
- power_upkeep += 10500
- for level in range(2):
- if unpowered_infra > 0:
- unpowered_infra -= 1000
- uranium -= 1.2
- for oil_plant in range(city['oilpower']):
- 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['coalpower']):
- power_upkeep += 1200
- pollution += 8
- for level in range(5):
- if unpowered_infra > 0:
- unpowered_infra -= 100
- coal -= 1.2
- rss_upkeep += 400 * city['coalmine'] * rss_upkeep_mod
- pollution += 12 * city['coalmine']
- coal += 3 * city['coalmine'] * (1 + ((0.5 * (city['coalmine'] - 1)) / (10 - 1)))
- rss_upkeep += 600 * city['oilwell'] * rss_upkeep_mod
- pollution += 12 * city['oilwell']
- oil += 3 * city['oilwell'] * (1 + ((0.5 * (city['oilwell'] - 1)) / (10 - 1)))
- rss_upkeep += 5000 * city['uramine'] * rss_upkeep_mod
- pollution += 20 * city['uramine']
- uranium += 3 * city['uramine'] * (1 + ((0.5 * (city['uramine'] - 1)) / (5 - 1))) * uranium_mod
- rss_upkeep += 1500 * city['leadmine'] * rss_upkeep_mod
- pollution += 12 * city['leadmine']
- lead += 3 * city['leadmine'] * (1 + ((0.5 * (city['leadmine'] - 1)) / (10 - 1)))
- rss_upkeep += 1600 * city['ironmine'] * rss_upkeep_mod
- pollution += 12 * city['ironmine']
- iron += 3 * city['ironmine'] * (1 + ((0.5 * (city['ironmine'] - 1)) / (10 - 1)))
- rss_upkeep += 1600 * city['bauxitemine'] * rss_upkeep_mod
- pollution += 12 * city['bauxitemine']
- bauxite += 3 * city['bauxitemine'] * (1 + ((0.5 * (city['bauxitemine'] - 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['gasrefinery'] * rss_upkeep_mod
- pollution += 32 * city['gasrefinery'] * manu_poll_mod
- oil -= 3 * city['gasrefinery'] * (1 + ((0.5 * (city['gasrefinery'] - 1)) / (5 - 1))) * gas_mod
- gasoline += 6 * city['gasrefinery'] * (1 + ((0.5 * (city['gasrefinery'] - 1)) / (5 - 1))) * gas_mod
- rss_upkeep += 4000 * city['steelmill'] * rss_upkeep_mod
- pollution += 40 * city['steelmill'] * manu_poll_mod
- iron -= 3 * city['steelmill'] * (1 + ((0.5 * (city['steelmill'] - 1)) / (5 - 1))) * ste_mod
- coal -= 3 * city['steelmill'] * (1 + ((0.5 * (city['steelmill'] - 1)) / (5 - 1))) * ste_mod
- steel += 9 * city['steelmill'] * (1 + ((0.5 * (city['steelmill'] - 1)) / (5 - 1))) * ste_mod
- rss_upkeep += 2500 * city['aluminumrefinery'] * rss_upkeep_mod
- pollution += 40 * city['aluminumrefinery'] * manu_poll_mod
- bauxite -= 3 * city['aluminumrefinery'] * (1 + ((0.5 * (city['aluminumrefinery'] - 1)) / (5 - 1))) * alu_mod
- aluminum += 9 * city['aluminumrefinery'] * (1 + ((0.5 * (city['aluminumrefinery'] - 1)) / (5 - 1))) * alu_mod
- rss_upkeep += 3500 * city['munitionsfactory'] * rss_upkeep_mod
- pollution += 32 * city['munitionsfactory'] * manu_poll_mod
- lead -= 6 * city['munitionsfactory'] * (1 + ((0.5 * (city['munitionsfactory'] - 1)) / (5 - 1))) * mun_mod
- munitions += 18 * city['munitionsfactory'] * (1 + ((0.5 * (city['munitionsfactory'] - 1)) / (5 - 1))) * mun_mod
- civil_upkeep += city['policestation'] * 750
- civil_upkeep += city['hospital'] * 1000
- civil_upkeep += city['recyclingcenter'] * 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['policestation']
- hospitals = city['hospital']
- pollution += city['policestation']
- pollution += city['hospital'] * 4
- pollution -= city['recyclingcenter'] * 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.utcnow() - 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 += await spy_calc(nation) * 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['airforcebase']) * 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
- # RIFT VERSION
- async def actual_calculate_revenue(
- self,
- prices: Optional[TradePrices],
- cities: List[FullCity],
- fetch_spies: bool = False,
- ) -> RevenueDict:
- from ...funcs import calculate_spies
- spies = await calculate_spies(self) if fetch_spies else 0
- prices = prices or cache.prices
- revenues = [i.calculate_income() for i in cities]
- revenue: RevenueDict = { # type: ignore
- "gross_income": sum(
- (i["gross_income"] for i in revenues[1:]), revenues[0]["gross_income"]
- ),
- "net_income": sum(
- (i["net_income"] for i in revenues[1:]), revenues[0]["net_income"]
- ),
- "upkeep": sum((i["upkeep"] for i in revenues[1:]), revenues[0]["upkeep"]),
- }
- color = await Color.fetch(self.color.lower())
- bonus = color.bonus * 12
- if self.cities <= 10:
- revenue["new_player_bonus"] = revenue["gross_income"].money * (
- 1.1 - (0.1 * self.cities)
- )
- revenue["gross_income"].money *= 2.1 - (0.1 * self.cities)
- revenue["net_income"].money = sum(
- i.calculate_net_money_income(2.1 - (0.1 * self.cities)) for i in cities
- )
- revenue["gross_income"].money += bonus
- revenue["net_income"].money += bonus
- if self.offensive_wars or self.defensive_wars:
- revenue["net_income"].money -= (
- (1.88 * (self.soldiers / 500))
- + (75 * self.tanks)
- + (750 * self.aircraft)
- + (5625 * self.ships)
- + (2400 * spies)
- + (31500 * self.missiles)
- + (52500 * self.nukes)
- )
- revenue["net_income"].food -= self.soldiers / 500
- revenue["upkeep"].food += self.soldiers / 500
- revenue["upkeep"].money += (
- (1.88 * (self.soldiers / 500))
- + (75 * self.tanks)
- + (750 * self.aircraft)
- + (5625 * self.ships)
- + (2400 * spies)
- + (31500 * self.missiles)
- + (52500 * self.nukes)
- )
- else:
- revenue["net_income"].money -= (
- (1.25 * (self.soldiers / 750))
- + (50 * self.tanks)
- + (500 * self.aircraft)
- + (3750 * self.ships)
- + (2400 * spies)
- + (21000 * self.missiles)
- + (35000 * self.nukes)
- )
- revenue["net_income"].food -= self.soldiers / 750
- revenue["upkeep"].money += (
- (1.25 * (self.soldiers / 750))
- + (50 * self.tanks)
- + (500 * self.aircraft)
- + (3750 * self.ships)
- + (2400 * spies)
- + (21000 * self.missiles)
- + (35000 * self.nukes)
- )
- revenue["upkeep"].food += self.soldiers / 750
- revenue["gross_total"] = Resources(
- **{
- key: value * getattr(prices, key).lowest_sell.price
- for key, value in revenue["gross_income"].to_dict().items()
- if key != "money"
- }
- )
- revenue["net_total"] = Resources(
- **{
- key: value * getattr(prices, key).lowest_sell.price
- for key, value in revenue["net_income"].to_dict().items()
- if key != "money"
- }
- )
- revenue["upkeep_total"] = Resources(
- **{
- key: value * getattr(prices, key).lowest_sell.price
- for key, value in revenue["upkeep"].to_dict().items()
- if key != "money"
- }
- )
- revenue["trade_bonus"] = bonus
- return revenue
- ## CITY
- @property
- @cachetools.cached(cache=cachetools.TTLCache(1024, 30)) # type: ignore
- def population(self) -> float:
- return (
- ((self.infrastructure * 100) - (self.disease * self.infrastructure))
- - max((self.crime / 10) * (100 * self.infrastructure) - 25, 0)
- ) * (1 + (math.log(self.age) if self.age else 0) / 15)
- @property
- @cachetools.cached(cache=cachetools.TTLCache(1024, 30)) # type: ignore
- def disease(self) -> float:
- disease = (
- (((((self.infrastructure * 100 / self.land) ** 2) * 0.01) - 25) / 100)
- + (self.infrastructure * 100 / 100000)
- + (self.pollution * 0.05)
- - (self.hospitals * 2.5)
- - (self.hospitals * self.projects.clinical_research_center)
- )
- if disease < 0:
- return 0
- if disease > 100:
- return 100
- return disease
- @property
- @cachetools.cached(cache=cachetools.TTLCache(1024, 30)) # type: ignore
- def crime(self) -> float:
- crime = (
- ((103 - self.commerce) ** 2 + (self.infrastructure * 100)) / (111111)
- - (self.police_stations * 2.5)
- - (self.police_stations * self.projects.specialized_police_training)
- )
- if crime < 0:
- return 0
- if crime > 100:
- return 100
- return crime
- @property
- @cachetools.cached(cache=cachetools.TTLCache(1024, 30)) # type: ignore
- def pollution(self) -> float:
- return (
- self.coal_power * 8
- + self.oil_power * 6
- + self.coal_mines * 12
- + self.iron_mines * 12
- + self.bauxite_mines * 12
- + self.oil_wells * 12
- + self.lead_mines * 12
- + self.uranium_mines * 20
- + self.farms * 2 * (1 - int(self.projects.green_tech) * 0.5)
- + self.oil_refineries * 32 * (1 - int(self.projects.green_tech) * 0.25)
- + self.steel_mills * 40 * (1 - int(self.projects.green_tech) * 0.25)
- + self.aluminum_refineries * 40 * (1 - int(self.projects.green_tech) * 0.25)
- + self.munitions_factories * 32 * (1 - int(self.projects.green_tech) * 0.25)
- + self.police_stations
- + self.hospitals * 4
- - self.recycling_centers * 70
- - self.recycling_centers * 5 * self.projects.recycling_initiative
- - self.subways * 45
- - self.subways * 25 * self.projects.green_tech
- + self.shopping_malls * 2
- + self.stadiums * 5
- )
- @property
- @cachetools.cached(cache=cachetools.TTLCache(1024, 30)) # type: ignore
- def commerce(self) -> float:
- commerce = (
- self.supermarkets * 3
- + self.banks * 5
- + self.shopping_malls * 9
- + self.stadiums * 12
- + self.subways * 8
- + self.projects.telecom_satellite * 2
- )
- if self.projects.telecom_satellite:
- return commerce
- if self.projects.itc:
- return min(commerce, 115)
- return min(commerce, 100)
- def calculate_income(self) -> Dict[str, Resources]:
- """
- Income is per day.
- """
- return {
- "gross_income": Resources(
- money=self.calculate_money_income(),
- food=self.calculate_food_income(),
- coal=self.calculate_coal_income(),
- oil=self.calculate_oil_income(),
- uranium=self.calculate_uranium_income(),
- lead=self.calculate_lead_income(),
- iron=self.calculate_iron_income(),
- bauxite=self.calculate_bauxite_income(),
- gasoline=self.calculate_gasoline_income(),
- munitions=self.calculate_munitions_income(),
- steel=self.calculate_steel_income(),
- aluminum=self.calculate_aluminum_income(),
- ),
- "net_income": Resources(
- money=self.calculate_net_money_income(),
- food=self.calculate_net_food_income(),
- coal=self.calculate_net_coal_income(),
- oil=self.calculate_net_oil_income(),
- uranium=self.calculate_net_uranium_income(),
- lead=self.calculate_net_lead_income(),
- iron=self.calculate_net_iron_income(),
- bauxite=self.calculate_net_bauxite_income(),
- gasoline=self.calculate_net_gasoline_income(),
- munitions=self.calculate_net_munitions_income(),
- steel=self.calculate_net_steel_income(),
- aluminum=self.calculate_net_aluminum_income(),
- ),
- "upkeep": Resources(
- money=self.calculate_money_upkeep(),
- food=self.calculate_food_upkeep(),
- coal=self.calculate_coal_upkeep(),
- oil=self.calculate_oil_upkeep(),
- uranium=self.calculate_uranium_upkeep(),
- lead=self.calculate_lead_upkeep(),
- iron=self.calculate_iron_upkeep(),
- bauxite=self.calculate_bauxite_upkeep(),
- ),
- }
- def calculate_money_income(self, income_modifier: float = 1) -> float:
- if not self.powered:
- return 0.725 * self.population
- if self.nation.domestic_policy == "Open Markets":
- return (((self.commerce / 50) * 0.725) + 0.725) * self.population * 1.01
- return (
- (((self.commerce / 50) * 0.725) + 0.725) * self.population * income_modifier
- )
- def calculate_food_income(self) -> float:
- return (
- (
- (self.land / (500 - (int(self.projects.massirr) * 100)))
- * self.farms
- * (1 + ((0.5 * (self.farms - 1)) / (20 - 1)))
- * 12
- )
- if self.farms
- else 0
- )
- def calculate_coal_income(self) -> float:
- return (
- 3 * self.coal_mines * (1 + ((0.5 * (self.coal_mines - 1)) / (10 - 1)))
- if self.coal_mines
- else 0
- )
- def calculate_oil_income(self) -> float:
- return (
- 3 * self.oil_wells * (1 + ((0.5 * (self.oil_wells - 1)) / (10 - 1)))
- if self.oil_wells
- else 0
- )
- def calculate_uranium_income(self) -> float:
- return (
- (
- 3
- * self.uranium_mines
- * (1 + ((0.5 * (self.uranium_mines - 1)) / (5 - 1)))
- * (1 + int(self.projects.uap))
- )
- if self.uranium_mines
- else 0
- )
- def calculate_lead_income(self) -> float:
- return (
- 3 * self.lead_mines * (1 + ((0.5 * (self.lead_mines - 1)) / (10 - 1)))
- if self.lead_mines
- else 0
- )
- def calculate_iron_income(self) -> float:
- return (
- 3 * self.iron_mines * (1 + ((0.5 * (self.iron_mines - 1)) / (10 - 1)))
- if self.iron_mines
- else 0
- )
- def calculate_bauxite_income(self) -> float:
- return (
- (
- 3
- * self.bauxite_mines
- * (1 + ((0.5 * (self.bauxite_mines - 1)) / (10 - 1)))
- )
- if self.bauxite_mines
- else 0
- )
- def calculate_gasoline_income(self) -> float:
- if not self.oil_refineries or not self.powered:
- return 0
- return (
- 6
- * self.oil_refineries
- * (1 + ((0.5 * (self.oil_refineries - 1)) / (5 - 1)))
- * (1 + (0.36 * int(self.projects.egr)))
- )
- def calculate_munitions_income(self) -> float:
- if not self.munitions_factories or not self.powered:
- return 0
- return (
- 18
- * self.munitions_factories
- * (1 + ((0.5 * (self.munitions_factories - 1)) / (5 - 1)))
- * (1 + (0.34 * int(self.projects.armss)))
- )
- def calculate_steel_income(self) -> float:
- if not self.steel_mills or not self.powered:
- return 0
- return (
- 9
- * self.steel_mills
- * (1 + ((0.5 * (self.steel_mills - 1)) / (5 - 1)))
- * (1 + (0.36 * int(self.projects.ironw)))
- )
- def calculate_aluminum_income(self) -> float:
- if not self.aluminum_refineries or not self.powered:
- return 0
- return (
- 9
- * self.aluminum_refineries
- * (1 + ((0.5 * (self.aluminum_refineries - 1)) / (5 - 1)))
- * (1 + (0.36 * int(self.projects.bauxitew)))
- )
- def calculate_money_upkeep(self):
- return (
- (self.coal_power * 1200)
- + (self.oil_power * 1800)
- + (self.nuclear_power * 10500)
- + (self.wind_power * 500)
- + (self.coal_mines * 400)
- + (self.oil_wells * 600)
- + (self.iron_mines * 1600)
- + (self.bauxite_mines * 1600)
- + (self.lead_mines * 1500)
- + (self.uranium_mines * 5000)
- + (self.farms * 300)
- ) + (
- (
- (self.oil_refineries * 4000)
- + (self.steel_mills * 4000)
- + (self.aluminum_refineries * 2500)
- + (self.munitions_factories * 3500)
- + (self.police_stations * 750)
- + (self.hospitals * 1000)
- + (self.recycling_centers * 2500)
- + (self.subways * 3250)
- + (self.supermarkets * 600)
- + (self.banks * 1800)
- + (self.shopping_malls * 5400)
- + (self.stadiums * 12150)
- )
- if self.powered
- else 0
- )
- def calculate_food_upkeep(self):
- return self.population / 1000
- def calculate_coal_upkeep(self):
- return (self.coal_power * 1.2) + (
- (self.steel_mills * 3)
- * (1 + ((0.5 * (self.steel_mills - 1)) / (5 - 1)))
- * (1 + (0.36 * int(self.projects.ironw)))
- )
- def calculate_oil_upkeep(self):
- return (self.oil_power * 1.2) + (
- (self.oil_refineries * 3)
- * (1 + ((0.5 * (self.oil_refineries - 1)) / (5 - 1)))
- * (1 + (0.36 * int(self.projects.egr)))
- )
- def calculate_uranium_upkeep(self) -> float:
- amount = self.infrastructure // 1000
- if amount * 1000 < self.infrastructure:
- amount += 1
- amount = min(amount, self.nuclear_power * 2)
- return amount * 1.2
- def calculate_lead_upkeep(self) -> float:
- return (
- (self.munitions_factories * 6)
- * (1 + ((0.5 * (self.munitions_factories - 1)) / (5 - 1)))
- * (1 + (0.34 * int(self.projects.armss)))
- )
- def calculate_iron_upkeep(self) -> float:
- return (
- (self.steel_mills * 3)
- * (1 + ((0.5 * (self.steel_mills - 1)) / (5 - 1)))
- * (1 + (0.36 * int(self.projects.ironw)))
- )
- def calculate_bauxite_upkeep(self) -> float:
- return (
- (self.aluminum_refineries * 3)
- * (1 + ((0.5 * (self.aluminum_refineries - 1)) / (5 - 1)))
- * (1 + (0.36 * int(self.projects.bauxitew)))
- )
- def calculate_net_money_income(self, income_modifier: float = 1) -> float:
- return (
- self.calculate_money_income(income_modifier) - self.calculate_money_upkeep()
- )
- def calculate_net_food_income(self) -> float:
- return self.calculate_food_income() - self.calculate_food_upkeep()
- def calculate_net_coal_income(self) -> float:
- return self.calculate_coal_income() - self.calculate_coal_upkeep()
- def calculate_net_oil_income(self) -> float:
- return self.calculate_oil_income() - self.calculate_oil_upkeep()
- def calculate_net_uranium_income(self) -> float:
- return self.calculate_uranium_income() - self.calculate_uranium_upkeep()
- def calculate_net_lead_income(self) -> float:
- return self.calculate_lead_income() - self.calculate_lead_upkeep()
- def calculate_net_iron_income(self) -> float:
- return self.calculate_iron_income() - self.calculate_iron_upkeep()
- def calculate_net_bauxite_income(self) -> float:
- return self.calculate_bauxite_income() - self.calculate_bauxite_upkeep()
- calculate_net_gasoline_income = calculate_gasoline_income
- calculate_net_munitions_income = calculate_munitions_income
- calculate_net_steel_income = calculate_steel_income
- calculate_net_aluminum_income = calculate_aluminum_income
Add Comment
Please, Sign In to add comment