Browse Source

Add rival_regions_calc with pipfile and regions

JoostSijm 5 years ago
parent
commit
4780dbdf22
3 changed files with 170 additions and 0 deletions
  1. 12 0
      Pipfile
  2. 29 0
      Pipfile.lock
  3. 129 0
      regions.py

+ 12 - 0
Pipfile

@@ -0,0 +1,12 @@
+[[source]]
+name = "pypi"
+url = "https://pypi.org/simple"
+verify_ssl = true
+
+[dev-packages]
+
+[packages]
+rival-regions-calc = "*"
+
+[requires]
+python_version = "3.7"

+ 29 - 0
Pipfile.lock

@@ -0,0 +1,29 @@
+{
+    "_meta": {
+        "hash": {
+            "sha256": "a9eba710da02c79738e73b192e3a095f15858579db1892d61e3be8ad99b6b482"
+        },
+        "pipfile-spec": 6,
+        "requires": {
+            "python_version": "3.7"
+        },
+        "sources": [
+            {
+                "name": "pypi",
+                "url": "https://pypi.org/simple",
+                "verify_ssl": true
+            }
+        ]
+    },
+    "default": {
+        "rival-regions-calc": {
+            "hashes": [
+                "sha256:79d4e9489a2ba7cdd9e143d58f68a5a0b4c2f810bdbe8618555894aa3bed4390",
+                "sha256:cd4f7c3d7565fa5aa4b36cb634bd541ca42f986456768301b15b589777238d52"
+            ],
+            "index": "pypi",
+            "version": "==1.0.0"
+        }
+    },
+    "develop": {}
+}

+ 129 - 0
regions.py

@@ -0,0 +1,129 @@
+"""Calculate VN REGIONS"""
+
+from rival_regions_calc import Item, DeepExploration, ResourceCoefficient
+
+TOTAL_COSTS = False
+GOLD_PRICE = 0.35
+#DIAMOND_PRICE = 1600690
+DIAMOND_PRICE = 1664000
+REGIONS = {
+    '4001': {
+        'name': 'Northern Netherlands',
+        'resources': {
+            'gold': 379,
+            'oil': 223,
+            'ore': 247,
+            'uranium': 2,
+            'diamond': 2,
+        },
+    },
+    '4002': {
+        'name': 'Eastern Netherlands',
+        'resources': {
+            'gold': 359,
+            'oil': 266,
+            'ore': 250,
+            'uranium': 2,
+            'diamond': 2,
+        },
+    },
+    '4003': {
+        'name': 'Western Netherlands',
+        'resources': {
+            'gold': 372,
+            'oil': 296,
+            'ore': 230,
+            'uranium': 2,
+            'diamond': 2,
+        },
+    },
+    '4004': {
+        'name': 'Southern Netherlands',
+        'resources': {
+            'gold': 366,
+            'oil': 296,
+            'ore': 211,
+            'uranium': 2,
+            'diamond': 2,
+        },
+    },
+    '4008': {
+        'name': 'Amsterdam',
+        'resources': {
+            'gold': 418,
+            'oil': 307,
+            'ore': 303,
+            'uranium': 4,
+            'diamond': 13,
+        },
+    },
+    '4801': {
+        'name': 'Luxembourg',
+        'resources': {
+            'gold': 435,
+            'oil': 283,
+            'ore': 267,
+            'uranium': 2,
+            'diamond': 2,
+        },
+    }
+}
+
+def calc_regions():
+    """Calculate deep exploration"""
+    if TOTAL_COSTS:
+        print("Resource             cash    old    new  grow %")
+    else:
+        print("Resource      dia    old    new  grow %")
+    for region in REGIONS.values():
+        print(region['name'])
+        for resource, limit in region['resources'].items():
+            resource = Item(resource)
+            deep_exploration = DeepExploration(resource, limit)
+            deep_exploration.calculate_max()
+
+            old_koef = ResourceCoefficient(
+                resource,
+                limit
+            ).calculate()
+            new_koef = ResourceCoefficient(
+                resource,
+                deep_exploration.resource.get_max()
+            ).calculate()
+
+            koef_increase = 100 / old_koef * new_koef - 100
+            print_prices(deep_exploration, old_koef, new_koef, koef_increase)
+
+
+def bucks(integer):
+    """Format number"""
+    return '{:,}'.format(integer).replace(',', '.')
+
+
+def print_prices(deep_exploration, old_koef, new_koef, koef_increase):
+    """print costs"""
+    if TOTAL_COSTS:
+        total_cash = round(
+            deep_exploration.gold * GOLD_PRICE \
+            + deep_exploration.diamond * DIAMOND_PRICE \
+            + deep_exploration.cash
+        )
+        print("%8s %16s %6.2f %6.2f %7.2f" % (
+            deep_exploration.resource.name,
+            bucks(total_cash),
+            old_koef,
+            new_koef,
+            koef_increase,
+        ))
+    else:
+        print("%-8s% 9s% 7.2f% 7.2f %7.2f" % (
+            deep_exploration.resource.name,
+            bucks(deep_exploration.diamond),
+            old_koef,
+            new_koef,
+            koef_increase,
+        ))
+
+
+if __name__ == "__main__":
+    calc_regions()