diff options
Diffstat (limited to 'diplomacy/web/src/diplomacy/client')
7 files changed, 22 insertions, 22 deletions
diff --git a/diplomacy/web/src/diplomacy/client/channel.js b/diplomacy/web/src/diplomacy/client/channel.js index eb8692a..6a70635 100644 --- a/diplomacy/web/src/diplomacy/client/channel.js +++ b/diplomacy/web/src/diplomacy/client/channel.js @@ -29,7 +29,7 @@ export class Channel { localJoinGame(joinParameters) { // Game ID must be known. - if (this.game_id_to_instances.hasOwnProperty(joinParameters.game_id)) { + if (Object.prototype.hasOwnProperty.call(this.game_id_to_instances, joinParameters.game_id)) { // If there is a power name, we return associated power game. if (joinParameters.power_name) return this.game_id_to_instances[joinParameters.game_id].get(joinParameters.power_name); diff --git a/diplomacy/web/src/diplomacy/client/connection.js b/diplomacy/web/src/diplomacy/client/connection.js index 1e40ed8..179f090 100644 --- a/diplomacy/web/src/diplomacy/client/connection.js +++ b/diplomacy/web/src/diplomacy/client/connection.js @@ -70,7 +70,7 @@ class Reconnection { for (let game of gis.getGames()) { const game_id = game.local.game_id; const game_role = game.local.role; - if (!this.games_phases.hasOwnProperty(game_id)) + if (!Object.prototype.hasOwnProperty.call(this.games_phases, game_id)) this.games_phases[game_id] = {}; this.games_phases[game_id][game_role] = null; ++this.n_expected_games; @@ -251,7 +251,7 @@ export class Connection { } if (jsonMessage.request_id) { const requestID = jsonMessage.request_id; - if (!this.requestsWaitingResponses.hasOwnProperty(requestID)) { + if (!Object.prototype.hasOwnProperty.call(this.requestsWaitingResponses, requestID)) { Diplog.error('Unknown request ' + requestID + '.'); return; } @@ -310,13 +310,13 @@ export class Connection { const onConnected = () => { connection.socket.send(JSON.stringify(request)); connection.requestsWaitingResponses[requestID] = requestContext; - if (connection.requestsToSend.hasOwnProperty(requestID)) { + if (Object.prototype.hasOwnProperty.call(connection.requestsToSend, requestID)) { delete connection.requestsToSend[requestID]; } writeFuture.setResult(null); }; const onAnyError = (error) => { - if (!connection.requestsToSend.hasOwnProperty(requestID)) { + if (!Object.prototype.hasOwnProperty.call(connection.requestsToSend, requestID)) { connection.requestsToSend[requestID] = requestContext; } Diplog.info('Error occurred while sending a request ' + requestID); diff --git a/diplomacy/web/src/diplomacy/client/game_instance_set.js b/diplomacy/web/src/diplomacy/client/game_instance_set.js index ca92e48..b03b027 100644 --- a/diplomacy/web/src/diplomacy/client/game_instance_set.js +++ b/diplomacy/web/src/diplomacy/client/game_instance_set.js @@ -28,7 +28,7 @@ export class GameInstanceSet { } has(role) { - return this.__games.hasOwnProperty(role); + return Object.prototype.hasOwnProperty.call(this.__games, role); } get(role) { @@ -36,9 +36,9 @@ export class GameInstanceSet { } getSpecial() { - if (this.__games.hasOwnProperty(STRINGS.OBSERVER_TYPE)) + if (Object.prototype.hasOwnProperty.call(this.__games, STRINGS.OBSERVER_TYPE)) return this.__games[STRINGS.OBSERVER_TYPE]; - if (this.__games.hasOwnProperty(STRINGS.OMNISCIENT_TYPE)) + if (Object.prototype.hasOwnProperty.call(this.__games, STRINGS.OMNISCIENT_TYPE)) return this.__games[STRINGS.OMNISCIENT_TYPE]; return null; } @@ -53,19 +53,19 @@ export class GameInstanceSet { } removeSpecial() { - if (this.__games.hasOwnProperty(STRINGS.OBSERVER_TYPE)) + if (Object.prototype.hasOwnProperty.call(this.__games, STRINGS.OBSERVER_TYPE)) delete this.__games[STRINGS.OBSERVER_TYPE]; - if (this.__games.hasOwnProperty(STRINGS.OMNISCIENT_TYPE)) + if (Object.prototype.hasOwnProperty.call(this.__games, STRINGS.OMNISCIENT_TYPE)) delete this.__games[STRINGS.OMNISCIENT_TYPE]; } add(game) { if (game.local.game_id !== this.__game_id) throw new Error('game ID to add does not match game instance set ID.'); - if (this.__games.hasOwnProperty(game.local.role)) + if (Object.prototype.hasOwnProperty.call(this.__games, game.local.role)) throw new Error('Role already in game instance set.'); if (!game.local.isPlayerGame() && ( - this.__games.hasOwnProperty(STRINGS.OBSERVER_TYPE) || this.__games.hasOwnProperty(STRINGS.OMNISCIENT_TYPE))) + Object.prototype.hasOwnProperty.call(this.__games, STRINGS.OBSERVER_TYPE) || Object.prototype.hasOwnProperty.call(this.__games, STRINGS.OMNISCIENT_TYPE))) throw new Error('Previous special game must be removed before adding new one.'); this.__games[game.local.role] = game; } diff --git a/diplomacy/web/src/diplomacy/client/network_game.js b/diplomacy/web/src/diplomacy/client/network_game.js index 9999093..85571e2 100644 --- a/diplomacy/web/src/diplomacy/client/network_game.js +++ b/diplomacy/web/src/diplomacy/client/network_game.js @@ -32,14 +32,14 @@ export class NetworkGame { } addCallback(notificationName, notificationCallback) { - if (!this.notificationCallbacks.hasOwnProperty(notificationName)) + if (!Object.prototype.hasOwnProperty.call(this.notificationCallbacks, notificationName)) this.notificationCallbacks[notificationName] = [notificationCallback]; else if (!this.notificationCallbacks[notificationName].includes(notificationCallback)) this.notificationCallbacks[notificationName].push(notificationCallback); } clearCallbacks(notificationName) { - if (this.notificationCallbacks.hasOwnProperty(notificationName)) + if (Object.prototype.hasOwnProperty.call(this.notificationCallbacks, notificationName)) delete this.notificationCallbacks[notificationName]; } @@ -48,7 +48,7 @@ export class NetworkGame { } notify(notification) { - if (this.notificationCallbacks.hasOwnProperty(notification.name)) { + if (Object.prototype.hasOwnProperty.call(this.notificationCallbacks, notification.name)) { for (let callback of this.notificationCallbacks[notification.name]) setTimeout(() => callback(this, notification), 0); } diff --git a/diplomacy/web/src/diplomacy/client/notification_managers.js b/diplomacy/web/src/diplomacy/client/notification_managers.js index bbfe862..5241316 100644 --- a/diplomacy/web/src/diplomacy/client/notification_managers.js +++ b/diplomacy/web/src/diplomacy/client/notification_managers.js @@ -23,7 +23,7 @@ import {Game} from "../engine/game"; export const NOTIFICATION_MANAGERS = { account_deleted: function (channel, notification) { const connection = channel.connection; - if (connection.channels.hasOwnProperty(channel.token)) + if (Object.prototype.hasOwnProperty.call(connection.channels, channel.token)) delete channel.connection.channels[channel.token]; }, cleared_centers: function (game, notification) { @@ -105,15 +105,15 @@ export const NOTIFICATION_MANAGERS = { } }, handleNotification: function (connection, notification) { - if (!NOTIFICATION_MANAGERS.hasOwnProperty(notification.name)) + if (!Object.prototype.hasOwnProperty.call(NOTIFICATION_MANAGERS, notification.name)) throw new Error('No notification handler available for notification ' + notification.name); const handler = NOTIFICATION_MANAGERS[notification.name]; const level = NOTIFICATIONS.levels[notification.name]; - if (!connection.channels.hasOwnProperty(notification.token)) + if (!Object.prototype.hasOwnProperty.call(connection.channels, notification.token)) throw new Error('Unable to find channel related to notification ' + notification.name); let objectToNotify = connection.channels[notification.token]; if (level === STRINGS.GAME) { - if (objectToNotify.game_id_to_instances.hasOwnProperty(notification.game_id) + if (Object.prototype.hasOwnProperty.call(objectToNotify.game_id_to_instances, notification.game_id) && objectToNotify.game_id_to_instances[notification.game_id].has(notification.game_role)) objectToNotify = objectToNotify.game_id_to_instances[notification.game_id].get(notification.game_role); else diff --git a/diplomacy/web/src/diplomacy/client/request_future_context.js b/diplomacy/web/src/diplomacy/client/request_future_context.js index 16103fb..febd75f 100644 --- a/diplomacy/web/src/diplomacy/client/request_future_context.js +++ b/diplomacy/web/src/diplomacy/client/request_future_context.js @@ -45,7 +45,7 @@ export class RequestFutureContext { newGame(received_game) { const channel = this.getChannel(); const game = new NetworkGame(channel, received_game); - if (!channel.game_id_to_instances.hasOwnProperty(game.local.game_id)) + if (!Object.prototype.hasOwnProperty.call(channel.game_id_to_instances, game.local.game_id)) channel.game_id_to_instances[game.local.game_id] = new GameInstanceSet(game.local.game_id); channel.game_id_to_instances[game.local.game_id].add(game); return game; @@ -57,7 +57,7 @@ export class RequestFutureContext { deleteGame() { const channel = this.getChannel(); - if (channel.game_id_to_instances.hasOwnProperty(this.request.game_id)) + if (Object.prototype.hasOwnProperty.call(channel.game_id_to_instances, this.request.game_id)) delete channel.game_id_to_instances[this.request.game_id]; } } diff --git a/diplomacy/web/src/diplomacy/client/response_managers.js b/diplomacy/web/src/diplomacy/client/response_managers.js index ba45938..125c3a9 100644 --- a/diplomacy/web/src/diplomacy/client/response_managers.js +++ b/diplomacy/web/src/diplomacy/client/response_managers.js @@ -110,7 +110,7 @@ export const RESPONSE_MANAGERS = { return context.newChannel(context.request.username, response.data); }, handleResponse: function (context, response) { - if (!RESPONSE_MANAGERS.hasOwnProperty(context.request.name)) + if (!Object.prototype.hasOwnProperty.call(RESPONSE_MANAGERS, context.request.name)) throw new Error('No response handler available for request ' + context.request.name); const handler = RESPONSE_MANAGERS[context.request.name]; return handler(context, response); |