home
·
contact
·
privacy
projects
/
plomrogue2-experiments
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add FLATTEN_SURROUNDINGS task.
[plomrogue2-experiments]
/
new2
/
plomrogue
/
game.py
diff --git
a/new2/plomrogue/game.py
b/new2/plomrogue/game.py
index 6325fd0d0849dc9ef37df9612046fcf92f54ba1d..55f7c726a9020f07850e6dcb80c094c4481d8841 100755
(executable)
--- a/
new2/plomrogue/game.py
+++ b/
new2/plomrogue/game.py
@@
-1,7
+1,8
@@
-from plomrogue.tasks import Task_WAIT, Task_MOVE, Task_WRITE
+from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE,
+ Task_FLATTEN_SURROUNDINGS)
from plomrogue.errors import GameError
from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_QUERY, cmd_PING,
from plomrogue.errors import GameError
from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_QUERY, cmd_PING,
- cmd_
SAVE, cmd_
TURN, cmd_MAP_LINE)
+ cmd_TURN, cmd_MAP_LINE)
from plomrogue.io import GameIO
from plomrogue.misc import quote
from plomrogue.things import Thing, ThingPlayer
from plomrogue.io import GameIO
from plomrogue.misc import quote
from plomrogue.things import Thing, ThingPlayer
@@
-39,12
+40,12
@@
class Game(GameBase):
self.io = GameIO(self, save_file)
self.tasks = {'WAIT': Task_WAIT,
'MOVE': Task_MOVE,
self.io = GameIO(self, save_file)
self.tasks = {'WAIT': Task_WAIT,
'MOVE': Task_MOVE,
- 'WRITE': Task_WRITE}
+ 'WRITE': Task_WRITE,
+ 'FLATTEN_SURROUNDINGS': Task_FLATTEN_SURROUNDINGS}
self.map_geometry = MapGeometrySquare(YX(24, 40))
self.commands = {'QUERY': cmd_QUERY,
'ALL': cmd_ALL,
'LOGIN': cmd_LOGIN,
self.map_geometry = MapGeometrySquare(YX(24, 40))
self.commands = {'QUERY': cmd_QUERY,
'ALL': cmd_ALL,
'LOGIN': cmd_LOGIN,
- 'SAVE': cmd_SAVE,
'TURN': cmd_TURN,
'MAP_LINE': cmd_MAP_LINE,
'PING': cmd_PING}
'TURN': cmd_TURN,
'MAP_LINE': cmd_MAP_LINE,
'PING': cmd_PING}
@@
-106,6
+107,7
@@
class Game(GameBase):
self.turn += 1
self.send_gamestate()
self.changed = False
self.turn += 1
self.send_gamestate()
self.changed = False
+ self.save()
def get_command(self, command_name):
def get_command(self, command_name):
@@
-149,3
+151,13
@@
class Game(GameBase):
# the more obvious indicators that it does – that's why there's
# no safeguard here against this.
return self.things[-1].id_ + 1
# the more obvious indicators that it does – that's why there's
# no safeguard here against this.
return self.things[-1].id_ + 1
+
+ def save(self):
+
+ def write(f, msg):
+ f.write(msg + '\n')
+
+ with open(self.io.save_file, 'w') as f:
+ write(f, 'TURN %s' % self.turn)
+ for y, line in self.map.lines():
+ write(f, 'MAP_LINE %5s %s' % (y, quote(line)))