X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/form?a=blobdiff_plain;f=plomrogue%2Fgame.py;h=47f09d161ceff332b2e8ad43f086161d9ad75854;hb=88c8acab582aeb25735d86b78defe28441439cba;hp=49fdeeb007e73364baa41af166a7c7bf39f35464;hpb=800aca691b359f448599160ba3d8aef28174596d;p=plomrogue2 diff --git a/plomrogue/game.py b/plomrogue/game.py index 49fdeeb..47f09d1 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -3,6 +3,7 @@ from plomrogue.io import GameIO from plomrogue.misc import quote from plomrogue.mapping import YX, MapGeometrySquare, MapGeometryHex, Map import string +import datetime @@ -120,6 +121,8 @@ class Game(GameBase): self.tasks = {} self.thing_types = {} self.sessions = {} + self.faces = {} + self.hats = {} self.maps = {} self.map_controls = {} self.map_control_passwords = {} @@ -129,6 +132,9 @@ class Game(GameBase): self.player_chars = string.digits + string.ascii_letters self.player_char_i = -1 self.admin_passwords = [] + self.send_gamestate_interval = datetime.timedelta(seconds=0.04) + self.last_send_gamestate = datetime.datetime.now() -\ + self.send_gamestate_interval self.terrains = { '.': 'floor', 'X': 'wall', @@ -159,6 +165,12 @@ class Game(GameBase): print("FILE INPUT LINE %5s: %s" % (i, line), end='') self.io.handle_input(line, god_mode=True) + def can_do_thing_with_pw(self, thing, pw): + if thing.protection in self.map_control_passwords.keys(): + if pw != self.map_control_passwords[thing.protection]: + return False + return True + def can_do_tile_with_pw(self, big_yx, little_yx, pw): map_control = self.get_map(big_yx, 'control') tile_class = map_control[little_yx] @@ -170,7 +182,7 @@ class Game(GameBase): def get_string_options(self, string_option_type): if string_option_type == 'direction': - return self.map_geometry.get_directions() + return self.map_geometry.directions elif string_option_type == 'char': return [c for c in string.digits + string.ascii_letters + string.punctuation + ' '] @@ -189,11 +201,36 @@ class Game(GameBase): player = self.get_thing(self.sessions[connection_id]['thing_id']) return player + def get_face(self, t): + if t.type_ == 'Player': + if t.name in self.faces: + return self.faces[t.name] + else: + return '/O O\\' + '| oo |' + '\\>--