- if (game.map_geometry == 'Square') {
- this.movement_keys = {
- [this.keys.square_move_up]: 'UP',
- [this.keys.square_move_left]: 'LEFT',
- [this.keys.square_move_down]: 'DOWN',
- [this.keys.square_move_right]: 'RIGHT'
- };
- document.getElementById("move_upright").hidden = true;
- document.getElementById("move_upleft").hidden = true;
- document.getElementById("move_downright").hidden = true;
- document.getElementById("move_downleft").hidden = true;
- document.getElementById("move_up").hidden = false;
- document.getElementById("move_down").hidden = false;
- } else if (game.map_geometry == 'Hex') {
- document.getElementById("move_upright").hidden = false;
- document.getElementById("move_upleft").hidden = false;
- document.getElementById("move_downright").hidden = false;
- document.getElementById("move_downleft").hidden = false;
- document.getElementById("move_up").hidden = true;
- document.getElementById("move_down").hidden = true;
- this.movement_keys = {
- [this.keys.hex_move_upleft]: 'UPLEFT',
- [this.keys.hex_move_upright]: 'UPRIGHT',
- [this.keys.hex_move_right]: 'RIGHT',
- [this.keys.hex_move_downright]: 'DOWNRIGHT',
- [this.keys.hex_move_downleft]: 'DOWNLEFT',
- [this.keys.hex_move_left]: 'LEFT'
- };
+ this.movement_keys = {};
+ let geometry_prefix = 'undefinedMapGeometry_';
+ if (game.map_geometry) {
+ geometry_prefix = game.map_geometry.toLowerCase() + '_';
+ }
+ for (const key_name of Object.keys(key_descriptions)) {
+ if (key_name.startsWith(geometry_prefix)) {
+ let direction = key_name.split('_')[2].toUpperCase();
+ let key = this.keys[key_name];
+ this.movement_keys[key] = direction;
+ }
+ };
+ for (const move_button of document.querySelectorAll('[id*="_move_"]')) {
+ if (move_button.id.startsWith('key_')) {
+ continue;
+ }
+ move_button.hidden = true;
+ };
+ for (const move_button of document.querySelectorAll('[id^="' + geometry_prefix + 'move_"]')) {
+ document.getElementById("move_table").hidden = false;
+ move_button.hidden = false;