y_range_end = absolute_position.y + fov_radius
x_range_start = absolute_position.x - fov_radius
x_range_end = absolute_position.x + fov_radius
+ # TODO: refactor with SourcedMap.inside?
for position in self.changed_tiles:
if position.y < y_range_start\
or position.y > y_range_end:
from plomrogue.errors import PlayError, GameError
+from plomrogue.misc import quote
raise PlayError('cannot command this item type')
def do(self):
- from plomrogue.misc import quote
reply_lines = self.thing.carrying.interpret(self.args[0])
for line in reply_lines:
self.thing.send_msg('REPLY ' + quote(line))
remixer.accept(t)
break
else:
- from plomrogue.misc import quote
self.thing.game.hats[self.thing.name] = self.thing.carrying.design
self.thing.game.remove_thing(self.thing.carrying)
self.thing.carrying = None
self.thing.send_msg('CHAT "You put on a hat."')
+
+
+
+class Task_SPIN(Task):
+
+ def check(self):
+ if not self.thing.carrying:
+ raise PlayError('holding nothing to spin')
+ if not hasattr(self.thing.carrying, 'spinnable'):
+ raise PlayError('held object not spinnable')
+
+ def do(self):
+ self.thing.carrying.spin()
from plomrogue.errors import GameError, PlayError
from plomrogue.mapping import YX
+from plomrogue.misc import quote
import random
def sound(self, name, msg):
from plomrogue.mapping import DijkstraMap
- from plomrogue.misc import quote
def lower_msg_by_volume(msg, volume, largest_audible_distance):
import random
portable = True
full = True
thing_char = '~'
+ spinnable = True
def empty(self):
self.thing_char = '_'
self.full = False
+ def spin(self):
+ import random
+ all_players = [t for t in self.game.things if t.type_ == 'Player']
+ # TODO: refactor with ThingPlayer.prepare_multiprocessible_fov_stencil
+ # and ThingPlayer.fov_test
+ fov_map_class = self.game.map_geometry.fov_map_class
+ fov_radius = 12
+ fov = fov_map_class(self.game.things, self.game.maps,
+ self.position, fov_radius, self.game.get_map)
+ fov.init_terrain()
+ visible_players = []
+ for p in all_players:
+ test_position = fov.target_yx(p.position[0], p.position[1])
+ if fov.inside(test_position) and fov[test_position] == '.':
+ visible_players += [p]
+ if len(visible_players) == 0:
+ self.sound('BOTTLE', 'no visible players in spin range')
+ pick = random.choice(visible_players)
+ self.sound('BOTTLE', 'BOTTLE picks: ' + pick.name)
+
class Thing_BottleSpawner(ThingSpawner):
<button id="teleport"></button>
<button id="install"></button>
<button id="wear"></button>
+ <button id="spin"></button>
</td>
</tr>
<tr>
<li>help: <input id="key_help" type="text" value="h" />
<li>flatten surroundings: <input id="key_flatten" type="text" value="F" />
<li>teleport: <input id="key_teleport" type="text" value="p" />
+<li>spin: <input id="key_spin" type="text" value="S" />
<li>open/close: <input id="key_door" type="text" value="D" />
<li>consume: <input id="key_consume" type="text" value="C" />
<li>install: <input id="key_install" type="text" value="I" />
'consume': 'consume',
'install': '(un-)install',
'wear': '(un-)wear',
+ 'spin': 'spin',
'toggle_map_mode': 'toggle map view',
'toggle_tile_draw': 'toggle protection character drawing',
'hex_move_upleft': 'up-left',
'wear': 'WEAR',
'command': 'COMMAND',
'consume': 'INTOXICATE',
+ 'spin': 'SPIN',
},
offset: [0,0],
map_lines: [],
this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter",
"command_thing", "take_thing", "drop_thing"]
this.mode_play.available_actions = ["move", "teleport", "door", "consume",
- "install", "wear"];
+ "install", "wear", "spin"];
this.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
this.mode_study.available_actions = ["toggle_map_mode", "move_explorer"];
this.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type",
server.send(["TASK:INSTALL"]);
} else if (event.key === tui.keys.wear && tui.task_action_on('wear')) {
server.send(["TASK:WEAR"]);
+ } else if (event.key === tui.keys.spin && tui.task_action_on('spin')) {
+ server.send(["TASK:SPIN"]);
} else if (event.key in tui.movement_keys && tui.task_action_on('move')) {
server.send(['TASK:MOVE', tui.movement_keys[event.key]]);
} else if (event.key === tui.keys.teleport) {
document.getElementById("wear").onclick = function() {
server.send(['TASK:WEAR']);
};
+document.getElementById("spin").onclick = function() {
+ server.send(['TASK:SPIN']);
+};
document.getElementById("teleport").onclick = function() {
game.teleport();
};
from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP,
Task_DROP, Task_FLATTEN_SURROUNDINGS, Task_DOOR,
Task_INTOXICATE, Task_COMMAND, Task_INSTALL,
- Task_WEAR)
+ Task_WEAR, Task_SPIN)
from plomrogue.things import (Thing_Player, Thing_Item, Thing_ItemSpawner,
Thing_SpawnPoint, Thing_SpawnPointSpawner,
Thing_Door, Thing_DoorSpawner, Thing_Bottle,
game.register_task(Task_COMMAND)
game.register_task(Task_INSTALL)
game.register_task(Task_WEAR)
+game.register_task(Task_SPIN)
game.register_thing_type(Thing_Player)
game.register_thing_type(Thing_Item)
game.register_thing_type(Thing_ItemSpawner)
"command_thing", "take_thing",
"drop_thing"]
self.mode_play.available_actions = ["move", "teleport", "door", "consume",
- "install", "wear"]
+ "install", "wear", "spin"]
self.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
self.mode_study.available_actions = ["toggle_map_mode", "move_explorer"]
self.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type",
'door': 'D',
'install': 'I',
'wear': 'W',
+ 'spin': 'S',
'help': 'h',
'toggle_map_mode': 'L',
'toggle_tile_draw': 'm',
'wear': '(un-)wear',
'door': 'open/close',
'consume': 'consume',
+ 'spin': 'spin',
}
action_tasks = {
'move': 'MOVE',
'command': 'COMMAND',
'consume': 'INTOXICATE',
+ 'spin': 'SPIN',
}
curses.curs_set(False) # hide cursor
self.send('TASK:INSTALL')
elif key == self.keys['wear'] and task_action_on('wear'):
self.send('TASK:WEAR')
+ elif key == self.keys['spin'] and task_action_on('spin'):
+ self.send('TASK:SPIN')
elif key == self.keys['teleport']:
player = self.game.get_thing(self.game.player_id)
if player.position in self.game.portals: