Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var costs = [1e1, 1e3, 1e4, 1e5, 1e6, 1e8, 1e10, 1e12, 1e15];
- var buttons = [
- [$("#tickSpeed"), $("tickSpeedMax")],
- [$("#first"), $("#firstMax")],
- [$("#second"), $("#secondMax")],
- [$("#third"), $("#thirdMax")],
- [$("#fourth"), $("#fourthMax")],
- [$("#fifth"), $("#fifthMax")],
- [$("#sixth"), $("#sixthMax")],
- [$("#seventh"), $("#seventhMax")],
- [$("#eight"), $("#eightMax")]
- ];
- function preparePrice(price) {
- var regex = /Cost: ([^)].*)/;
- return price.match(regex)[1];
- }
- function checkPrices() {
- for (var i = 0, l = buttons.length; i < l; i++) {
- var safeToBuy = true;
- var verySafe = true
- var fixIt = false;
- var price = Number(preparePrice(buttons[i][0].text()));
- var nextPrice = price * costs[i];
- var nextNextPrice = price * costs[i] * costs[i];
- if (!isFinite(nextPrice)) continue;
- for (var i2 = 0, l2 = buttons.length; i2 < l2; i2++) {
- if (price == Number(preparePrice(buttons[i2][0].text())) * costs[i2]) {
- fixIt = true;
- }
- if (nextPrice == Number(preparePrice(buttons[i2][0].text()))) {
- safeToBuy = false;
- }
- if (nextNextPrice == Number(preparePrice(buttons[i2][0].text()))) {
- verySafe = false;
- }
- if (nextPrice == Number(preparePrice(buttons[i2][0].text())) * costs[i2] && i != i2) {
- verySafe = false;
- }
- }
- if (!safeToBuy) {
- if (fixIt) {
- buttons[i][0].css("background-color", "#CC0000");
- } else {
- buttons[i][0].css("background-color", "#880000");
- }
- } else if (!verySafe) {
- if (fixIt) {
- buttons[i][0].css("background-color", "#CCCC00");
- } else {
- buttons[i][0].css("background-color", "#888800");
- }
- } else {
- if (fixIt) {
- buttons[i][0].css("background-color", "#00CC00");
- } else {
- buttons[i][0].css("background-color", "#008800");
- }
- }
- }
- }
- setInterval(checkPrices, 100);
- checkPrices();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement