Skip to content

Commit

Permalink
jshint warning ('cur' is already defined)
Browse files Browse the repository at this point in the history
The "cur" variable is defined twice in each for loop.
So I pulled out the definition part of the "cur" variable.
  • Loading branch information
hun0975 committed Dec 4, 2017
1 parent 36f5a82 commit 4e37103
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions script/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,12 +774,13 @@ var World = {

var chances = {};
var nonSticky = 1;
var cur;
for(var i in adjacent) {
if(adjacent[i] == World.TILE.VILLAGE) {
// Village must be in a forest to maintain thematic consistency, yo.
return World.TILE.FOREST;
} else if(typeof adjacent[i] == 'string') {
var cur = chances[adjacent[i]];
cur = chances[adjacent[i]];
cur = typeof cur == 'number' ? cur : 0;
chances[adjacent[i]] = cur + World.STICKINESS;
nonSticky -= World.STICKINESS;
Expand All @@ -788,7 +789,7 @@ var World = {
for(var t in World.TILE) {
var tile = World.TILE[t];
if(World.isTerrain(tile)) {
var cur = chances[tile];
cur = chances[tile];
cur = typeof cur == 'number' ? cur : 0;
cur += World.TILE_PROBS[tile] * nonSticky;
chances[tile] = cur;
Expand Down

0 comments on commit 4e37103

Please sign in to comment.