pass # we assume socket will be known as dead by now
def cmd_TURN(game, n):
+ game.info_db = {}
+ game.info_hints = []
game.turn = n
game.things = []
game.portals = {}
cmd_MAP_CONTROL.argtypes = 'string'
def cmd_GAME_STATE_COMPLETE(game):
- game.info_db = {}
if game.tui.mode.name == 'post_login_wait':
game.tui.switch_mode('play')
if game.tui.mode.shows_info:
game.tui.do_refresh = True
cmd_ARGUMENT_ERROR.argtypes = 'string'
+def cmd_ANNOTATION_HINT(game, position):
+ game.info_hints += [position]
+cmd_ANNOTATION_HINT.argtypes = 'yx_tuple:nonneg'
+
def cmd_ANNOTATION(game, position, msg):
game.info_db[position] = msg
game.tui.restore_input_values()
self.register_command(cmd_MAP_CONTROL)
self.register_command(cmd_PORTAL)
self.register_command(cmd_ANNOTATION)
+ self.register_command(cmd_ANNOTATION_HINT)
self.register_command(cmd_GAME_STATE_COMPLETE)
self.register_command(cmd_ARGUMENT_ERROR)
self.register_command(cmd_GAME_ERROR)
self.map_content = ''
self.player_id = -1
self.info_db = {}
+ self.info_hints = []
self.portals = {}
self.terrains = {}
start = self.game.map_geometry.size.x * y
end = start + self.game.map_geometry.size.x
map_lines_split += [[c + ' ' for c in map_content[start:end]]]
- if self.map_mode == 'terrain':
+ if self.map_mode == 'annotations':
+ for p in self.game.info_hints:
+ map_lines_split[p.y][p.x] = 'A '
+ elif self.map_mode == 'terrain':
for p in self.game.portals.keys():
map_lines_split[p.y][p.x] = 'P '
used_positions = []
elif self.mode == self.mode_study:
content += 'Available actions:\n'
content += '[%s] – move question mark\n' % ','.join(self.movement_keys)
- content += '[%s] – toggle view between terrain, and password protection areas\n' % self.keys['toggle_map_mode']
+ content += '[%s] – toggle view between terrain, annotations, and password protection areas\n' % self.keys['toggle_map_mode']
content += '\n\nOther modes available from here:'
content += '[%s] – chat mode\n' % self.keys['switch_to_chat']
content += '[%s] – play mode\n' % self.keys['switch_to_play']
elif self.mode == self.mode_chat:
content += '/nick NAME – re-name yourself to NAME\n'
- #content += '/msg USER TEXT – send TEXT to USER\n'
content += '/%s or /play – switch to play mode\n' % self.keys['switch_to_play']
content += '/%s or /study – switch to study mode\n' % self.keys['switch_to_study']
for i in range(self.size.y):
self.switch_mode('play')
elif key == self.keys['toggle_map_mode']:
if self.map_mode == 'terrain':
+ self.map_mode = 'annotations'
+ elif self.map_mode == 'annotations':
self.map_mode = 'control'
else:
self.map_mode = 'terrain'
<button id="switch_to_password">change tile editing password</button>
<button id="switch_to_annotate">annotate tile</button>
<button id="switch_to_portal">edit portal link</button>
-<button id="toggle_map_mode">toggle terrain/control view</button>
+<button id="toggle_map_mode">toggle terrain/annotations/control view</button>
</div>
<h3>edit keybindings</h3> (see <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values">here</a> for non-obvious available values):<br />
<ul>
<li>enter tile password (from play mode): <input id="key_switch_to_password" type="text" value="P" />
<li>annotate tile (from play mode): <input id="key_switch_to_annotate" type="text" value="M" />
<li>annotate portal (from play mode): <input id="key_switch_to_portal" type="text" value="T" />
-<li>toggle terrain/control view (from study mode): <input id="key_toggle_map_mode" type="text" value="M" />
+<li>toggle terrain/annotations/control view (from study mode): <input id="key_toggle_map_mode" type="text" value="M" />
</ul>
</div>
<script>
let tokens = parser.tokenize(event.data);
if (tokens[0] === 'TURN') {
game.turn_complete = false;
+ explorer.empty_info_db();
game.things = {};
game.portals = {};
game.turn = parseInt(tokens[1]);
game.map_control = tokens[1]
} else if (tokens[0] === 'GAME_STATE_COMPLETE') {
game.turn_complete = true;
- explorer.empty_info_db();
if (tui.mode == mode_post_login_wait) {
tui.switch_mode(mode_play);
} else if (tui.mode == mode_study) {
} else if (tokens[0] === 'PORTAL') {
let position = parser.parse_yx(tokens[1]);
game.portals[position] = tokens[2];
+ } else if (tokens[0] === 'ANNOTATION_HINT') {
+ let position = parser.parse_yx(tokens[1]);
+ explorer.info_hints = explorer.info_hints.concat([position]);
} else if (tokens[0] === 'ANNOTATION') {
let position = parser.parse_yx(tokens[1]);
explorer.update_info_db(position, tokens[2]);
line.push(map_content[i] + ' ');
};
map_lines_split.push(line);
- if (this.map_mode == 'terrain') {
+ if (this.map_mode == 'annotations') {
+ for (const coordinate of explorer.info_hints) {
+ map_lines_split[coordinate[0]][coordinate[1]] = 'A ';
+ }
+ } else if (this.map_mode == 'terrain') {
for (const p in game.portals) {
let coordinate = p.split(',')
map_lines_split[coordinate[0]][coordinate[1]] = 'P ';
} else if (this.mode == mode_study) {
content += "Available actions:\n";
content += '[' + movement_keys_desc + '] – move question mark\n';
- content += '[' + this.keys.toggle_map_mode + '] – toggle view between terrain, and password protection areas\n';
+ content += '[' + this.keys.toggle_map_mode + '] – toggle view between terrain, annotations, and password protection areas\n';
content += '\nOther modes available from here:\n';
content += '[' + this.keys.switch_to_chat + '] – chat mode\n';
content += '[' + this.keys.switch_to_play + '] – play mode\n';
let explorer = {
position: [0,0],
info_db: {},
+ info_hints: [],
move: function(direction) {
let target = game.move(this.position, direction);
if (target) {
},
empty_info_db: function() {
this.info_db = {};
+ this.info_hints = [];
if (tui.mode == mode_study) {
tui.full_refresh();
}
explorer.move(tui.movement_keys[event.key]);
} else if (event.key == tui.keys.toggle_map_mode) {
if (tui.map_mode == 'terrain') {
+ tui.map_mode = 'annotations';
+ } else if (tui.map_mode == 'annotations') {
tui.map_mode = 'control';
} else {
tui.map_mode = 'terrain';
};
document.getElementById("toggle_map_mode").onclick = function() {
if (tui.map_mode == 'terrain') {
+ tui.map_mode = 'annotations';
+ } else if (tui.map_mode == 'annotations') {
tui.map_mode = 'control';
} else {
tui.map_mode = 'terrain';