"""Calculate VN REGIONS""" from rival_regions_calc import Item, DeepExploration, ResourceCoefficient TOTAL_COSTS = True PRINT_AVERAGE = False GOLD_PRICE = 0.15 #DIAMOND_PRICE = 1600690 DIAMOND_PRICE = 1684000 REGIONS = { '4001': { 'name': 'Northern Netherlands', 'resources': { 'gold': 379, 'oil': 223, 'ore': 247, 'uranium': 2, 'diamond': 2, }, }, '4002': { 'name': 'Eastern Netherlands', 'resources': { 'gold': 359, 'oil': 266, 'ore': 250, 'uranium': 2, 'diamond': 2, }, }, '4003': { 'name': 'Western Netherlands', 'resources': { 'gold': 372, 'oil': 296, 'ore': 230, 'uranium': 2, 'diamond': 2, }, }, '4004': { 'name': 'Southern Netherlands', 'resources': { 'gold': 366, 'oil': 296, 'ore': 211, 'uranium': 2, 'diamond': 2, }, }, '4008': { 'name': 'Amsterdam', 'resources': { 'gold': 418, 'oil': 307, 'ore': 303, 'uranium': 4, 'diamond': 13, }, }, } TOTAL = { 'gold': { 'koef_increase': 0, 'total_cash': 0, }, 'oil': { 'koef_increase': 0, 'total_cash': 0, }, 'ore': { 'koef_increase': 0, 'total_cash': 0, }, 'uranium': { 'koef_increase': 0, 'total_cash': 0, }, 'diamond': { 'koef_increase': 0, 'total_cash': 0, }, } def calc_regions(): """Calculate deep exploration""" if TOTAL_COSTS: print("Resource cash old new grow %") else: print("Resource dia old new grow %") for region in REGIONS.values(): print(region['name']) for resource, limit in region['resources'].items(): resource = Item(resource) deep_exploration = DeepExploration(resource, limit) deep_exploration.calculate_max() old_koef = ResourceCoefficient( resource, limit ).calculate() new_koef = ResourceCoefficient( resource, deep_exploration.resource.get_max() ).calculate() koef_increase = 100 / old_koef * new_koef - 100 print_prices(deep_exploration, old_koef, new_koef, koef_increase) if PRINT_AVERAGE: print_average() def bucks(integer): """Format number""" return '{:,}'.format(integer).replace(',', '.') def print_prices(deep_exploration, old_koef, new_koef, koef_increase): """print costs""" total_cash = None if TOTAL_COSTS or PRINT_AVERAGE: total_cash = round( deep_exploration.gold * GOLD_PRICE \ + deep_exploration.diamond * DIAMOND_PRICE \ + deep_exploration.cash ) if TOTAL_COSTS: print("%8s %16s %6.2f %6.2f %7.2f" % ( deep_exploration.resource.name, bucks(total_cash), old_koef, new_koef, koef_increase, )) elif PRINT_AVERAGE: TOTAL[deep_exploration.resource.name]['koef_increase'] += koef_increase TOTAL[deep_exploration.resource.name]['total_cash'] += total_cash else: print("%-8s% 9s% 7.2f% 7.2f %7.2f" % ( deep_exploration.resource.name, bucks(deep_exploration.diamond), old_koef, new_koef, koef_increase, )) def print_average(): """Calculate and print average""" for resource, values in TOTAL.items(): print(resource) print("{:15,} - {:5}".format( round(values['total_cash']/5), round(values['koef_increase']/5), )) if __name__ == "__main__": calc_regions()