self.players_hat_chars = {}
self.player_char_i = -1
self.admin_passwords = []
- self.send_gamestate_interval = datetime.timedelta(seconds=0.04)
+ self.send_gamestate_min_interval = datetime.timedelta(seconds=0.04)
+ self.send_gamestate_max_interval = datetime.timedelta(seconds=5)
self.last_send_gamestate = datetime.datetime.now() -\
- self.send_gamestate_interval
+ self.send_gamestate_min_interval
self.terrains = {
'.': Terrain('.', 'floor'),
'X': Terrain('X', 'wall', blocks_light=True, blocks_sound=True,
player = self.get_player(c_id)
self.io.send('PLAYERS_HAT_CHARS ' + quote(player.get_cookie_chars()),
c_id)
+ self.io.send('BLADDER_PRESSURE %s' % player.need_for_toilet)
if player.id_ in player_ids_send_fov:
self.io.send('FOV %s' % quote(player.fov_stencil.terrain), c_id)
self.io.send('MAP %s %s %s' % (self.get_map_geometry_shape(),
self.io.send('PLAY_ERROR ' + quote(str(e)), connection_id)
# send gamestate if it makes sense at this point
- if self.changed:
+ if self.changed or self.last_send_gamestate < \
+ datetime.datetime.now() - self.send_gamestate_max_interval:
self.turn += 1
# send_gamestate() can be rather expensive, due to among other reasons
# re-calculating players' FOVs, so don't send it out too often
if self.last_send_gamestate < \
- datetime.datetime.now() -self.send_gamestate_interval:
+ datetime.datetime.now() - self.send_gamestate_min_interval:
n_changes = 0
for type_ in self.changed_tiles:
n_changes += len(self.changed_tiles[type_])
</div>
<script>
"use strict";
-let websocket_location = "wss://plomlompom.com/rogue_chat/";
-//let websocket_location = "ws://localhost:8000/";
+//let websocket_location = "wss://plomlompom.com/rogue_chat/";
+let websocket_location = "ws://localhost:8000/";
let mode_helps = {
'play': {
let tokens = parser.tokenize(event.data);
if (tokens[0] === 'TURN') {
game.turn_complete = false;
- game.turn = parseInt(tokens[1]);
} else if (tokens[0] === 'OTHER_WIPE') {
game.portals_new = {};
explorer.annotations_new = {};
game.things_new = [];
+ } else if (tokens[0] === 'BLADDER_PRESSURE') {
+ game.bladder_pressure_new = parseInt(tokens[1])
} else if (tokens[0] === 'THING') {
let t = game.get_thing_temp(tokens[4], true);
t.position = parser.parse_yx(tokens[1]);
game.things = game.things_new;
game.player = game.things[game.player_id];
game.players_hat_chars = game.players_hat_chars_new;
+ game.bladder_pressure = game.bladder_pressure_new
game.turn_complete = true;
if (tui.mode.name == 'post_login_wait') {
tui.switch_mode('play');
}
terminal.write(0, this.window_width, 'MODE: ' + this.mode.short_desc + ' – ' + help);
},
- draw_turn_line: function(n) {
- if (game.turn_complete) {
- terminal.write(1, this.window_width, 'TURN: ' + game.turn);
- }
+ draw_stats_line: function(n) {
+ terminal.write(1, this.window_width, 'BLADDER: ' + game.bladder_pressure);
},
draw_history: function() {
let log_display_lines = [];
this.draw_input();
} else {
this.draw_map();
- this.draw_turn_line();
+ this.draw_stats_line();
this.draw_mode_line();
if (this.mode.shows_info) {
this.draw_info();
this.portals = {};
this.portals_new = {};
this.players_hat_chars = "";
+ this.bladder_pressure = 0;
+ this.bladder_pressure_new = 0;
},
get_thing_temp: function(id_, create_if_not_found=false) {
if (id_ in game.things_new) {
pass # we assume socket will be known as dead by now
def cmd_TURN(game, n):
- game.turn = n
game.turn_complete = False
cmd_TURN.argtypes = 'int:nonneg'
game.map_control_content = game.map_control_content_new
game.player = game.get_thing(game.player_id)
game.players_hat_chars = game.players_hat_chars_new
+ game.bladder_pressure = game.bladder_pressure_new
game.turn_complete = True
if game.tui.mode.name == 'post_login_wait':
game.tui.switch_mode('play')
game.tui.set_random_colors()
cmd_RANDOM_COLORS.argtypes = ''
+def cmd_BLADDER_PRESSURE(game, bladder_pressure):
+ game.bladder_pressure_new = bladder_pressure
+cmd_BLADDER_PRESSURE.argtypes = 'int:nonneg'
+
class Game(GameBase):
turn_complete = False
tasks = {}
self.register_command(cmd_FOV)
self.register_command(cmd_DEFAULT_COLORS)
self.register_command(cmd_RANDOM_COLORS)
+ self.register_command(cmd_BLADDER_PRESSURE)
self.map_content = ''
self.players_hat_chars = ''
self.player_id = -1
self.portals_new = {}
self.terrains = {}
self.player = None
+ self.bladder_pressure_new = 0
+ self.bladder_pressure = 0
def get_string_options(self, string_option_type):
if string_option_type == 'map_geometry':
safe_addstr(y, self.window_width, self.input_lines[i])
y += 1
- def draw_turn():
- if not self.game.turn_complete:
- return
- safe_addstr(0, self.window_width, 'TURN: ' + str(self.game.turn))
+ def draw_stats():
+ safe_addstr(0, self.window_width, 'BLADDER: ' + str(self.game.bladder_pressure))
def draw_mode():
help = "hit [%s] for help" % self.keys['help']
draw_history()
draw_mode()
if not self.mode.is_intro:
- draw_turn()
+ draw_stats()
draw_map()
if self.show_help:
draw_help()