Last active
October 19, 2017 10:23
-
-
Save tmathmeyer/b3b282fb9f3f4fa2c0600304d2558dab to your computer and use it in GitHub Desktop.
show ratios on trimps buildings
This file contains 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
oldCanAffordBuilding = canAffordBuilding | |
newCanAffordBuilding = function(what, take, buildCostString, isEquipment, updatingLabel, forceAmt, autoPerc) { | |
result = oldCanAffordBuilding(what, take, buildCostString, isEquipment, updatingLabel, forceAmt, autoPerc) | |
if(typeof(result) === "boolean"){ | |
return result | |
} | |
gamething = game['buildings'][what] | |
if (gamething == null) { | |
return result | |
} | |
if (gamething.increase == null) { | |
return result | |
} | |
increase = gamething.increase.by | |
newresult = '' | |
number = /([e\.0-9]*)(.*)/ | |
reg = /<span class="(green|red|orange)">(food|wood|gems|metal|fragments|helium): ([e\.0-9]*[K|M|B|T]*)(.*?)<\/span>/g | |
var m; | |
while(m=reg.exec(result)) { | |
parse_amount = m[3].match(number) | |
cost_per = (Number(parse_amount[1]) / increase).toFixed(2) | |
string_per = '(cost per: '+cost_per+parse_amount[2]+')' | |
newspan = '<span class="'+m[1]+'">'+m[2]+': '+m[3]+string_per+m[4]+'</span><br/>' | |
newresult += newspan | |
} | |
newresult = newresult.slice(0, -5); | |
return newresult | |
} | |
canAffordBuilding = newCanAffordBuilding |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment