Created
August 23, 2015 05:41
-
-
Save new-guy/b267ab1873725a746a68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Room.prototype.getLargestEnergyPile = function() | |
{ | |
var droppedEnergyArray = this.find(FIND_DROPPED_ENERGY); | |
//console.log(droppedEnergyArray.length); | |
if(droppedEnergyArray.length === 0) return null; | |
var largestPile = droppedEnergyArray[0]; | |
for(var i = 0; i < droppedEnergyArray.length; i++) | |
{ | |
var currentPile = droppedEnergyArray[0]; | |
if(currentPile.energy > largestPile.energy) | |
{ | |
largestPile = currentPile; | |
} | |
} | |
return largestPile; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var energyPile = room.getLargestEnergyPile(); | |
//console.log(energyPile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment