-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathempire.py
41 lines (30 loc) · 1.11 KB
/
empire.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from constants import Constant
import string
import random
import numpy as np
class Empire:
def __init__(self, imperialist):
self.imperialist = imperialist
self.colonies = []
self.cost = self.calculateCost()
self.name = ''.join(random.choices(string.ascii_uppercase, k=2))
def calculateCost(self):
colony_count = 1
if len(self.colonies) > 0: colony_count = len(self.colonies)
return (self.imperialist.getCost() + (np.sum([colony.getCost() for colony in self.colonies]) * Constant.EMPIRE_COST_RATE)) / colony_count
def deleteColony(self, index):
del self.colonies[index]
self.cost = self.calculateCost()
def getCost(self):
return self.cost
def addColony(self, colony):
self.colonies.insert(len(self.colonies), colony)
self.cost = self.calculateCost()
def getColonies(self):
return self.colonies
def getColoniesCount(self):
return len(self.getColonies())
def getColony(self, index):
return self.colonies[index]
def getImperialist(self):
return self.imperialist