From 6d57ec4a0f0d46abb4fcb3bcb8fae3115a48dd5c Mon Sep 17 00:00:00 2001 From: Jerome Date: Wed, 22 Mar 2017 23:25:46 +0100 Subject: [PATCH] Fixing wrong binding of 'this' --- index.html | 1 - js/client/game.js | 10 +++++----- js/server/GameServer.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 83d9254..935c924 100644 --- a/index.html +++ b/index.html @@ -47,7 +47,6 @@ - diff --git a/js/client/game.js b/js/client/game.js index d0fd478..91cfdac 100644 --- a/js/client/game.js +++ b/js/client/game.js @@ -1310,7 +1310,7 @@ Game.handleClick = function(){ }; Game.handleCharClick = function(character){ // Handles what happens when clicking on an NPC - if (this.handleClick()) { + if (Game.handleClick()) { // character is the sprite that was clicked var end = Game.computeTileCoords(character.x, character.y); end.y++; // So that the player walks to place himself in front of the NPC @@ -1341,7 +1341,7 @@ Game.handleCharClick = function(character){ // Handles what happens when clickin }; Game.handleChestClick = function(chest){ // Handles what happens when clicking on a chest - if (this.handleClick()) { + if (Game.handleClick()) { // chest is the sprite that was clicked var end = Game.computeTileCoords(chest.x, chest.y); var action = { @@ -1354,14 +1354,14 @@ Game.handleChestClick = function(chest){ // Handles what happens when clicking o }; Game.handleLootClick = function(loot){ // Handles what happens when clicking on an item - if (this.handleClick()) { + if (Game.handleClick()) { // loot is the sprite that was clicked Game.player.prepareMovement(Game.computeTileCoords(loot.x, loot.y), 0, {action: 0}, 0, true); // true : send path to server } }; Game.handleMapClick = function(layer,pointer){ // Handles what happens when clicking on an empty tile to move - if (this.handleClick()) { + if (Game.handleClick()) { // layer is the layer object that was clicked on, pointer is the mouse if (!Game.marker.collide && Game.view.contains(pointer.worldX, pointer.worldY)) { // To avoid trigger movement to collision cells or cells below the HUD var end = Game.computeTileCoords(Game.marker.x, Game.marker.y); @@ -1371,7 +1371,7 @@ Game.handleMapClick = function(layer,pointer){ // Handles what happens when clic }; Game.handleMonsterClick = function(monster){ // Handles what happens when clicking on a monster - if (this.handleClick()) { + if (Game.handleClick()) { // monster is the sprite that was clicked on var end = Game.computeTileCoords(monster.x, monster.y); var action = { diff --git a/js/server/GameServer.js b/js/server/GameServer.js index 175c708..8e9d403 100644 --- a/js/server/GameServer.js +++ b/js/server/GameServer.js @@ -108,7 +108,7 @@ GameServer.readMap = function(){ // Iterate over all tiles and work out AOIs and collisions AOIutils.nbAOIhorizontal = Math.ceil(GameServer.map.width/GameServer.AOIwidth); - GameServer.AOIs = {}; + GameServer.AOIs = {}; // Maps AOI id to AOI object GameServer.dirtyAOIs = new Set(); // Set of AOI's whose update package have changes since last update GameServer.AOIfromTiles = new spaceMap(); // map tiles coordinates to AOI id (e.g. the tile (3,2) is in AOI 0) GameServer.collisionGrid = [];