-
Notifications
You must be signed in to change notification settings - Fork 1
/
Southeros.py
71 lines (61 loc) · 2.18 KB
/
Southeros.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from kingdom import Kingdom
class Southeros:
"""Class to contain the World of Southeros"""
def __init__(self, kingdoms=[]):
"""
Args:
kingdoms (list of tuple of str,str): List of Kingdoms and their emblems,
defaults to empty List
"""
self.__rulingKingdom = None
self.__kingdom_count = 0
self.register_kingdoms(kingdoms)
def register_kingdom(self, name, emblem):
"""Creates a Kingdom Class for the given kingdom name and emblem
Args:
name (string): Name of the Kingdom
emblem (string): Emblem of the Kingdom
Returns:
Kingdom Object: Return the new kingdom object
"""
new_kingdom = Kingdom(name, emblem)
self.__kingdom_count += 1
return new_kingdom
def register_kingdoms(self, kingdoms):
"""Registers all the kingdoms
Args:
kingdoms (list of tuple of str,str): List of Kingdoms and their emblems
"""
for name, emblem in kingdoms:
self.register_kingdom(name, emblem)
def get_kingdom(self, name):
"""Get the Kingdom Object from the Name of the kingdom
Args:
name (string): Name of the Kingdom
Returns:
Kingdom Object: Kingdom Object for the given name
Raises:
KingdomNotFound:
If no Kingdom is found for the kingdom name passed in as a parameter.
"""
return Kingdom.get_kingdom(name)
def ruler(self):
"""Get the Ruler of Southeros
Returns:
Kingdom Object: Ruling Kingdom Object otherwise None
"""
if self.__rulingKingdom == None:
self.__rulingKingdom = self.__ruling_kingdom()
return self.__rulingKingdom
def __ruling_kingdom(self):
"""Get the Ruler of Southeros
Returns:
Kingdom Object: Ruling Kingdom Object otherwise None
"""
return Kingdom.get_ruler()
def get_total_kingdoms(self):
"""Return the count of Total Kingdoms in Southeros
Returns:
int: Total count of Kingdoms
"""
return self.__kingdom_count