efficiency.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. """Calculate efficiency in different departments"""
  2. import json
  3. from rival_regions_calc import Item, WorkProduction
  4. DEPARTMENTS = None
  5. with open('departments.json') as file:
  6. DEPARTMENTS = json.load(file)
  7. PRICE = None
  8. with open('prices.json') as file:
  9. PRICE = json.load(file)
  10. REGIONS = None
  11. with open('regions.json') as file:
  12. REGIONS = json.load(file)
  13. WP = WorkProduction()
  14. WP.user_level = 80
  15. WP.work_exp = 80000 + 200 * 250
  16. def calculate_wage(resource_name, department_bonus):
  17. """Calculate production"""
  18. resource = Item(resource_name)
  19. WP.resource = resource
  20. WP.factory_level = 150
  21. WP.department_bonus = department_bonus
  22. WP.resource_max = REGIONS['1']['resources'][resource_name]
  23. WP.wage_percentage = 100
  24. WP.tax_rate = 0
  25. WP.calculate()
  26. return WP.wage() * PRICE[resource_name]
  27. def main():
  28. """Main function"""
  29. resources = {
  30. 'oil': {},
  31. 'ore': {},
  32. 'uranium': {},
  33. 'diamond': {},
  34. }
  35. for resource in resources:
  36. for points in range(0, 6001, 200):
  37. if points >= DEPARTMENTS[resource]:
  38. department_bonus = 10
  39. else:
  40. department_bonus = 10 / DEPARTMENTS[resource] * points
  41. resources[resource][points] = calculate_wage(resource, department_bonus)
  42. print('points,oil,ore,uranium,diamond')
  43. for points in range(0, 6001, 200):
  44. print('{},{},{},{},{}'.format(
  45. int(points),
  46. round(resources['oil'][points]),
  47. round(resources['ore'][points]),
  48. round(resources['uranium'][points]),
  49. round(resources['diamond'][points]),
  50. ))
  51. def print_json(json_text):
  52. """Print data to console"""
  53. print(json.dumps(json_text, sort_keys=True, indent=4))
  54. if __name__ == '__main__':
  55. main()