factory_workers.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. """Calculate wage"""
  2. import json
  3. import operator
  4. from rival_regions_calc import Item, WorkProduction
  5. RESOURCEPRICE = 2500
  6. RESOURCE = Item("uranium")
  7. WP = WorkProduction(RESOURCE)
  8. WP.factory_level = 165
  9. WP.resource_max = 25
  10. WP.department_bonus = 7.2
  11. WP.wage_percentage = 100
  12. WP.tax_rate = 0
  13. def main():
  14. """Main function"""
  15. print("resource price : $ {:9}".format(RESOURCEPRICE))
  16. print("tax rate : {:9} %".format(WP.tax_rate))
  17. print("factory level : {:9}".format(WP.factory_level))
  18. print("department bonus : {:9} %".format(WP.department_bonus))
  19. print()
  20. workers = None
  21. with open('workers.json') as file:
  22. workers = json.load(file)
  23. for worker in workers.values():
  24. WP.user_level = worker['level']
  25. WP.work_exp = 80000 + 200 * worker['education']
  26. WP.calculate()
  27. worker['production'] = round(WP.wage())
  28. print(worker['production'])
  29. print('WORKER WAGE')
  30. print_worker_wage(workers)
  31. print()
  32. print('WORKER PRODUCTION')
  33. print_worker_production(workers)
  34. def print_worker_wage(workers):
  35. """Print worker wage percentage"""
  36. print("NAME % H PROFIT")
  37. for worker in workers.values():
  38. calculated_wage = worker['production'] * RESOURCEPRICE
  39. worker['procent'] = 100 / calculated_wage * worker['wage'] - 100
  40. worker['hour_difference'] = round(calculated_wage - worker['wage']) * 180
  41. for worker in sorted(workers.values(), key=operator.itemgetter('procent'), reverse=True):
  42. print("{:20}: {:6.2f} {:8,}kk".format(
  43. worker['name'],
  44. worker['procent'],
  45. round(worker['hour_difference'] / 1000000),
  46. ).replace(',', '.'))
  47. def print_worker_production(workers):
  48. """Calculate production"""
  49. print("NAME 24 H PROD %")
  50. for worker in sorted(workers.values(), key=operator.itemgetter('production'), reverse=True):
  51. print("{:20}: {:6,.0f} {:6.2f}".format(
  52. worker['name'],
  53. worker['production'] * 4320,
  54. 100 / 2400000000 * (worker['production'] * 4320),
  55. ).replace(',', '.'))
  56. if __name__ == "__main__":
  57. main()