From 0572550d38cf28ed2090fae5907cfb8847603648 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sat, 5 Jul 2014 12:30:25 -0700 Subject: [PATCH] Type bug in implementation of #35 --- moonlight/src/AISprite.js | 2 +- moonlight/src/GameStates.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/moonlight/src/AISprite.js b/moonlight/src/AISprite.js index 8dcc037..38355db 100644 --- a/moonlight/src/AISprite.js +++ b/moonlight/src/AISprite.js @@ -350,7 +350,7 @@ var AISprite = function(game, x, y, key, frame) { if ( hasBeenReset == true ) return; if ( game.physics.arcade.overlap(spr, this) ) { - var last = this.path[this.path.length() - 1]; + var last = this.path[this.path.length - 1]; this.path_tween_stop(); hasBeenReset = true; } diff --git a/moonlight/src/GameStates.js b/moonlight/src/GameStates.js index cc624f0..aecbdb5 100644 --- a/moonlight/src/GameStates.js +++ b/moonlight/src/GameStates.js @@ -357,7 +357,12 @@ GameState.prototype.update = function() delState(player, STATE_STEALING); x.sprite_has_treasure = false; var stolen = moonlightTreasures[x.sprite_treasure]; - player.score += stolen['value']; + if ( typeof stolen == 'undefined' ) { + // You should put a trap here. + console.log("Tried to steal undefined : " + x.sprite_treasure); + } else { + player.score += stolen['value']; + } x.sprite_treasure = null; if ( this.recentlyStolenGroup.total >= RECENTLYSTOLEN_MAX ) { this.recentlyStolenGroup.remove(