regions.py 3.2 KB

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