-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,
cmd_TURN, cmd_MAP_LINE)
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,
directions += [name[5:]]
return directions
+ def get_neighbors(self, pos):
+ neighbors = {}
+ for direction in self.get_directions():
+ neighbors[direction] = self.move(pos, direction)
+ return neighbors
+
def move(self, start_pos, direction):
mover = getattr(self, 'move_' + direction)
target = mover(start_pos)
def do(self):
self.thing.game.map[self.thing.position] = self.args[0]
+
+
+
+class Task_FLATTEN_SURROUNDINGS(Task):
+ todo = 10
+
+ def check(self):
+ pass
+
+ def do(self):
+ self.thing.game.map[self.thing.position] = '.'
+ for yx in self.thing.game.map_geometry.get_neighbors(self.thing.position).values():
+ if yx is not None:
+ self.thing.game.map[yx] = '.'
tui.draw_history();
tui.draw_input_line();
-tui.log_msg("commands:", 1);
+tui.log_msg("basic commands:", 1);
tui.log_msg("LOGIN USER - register as USER", 3);
tui.log_msg("ALL TEXT - send TEXT to all users", 3);
tui.log_msg("QUERY USER TEXT - send TEXT to USER", 3);
tui.log_msg("");
tui.log_msg("To change the map cell you are standing on, type the desired ASCII character into the prompt and hit Return.", 1);
tui.log_msg("");
+tui.log_msg("more commands:", 1);
+tui.log_msg("FLATTEN - transform surrounding map cells to \".\" ones", 3);
+tui.log_msg("");
document.addEventListener('keydown', (event) => {
if (chat.input_line === '') {
} else if (event.key === 'Enter') {
if (chat.input_line.length === 1) {
websocket.send("TASK:WRITE " + chat.input_line);
+ } else if (chat.input_line.trimEnd() === 'FLATTEN') {
+ websocket.send("TASK:FLATTEN_SURROUNDINGS");
} else {
websocket.send(chat.input_line);
}