-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnorthshire_abbey.py
115 lines (91 loc) · 5.47 KB
/
northshire_abbey.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""
A Module that will take care of loading creatures that are in the Northshire Abbey zone
This is created so that we don't have to load the creatures every time we change zones AND
to have dead creatures stay dead, not be reloaded
the cs in cs_alive_monsters and similar names stands for Current Subzone
"""
from zones.zone import Zone, SubZone
from constants import ZONE_MOVE_BLOCK_SPECIAL_KEY, GARRICK_PADFOOT_GUID
from scripts.zones.northshire_abbey.a_peculiar_hut.haskel_paxton_conversation import (
SCRIPT_NAME as A_PECULIAR_HUT_ENTRY_SCRIPT_NAME, script as A_PECULIAR_HUT_ENTRY_SCRIPT)
class NorthshireAbbey(Zone):
# the _map that shows us where we can go from our current subzone
zone_map = {"Northshire Valley": ["Northshire Vineyards"],
"Northshire Vineyards": ["Northshire Valley", "A Peculiar Hut"],
"A Peculiar Hut": ["Northshire Vineyards"]}
zone_name = "Northshire Abbey"
starter_subzone = "Northshire Valley"
# dictionary that will hold the subzone class objects
loaded_zones = {"Northshire Valley": None,
"Northshire Vineyards": None,
"A Peculiar Hut": None}
def __init__(self, character):
super().__init__()
subzone_object = NorthshireValley(name="Northshire Valley", parent_zone_name=self.zone_name,
zone_map=self.zone_map["Northshire Valley"],
character=character)
self.cs_alive_monsters, self.cs_monsters_guid_name_set = subzone_object.get_monsters()
self.cs_alive_npcs, self.cs_npcs_guid_name_set = subzone_object.get_npcs()
self.cs_available_quests = subzone_object.get_quests()
self.cs_map = subzone_object.get_map_directions()
self.curr_subzone = "Northshire Valley"
self.loaded_zones["Northshire Valley"] = subzone_object
def move_player(self, current_subzone: str, destination: str, character):
"""
:param current_subzone: the subzone the character is in
:param destination: the subzone he wants to go in
:return: a boolean indicating if the move is possible
"""
if current_subzone in self.zone_map.keys() and current_subzone == self.curr_subzone:
if destination in self.zone_map[current_subzone] and destination in self.loaded_zones.keys():
# Before moving:
# update the information for our current in case we've killed monsters or done quests for example
self._update_subzone_attributes(current_subzone)
if destination == "A Peculiar Hut":
# this means we are in Northshire Vineyards
if GARRICK_PADFOOT_GUID in self.cs_alive_monsters.keys(): # if garry padfoot is alive
print("Garrick Padfoot is blocking the way.")
return ZONE_MOVE_BLOCK_SPECIAL_KEY
if not self.loaded_zones[destination]: # if we don't have the destination's attributes loaded load them
self._load_zone(destination, character)
self.curr_subzone = destination
# We move, therefore update our attributes
self._update_attributes(destination)
return True
else:
raise Exception("The subzone is not in the zone_object!")
return False
def _load_zone(self, subzone: str, character):
# if we have not loaded the zone before, we need to initialize it's class and put it in the loaded_zones
if subzone == "Northshire Valley":
self.loaded_zones[subzone] = NorthshireValley(name=subzone,
parent_zone_name=self.zone_name,
zone_map=self.zone_map[subzone],
character=character)
elif subzone == "Northshire Vineyards":
self.loaded_zones[subzone] = NorthshireVineyards(name=subzone,
parent_zone_name=self.zone_name,
zone_map=self.zone_map[subzone],
character=character)
elif subzone == "A Peculiar Hut":
self.loaded_zones[subzone] = PeculiarHut(name=subzone,
parent_zone_name=self.zone_name,
zone_map=self.zone_map[subzone],
character=character)
def engage_zone_entered_script(self, character):
subzone = character.current_subzone
if subzone == "A Peculiar Hut" and not character.has_loaded_script(A_PECULIAR_HUT_ENTRY_SCRIPT_NAME):
# only A Peculiar Hut has a script that starts on the first entry
character.load_script(A_PECULIAR_HUT_ENTRY_SCRIPT_NAME)
self.loaded_zones[subzone].load_on_zone_entry_script(character)
class NorthshireValley(SubZone):
pass
class NorthshireVineyards(SubZone):
pass
class PeculiarHut(SubZone):
GUID_BROTHER_PAXTON = 15
GUID_BROTHER_HASKEL = 16
def __init__(self, name: str, parent_zone_name: str, zone_map: list, character):
super().__init__(name, parent_zone_name, zone_map, character)
def load_on_zone_entry_script(self, character):
A_PECULIAR_HUT_ENTRY_SCRIPT(self, character)