didier/database/utils/math/currency.py

85 lines
2.0 KiB
Python
Raw Permalink Normal View History

import math
2024-02-20 16:21:51 +01:00
__all__ = [
"capacity_upgrade_price",
"interest_upgrade_price",
"rob_upgrade_price",
2024-03-01 14:18:58 +01:00
"interest_rate",
"savings_cap",
2024-02-20 16:21:51 +01:00
"jail_chance",
"jail_time",
"rob_amount",
"rob_chance",
]
2022-07-11 22:23:38 +02:00
def interest_upgrade_price(level: int) -> int:
"""Calculate the price to upgrade your interest level"""
base_cost = 600
growth_rate = 1.8
2024-03-01 14:18:58 +01:00
return math.floor(base_cost * (growth_rate ** (level - 1)))
def capacity_upgrade_price(level: int) -> int:
"""Calculate the price to upgrade your capacity level"""
base_cost = 800
growth_rate = 1.6
2024-03-01 14:18:58 +01:00
return math.floor(base_cost * (growth_rate ** (level - 1)))
def rob_upgrade_price(level: int) -> int:
"""Calculate the price to upgrade your rob level"""
base_cost = 950
growth_rate = 1.9
2024-03-01 14:18:58 +01:00
return math.floor(base_cost * (growth_rate ** (level - 1)))
def interest_rate(level: int) -> float:
"""Calculate the amount of interest you will receive"""
base_rate = 1.025
growth_rate = 0.03
return base_rate + (growth_rate * (level - 1))
def savings_cap(level: int) -> int:
"""Calculate the maximum amount you can save"""
base_limit = 1000
growth_rate = 1.10
return math.floor(base_limit * (growth_rate ** (level - 1)))
2024-02-20 16:21:51 +01:00
def jail_chance(level: int) -> float:
"""Calculate the chance that you'll end up in jail"""
base_chance = 0.35
growth_rate = 1.15
2024-02-20 18:20:41 +01:00
return min(0.1, max(0.0, base_chance - (growth_rate**level)))
2024-02-20 16:21:51 +01:00
def jail_time(level: int) -> int:
"""Calculate the time in hours you'll have to spend in jail"""
base_hours = 2
growth_rate = 1.27
return math.floor(base_hours + growth_rate**level)
def rob_amount(level: int) -> int:
"""Calculate the maximum amount of Didier Dinks that you can rob"""
base_amount = 250
growth_rate = 1.4
return math.floor(base_amount * (growth_rate**level))
def rob_chance(level: int) -> float:
"""Calculate the chances of a robbing attempt being successful"""
base_chance = 0.25
return base_chance + 2.1 * level