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/static/gitweb.css?a=blobdiff_plain;f=new2%2Fplomrogue%2Fgame.py;h=25f4d809b69b04083abb4bcea83996608920ee42;hb=1dc47266dcb1f7f692a7e993d2fb0bfb9f7ceeb1;hp=a8fc4edf08bd037175b9d9e70b3f1f60ba543449;hpb=09a7a28a19b56662eccceb5785fd36265845c15c;p=plomrogue2-experiments diff --git a/new2/plomrogue/game.py b/new2/plomrogue/game.py index a8fc4ed..25f4d80 100755 --- a/new2/plomrogue/game.py +++ b/new2/plomrogue/game.py @@ -1,10 +1,10 @@ -from plomrogue.tasks import Task_WAIT, Task_MOVE +from plomrogue.tasks import Task_WAIT, Task_MOVE, Task_WRITE from plomrogue.errors import GameError -from plomrogue.commands import cmd_ALL, cmd_LOGIN, cmd_QUERY +from plomrogue.commands import cmd_ALL, cmd_LOGIN, cmd_QUERY, cmd_PING from plomrogue.io import GameIO from plomrogue.misc import quote from plomrogue.things import Thing, ThingPlayer -from plomrogue.mapping import YX, MapGeometrySquare +from plomrogue.mapping import YX, MapGeometrySquare, Map @@ -36,18 +36,25 @@ class Game(GameBase): self.changed = True self.io = GameIO(self) self.tasks = {'WAIT': Task_WAIT, - 'MOVE': Task_MOVE} + 'MOVE': Task_MOVE, + 'WRITE': Task_WRITE} self.map_geometry = MapGeometrySquare(YX(24, 40)) self.commands = {'QUERY': cmd_QUERY, 'ALL': cmd_ALL, - 'LOGIN': cmd_LOGIN} + 'LOGIN': cmd_LOGIN, + 'PING': cmd_PING} self.thing_type = Thing self.thing_types = {'player': ThingPlayer} self.sessions = {} + self.map = Map(self.map_geometry.size) def get_string_options(self, string_option_type): + import string if string_option_type == 'direction': return self.map_geometry.get_directions() + if string_option_type == 'char': + return [c for c in + string.digits + string.ascii_letters + string.punctuation] return None def send_gamestate(self, connection_id=None): @@ -59,6 +66,7 @@ class Game(GameBase): self.io.send('TURN ' + str(self.turn)) for t in self.things: send_thing(t) + self.io.send('MAP %s %s' % (self.map_geometry.size, quote(self.map.terrain))) self.io.send('GAME_STATE_COMPLETE') def run_tick(self):