"""Calculate efficiency in different departments""" import json from rival_regions_calc import Item, WorkProduction DEPARTMENTS = None with open('departments.json') as file: DEPARTMENTS = json.load(file) PRICE = None with open('prices.json') as file: PRICE = json.load(file) REGIONS = None with open('regions.json') as file: REGIONS = json.load(file) WP = WorkProduction() WP.user_level = 80 WP.work_exp = 80000 + 200 * 250 def calculate_wage(resource_name, department_bonus): """Calculate production""" resource = Item(resource_name) WP.resource = resource WP.factory_level = 150 WP.department_bonus = department_bonus WP.resource_max = REGIONS['1']['resources'][resource_name] WP.wage_percentage = 100 WP.tax_rate = 0 WP.calculate() return WP.wage() * PRICE[resource_name] def main(): """Main function""" resources = { 'oil': {}, 'ore': {}, 'uranium': {}, 'diamond': {}, } for resource in resources: for points in range(0, 6001, 200): if points >= DEPARTMENTS[resource]: department_bonus = 10 else: department_bonus = 10 / DEPARTMENTS[resource] * points resources[resource][points] = calculate_wage(resource, department_bonus) print('points,oil,ore,uranium,diamond') for points in range(0, 6001, 200): print('{},{},{},{},{}'.format( int(points), round(resources['oil'][points]), round(resources['ore'][points]), round(resources['uranium'][points]), round(resources['diamond'][points]), )) def print_json(json_text): """Print data to console""" print(json.dumps(json_text, sort_keys=True, indent=4)) if __name__ == '__main__': main()