regions.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. """Calculate VN REGIONS"""
  2. from rival_regions_calc import Item, DeepExploration, ResourceCoefficient
  3. TOTAL_COSTS = True
  4. PRINT_AVERAGE = False
  5. GOLD_PRICE = 0.15
  6. #DIAMOND_PRICE = 1600690
  7. DIAMOND_PRICE = 1684000
  8. REGIONS = {
  9. '4001': {
  10. 'name': 'Northern Netherlands',
  11. 'resources': {
  12. 'gold': 379,
  13. 'oil': 223,
  14. 'ore': 247,
  15. 'uranium': 2,
  16. 'diamond': 2,
  17. },
  18. },
  19. '4002': {
  20. 'name': 'Eastern Netherlands',
  21. 'resources': {
  22. 'gold': 359,
  23. 'oil': 266,
  24. 'ore': 250,
  25. 'uranium': 2,
  26. 'diamond': 2,
  27. },
  28. },
  29. '4003': {
  30. 'name': 'Western Netherlands',
  31. 'resources': {
  32. 'gold': 372,
  33. 'oil': 296,
  34. 'ore': 230,
  35. 'uranium': 2,
  36. 'diamond': 2,
  37. },
  38. },
  39. '4004': {
  40. 'name': 'Southern Netherlands',
  41. 'resources': {
  42. 'gold': 366,
  43. 'oil': 296,
  44. 'ore': 211,
  45. 'uranium': 2,
  46. 'diamond': 2,
  47. },
  48. },
  49. '4008': {
  50. 'name': 'Amsterdam',
  51. 'resources': {
  52. 'gold': 418,
  53. 'oil': 307,
  54. 'ore': 303,
  55. 'uranium': 4,
  56. 'diamond': 13,
  57. },
  58. },
  59. }
  60. TOTAL = {
  61. 'gold': {
  62. 'koef_increase': 0,
  63. 'total_cash': 0,
  64. },
  65. 'oil': {
  66. 'koef_increase': 0,
  67. 'total_cash': 0,
  68. },
  69. 'ore': {
  70. 'koef_increase': 0,
  71. 'total_cash': 0,
  72. },
  73. 'uranium': {
  74. 'koef_increase': 0,
  75. 'total_cash': 0,
  76. },
  77. 'diamond': {
  78. 'koef_increase': 0,
  79. 'total_cash': 0,
  80. },
  81. }
  82. def calc_regions():
  83. """Calculate deep exploration"""
  84. if TOTAL_COSTS:
  85. print("Resource cash old new grow %")
  86. else:
  87. print("Resource dia old new grow %")
  88. for region in REGIONS.values():
  89. print(region['name'])
  90. for resource, limit in region['resources'].items():
  91. resource = Item(resource)
  92. deep_exploration = DeepExploration(resource, limit)
  93. deep_exploration.calculate_max()
  94. old_koef = ResourceCoefficient(
  95. resource,
  96. limit
  97. ).calculate()
  98. new_koef = ResourceCoefficient(
  99. resource,
  100. deep_exploration.resource.get_max()
  101. ).calculate()
  102. koef_increase = 100 / old_koef * new_koef - 100
  103. print_prices(deep_exploration, old_koef, new_koef, koef_increase)
  104. if PRINT_AVERAGE:
  105. print_average()
  106. def bucks(integer):
  107. """Format number"""
  108. return '{:,}'.format(integer).replace(',', '.')
  109. def print_prices(deep_exploration, old_koef, new_koef, koef_increase):
  110. """print costs"""
  111. total_cash = None
  112. if TOTAL_COSTS or PRINT_AVERAGE:
  113. total_cash = round(
  114. deep_exploration.gold * GOLD_PRICE \
  115. + deep_exploration.diamond * DIAMOND_PRICE \
  116. + deep_exploration.cash
  117. )
  118. if TOTAL_COSTS:
  119. print("%8s %16s %6.2f %6.2f %7.2f" % (
  120. deep_exploration.resource.name,
  121. bucks(total_cash),
  122. old_koef,
  123. new_koef,
  124. koef_increase,
  125. ))
  126. elif PRINT_AVERAGE:
  127. TOTAL[deep_exploration.resource.name]['koef_increase'] += koef_increase
  128. TOTAL[deep_exploration.resource.name]['total_cash'] += total_cash
  129. else:
  130. print("%-8s% 9s% 7.2f% 7.2f %7.2f" % (
  131. deep_exploration.resource.name,
  132. bucks(deep_exploration.diamond),
  133. old_koef,
  134. new_koef,
  135. koef_increase,
  136. ))
  137. def print_average():
  138. """Calculate and print average"""
  139. for resource, values in TOTAL.items():
  140. print(resource)
  141. print("{:15,} - {:5}".format(
  142. round(values['total_cash']/5),
  143. round(values['koef_increase']/5),
  144. ))
  145. if __name__ == "__main__":
  146. calc_regions()