Trimps tools

Trimps tools (visual)

当前为 2018-12-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Trimps tools
  3. // @namespace trimps.github.io
  4. // @version 1.281
  5. // @description Trimps tools (visual)
  6. // @author Anton
  7. // @match https://trimps.github.io
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. var $ = jQuery;
  15.  
  16. var _GameHelpers = {
  17. getBotVersion: function() {
  18. return typeof GM_info === 'function' ? GM_info().script.version :
  19. (typeof GM_info === 'object' ? GM_info.script.version : '?');
  20. },
  21. isPortal: function () {
  22. return portalWindowOpen;
  23. },
  24. getJobPrice: function (jobName, resource) {
  25. return game.jobs[jobName].cost[resource][0] * Math.pow(game.jobs[jobName].cost[resource][1], game.jobs[jobName].owned);
  26. },
  27. hasFormation: function(what) {
  28. what = parseInt(what);
  29. if (!game.global.preMapsActive && !game.global.lockTooltip) {
  30. if (game.upgrades.Formations.done && what === 0) return true;
  31. if (game.upgrades.Formations.done && what === 1) return true;
  32. if (game.upgrades.Dominance.done && what === 2) return true;
  33. if (game.upgrades.Barrier.done && what === 3) return true;
  34. if (game.upgrades.Formations.done && game.global.highestLevelCleared >= 180 && what === 4) return true;
  35. }
  36. return false;
  37. },
  38. getCurrentEnemyAttack: function() {
  39. var cellNum, cell;
  40. if (game.global.mapsActive) {
  41. cellNum = game.global.lastClearedMapCell + 1;
  42. cell = game.global.mapGridArray[cellNum];
  43. } else {
  44. cellNum = game.global.lastClearedCell + 1;
  45. cell = game.global.gridArray[cellNum];
  46. }
  47. return calculateDamage(cell.attack, false, false, false, cell);
  48. },
  49. getBreedingBaseSpeed: function () {
  50. if (game.global.challengeActive === "Trapper") return 0;
  51. var base = 0.0085;
  52. var currentCalc = _GameHelpers.getBreedingCount() * base;
  53. if (game.upgrades.Potency.done > 0) {
  54. currentCalc *= Math.pow(1.1, game.upgrades.Potency.done);
  55. }
  56. return currentCalc;
  57. },
  58. getBreedingTotalSpeed: function () {
  59. if (game.global.challengeActive === "Trapper") return 0;
  60. var trimps = game.resources.trimps;
  61. var base = 0.0085;
  62. //Add job count
  63. var breeding = trimps.owned - trimps.employed;
  64. var currentCalc = breeding * base;
  65. //Add Potency
  66. if (game.upgrades.Potency.done > 0){
  67. currentCalc *= Math.pow(1.1, game.upgrades.Potency.done);
  68. }
  69. //Add Nurseries
  70. if (game.buildings.Nursery.owned > 0){
  71. currentCalc *= Math.pow(1.01, game.buildings.Nursery.owned);
  72. }
  73. //Add Venimp
  74. if (game.unlocks.impCount.Venimp > 0){
  75. var venimpStrength = Math.pow(1.003, game.unlocks.impCount.Venimp);
  76. currentCalc *= (venimpStrength);
  77. }
  78. if (game.global.brokenPlanet){
  79. currentCalc /= 10;
  80. }
  81. //Add pheromones
  82. if (game.portal.Pheromones.level > 0){
  83. var PheromonesStrength = (game.portal.Pheromones.level * game.portal.Pheromones.modifier);
  84. currentCalc *= (PheromonesStrength + 1);
  85. }
  86. //Add Geneticist
  87. if (game.jobs.Geneticist.owned > 0) {
  88. currentCalc *= Math.pow(.98, game.jobs.Geneticist.owned);
  89. }
  90. //Add quick trimps
  91. if (game.unlocks.quickTrimps){
  92. currentCalc *= 2;
  93. }
  94. if (game.global.challengeActive === "Daily"){
  95. var mult = 0;
  96. if (typeof game.global.dailyChallenge.dysfunctional !== 'undefined'){
  97. mult = dailyModifiers.dysfunctional.getMult(game.global.dailyChallenge.dysfunctional.strength);
  98. currentCalc *= mult;
  99. }
  100. if (typeof game.global.dailyChallenge.toxic !== 'undefined'){
  101. mult = dailyModifiers.toxic.getMult(game.global.dailyChallenge.toxic.strength, game.global.dailyChallenge.toxic.stacks);
  102. currentCalc *= mult;
  103. }
  104. }
  105. if (game.global.challengeActive === "Toxicity" && game.challenges.Toxicity.stacks > 0){
  106. currentCalc *= Math.pow(game.challenges.Toxicity.stackMult, game.challenges.Toxicity.stacks);
  107. }
  108. if (game.global.voidBuff === "slowBreed"){
  109. currentCalc *= 0.2;
  110. }
  111. var heirloomBonus = calcHeirloomBonus("Shield", "breedSpeed", 0, true);
  112. if (heirloomBonus > 0){
  113. currentCalc *= ((heirloomBonus / 100) + 1);
  114. }
  115. return currentCalc;
  116. },
  117. getMinimumBreeding: function () {
  118. var battleTrimps = (game.portal.Coordinated.level) ? game.portal.Coordinated.currentSend : game.resources.trimps.maxSoldiers;
  119. if (battleTrimps < 5) return 5; else return battleTrimps + 1;
  120. },
  121. getBreedingCount: function () {
  122. var trimps = game.resources.trimps;
  123. return game.global.challengeActive === "Trapper" ? 0 : trimps.owned - trimps.employed;
  124. },
  125. isMetalChallenge: function () {
  126. return game.global.challengeActive === "Metal";
  127. },
  128. canGatherMetal: function () {
  129. return document.getElementById('metal').style.visibility === 'visible';
  130. }
  131. };
  132.  
  133. var _BotStrategy = {
  134. isStarted: false,
  135. _tPassiveWatcher: undefined,
  136. _tAutoBuy: undefined,
  137. middleGameStrategy: function() {
  138. if (game.global.world < 60) return;
  139.  
  140. if (game.global.formation === 0) {
  141. if (_GameHelpers.hasFormation(1)) setFormation('1');
  142. }
  143.  
  144. var enemy = _GameHelpers.getCurrentEnemyAttack();
  145. var me = game.global.soldierCurrentBlock + game.global.soldierHealthMax;
  146. if (enemy >= me && parseInt(game.global.formation) !== 1) {
  147. if (_GameHelpers.hasFormation(1)) setFormation('1');
  148. }
  149.  
  150. if (parseInt(game.global.formation) !== 2 && _GameHelpers.hasFormation(2)) {
  151. var formation2health = game.global.soldierHealthMax / 8;
  152. var me2 = formation2health + game.global.soldierCurrentBlock;
  153. if (me2 > enemy) {
  154. setFormation('2');
  155. }
  156. }
  157. },
  158. autoBuyStorage: function () {
  159. var packratLevel = (1 + game.portal.Packrat.level * (game.portal.Packrat.modifier * 100) / 100);
  160. var buildingsForResources = {
  161. food: "Barn",
  162. wood: "Shed",
  163. metal: "Forge"
  164. };
  165.  
  166. for (var res in buildingsForResources) {
  167. if (buildingsForResources.hasOwnProperty(res)) {
  168. var bldName = buildingsForResources[res];
  169. if (game.resources[res].owned / (game.resources[res].max * packratLevel) >= 0.8) {
  170. if (canAffordBuilding(bldName, false, false, false, true)) {
  171. buyBuilding(bldName, true, true);
  172. _Log.println('Building ' + bldName);
  173. }
  174. }
  175. }
  176. }
  177. },
  178. autoJobs: function() {
  179. _Job.autoJobs();
  180. },
  181. earlyGameStrategy: function (isPassive) {
  182. if (_GameHelpers.isPortal()) return;
  183.  
  184. if (parseInt(game.global.eggLoc) !== -1) {
  185. _Log.println('Destroying Easter Egg');
  186. easterEggClicked();
  187. }
  188.  
  189. _BotStrategy.autoBuyStorage();
  190. if (isPassive === false) {
  191. _BotStrategy.autoJobs();
  192. }
  193.  
  194. var breeding = _GameHelpers.getBreedingCount();
  195. var unemployed = Math.ceil(game.resources.trimps.realMax() / 2) - game.resources.trimps.employed;
  196.  
  197. if (game.buildings.Trap.owned >= 1 && game.resources.trimps.owned < game.resources.trimps.realMax() &&
  198. (breeding < _GameHelpers.getMinimumBreeding() || unemployed > 0) &&
  199. _GameHelpers.getBreedingBaseSpeed() < 1) {
  200. setGather('trimps');
  201. return;
  202. }
  203.  
  204. var hasTrap = _Buildings.hasInQueue('Trap');
  205. var cnt = game.global.challengeActive === "Trapper" ? 100 : (breeding < unemployed ? 25 : 1);
  206. if (!hasTrap && game.buildings.Trap.owned < 1 && game.resources.food.owned >= 10 && game.resources.wood.owned >= 10) {
  207. buyBuilding('Trap', true, true, cnt);
  208. return;
  209. }
  210.  
  211. if ((game.global.buildingsQueue.length > 0 && game.global.autoCraftModifier < 1) || (game.global.buildingsQueue.length > 5)) {
  212. setGather('buildings');
  213. return;
  214. }
  215.  
  216. var playerStrength = getPlayerModifier();
  217. var minimumSpeedToHelp = 1 + playerStrength;
  218.  
  219. if (getPsString('food', true) < minimumSpeedToHelp && game.resources.food.owned < 10) {
  220. setGather('food');
  221. return;
  222. }
  223.  
  224. if (getPsString('wood', true) < minimumSpeedToHelp && game.resources.wood.owned < 10) {
  225. setGather('wood');
  226. return;
  227. }
  228.  
  229. var canGetScience = game.global.challengeActive !== "Scientist";
  230.  
  231. if (canGetScience && getPsString('science', true) < minimumSpeedToHelp && game.resources.science.owned < 10) {
  232. setGather('science');
  233. return;
  234. }
  235.  
  236. var metalNeeded = _Upgrade.getUpgradePriceSumForRes('metal');
  237. if (getPsString('metal', true) < minimumSpeedToHelp && game.resources.metal.owned < Math.min(100, metalNeeded)) {
  238. setGather('metal');
  239. return;
  240. }
  241.  
  242. var needScientists = game.upgrades.Scientists.done === 0 && game.upgrades.Scientists.allowed === 1;
  243. if (canGetScience && getPsString('science', true) < minimumSpeedToHelp && (game.resources.science.owned < 60 || needScientists)) {
  244. setGather('science');
  245. return;
  246. }
  247.  
  248. if ((game.global.playerGathering === 'trimps' && (game.buildings.Trap.owned === 0 || _GameHelpers.getBreedingBaseSpeed() > 1)) ||
  249. (game.global.playerGathering === 'buildings' && game.global.buildingsQueue.length === 0)) {
  250. _Job.selectAutoJob();
  251. }
  252. },
  253. passiveWatcher: function () {
  254. if (_GameHelpers.isPortal()) return;
  255.  
  256. _BotStrategy.earlyGameStrategy(true);
  257. _Buildings.buyTribute();
  258. _Buildings.buyGym();
  259.  
  260. _BotStrategy.middleGameStrategy();
  261. },
  262. autoBuyEquipment: function () {
  263. _Equipment.autoBuyEquipment();
  264. },
  265. mapAttackStrategy: function () {
  266. _Map.mapAttackStrategy();
  267. },
  268. autoUpgrade: function() {
  269. _Upgrade.autoUpgrade();
  270. },
  271. autoBuy: function() {
  272. _Buildings.autoBuy();
  273. },
  274. auto: function () {
  275. if (_GameHelpers.isPortal()) return;
  276. _BotStrategy.earlyGameStrategy(false);
  277.  
  278. _BotStrategy.autoUpgrade();
  279. _BotStrategy.autoBuy();
  280. _BotStrategy.autoBuyEquipment();
  281. _BotStrategy.mapAttackStrategy();
  282.  
  283. _BotStrategy.middleGameStrategy();
  284.  
  285. _Map.mapDeleter();
  286. },
  287. onStartButton: function () {
  288. if (_BotStrategy.isStarted) {
  289. _BotStrategy.stop();
  290. _Log.println('Stop.');
  291. _BotStrategy.isStarted = false;
  292. } else {
  293. _BotStrategy.start();
  294. _Log.println('Started!');
  295. _BotStrategy.isStarted = true;
  296. }
  297. },
  298. stop: function () {
  299. _Log.println('BOT stop');
  300. clearInterval(_BotStrategy._tAutoBuy);
  301.  
  302. _BotStrategy._tPassiveWatcher = setInterval(_BotStrategy.passiveWatcher, 1000);
  303. _Log.println('Passive watcher started');
  304.  
  305. $('#botStart').text('Bot start');
  306. },
  307. start: function () {
  308. _Log.println('Passive watcher stop');
  309. clearInterval(_BotStrategy._tPassiveWatcher);
  310.  
  311. _Log.println('BOT start version ' + _GameHelpers.getBotVersion());
  312. _BotStrategy._tAutoBuy = setInterval(_BotStrategy.auto, 1000);
  313.  
  314. $('#botStart').text('Bot stop');
  315. }
  316. };
  317.  
  318. var _Equipment = {
  319. hasUpgradeForEquipment: function (equipName) {
  320. for (var item in game.upgrades) {
  321. if (game.upgrades.hasOwnProperty(item)) {
  322. var upgrade = game.upgrades[item];
  323. if (parseInt(upgrade.locked) === 1) continue;
  324. if (typeof upgrade.prestiges !== 'undefined' && upgrade.prestiges === equipName) {
  325. return true;
  326. }
  327. }
  328. }
  329. return false;
  330. },
  331. getMetalNeededForEquipment: function (equipName) {
  332. var price = getBuildingItemPrice(game.equipment[equipName], 'metal', true, 1);
  333. var artMult = Math.pow(1 - game.portal.Artisanistry.modifier, game.portal.Artisanistry.level);
  334. if (game.global.challengeActive === "Daily" && typeof game.global.dailyChallenge.metallicThumb !== 'undefined'){
  335. artMult *= dailyModifiers.metallicThumb.getMult(game.global.dailyChallenge.metallicThumb.strength);
  336. }
  337. if (game.global.challengeActive === "Obliterated"){
  338. artMult = (artMult === -1) ? 1e12 : (1e12 * artMult);
  339. }
  340. price = Math.ceil(price * artMult);
  341. return price;
  342. },
  343. autoBuyEquipment: function () {
  344. var maxEquipLevel = game.global.challengeActive === 'Frugal' ? 10000 : 7;
  345. var isMetal = _GameHelpers.isMetalChallenge();
  346. for (var x in game.equipment) {
  347. if (game.equipment.hasOwnProperty(x) && game.equipment[x].locked === 0) {
  348. if (_Equipment.hasUpgradeForEquipment(x)) continue;
  349. var maxLevel = isMetal ? 1 :
  350. (game.equipment[x].prestige > maxEquipLevel ? 1 : (maxEquipLevel + 1 - game.equipment[x].prestige) * 2);
  351. if (x === 'Shield' && !game.equipment['Shield'].blockNow) {
  352. maxLevel = 1;
  353. }
  354. if (game.equipment[x].level < maxLevel && canAffordBuilding(x, null, null, true)) {
  355. if (game.equipment[x].cost.hasOwnProperty('metal')) {
  356. // save metal for upgrades
  357. var currentMetal = game.resources['metal'].owned;
  358. var equipMetal = _Equipment.getMetalNeededForEquipment(x);
  359. var upgradesMetal = _Upgrade.getUpgradePriceSumForRes('metal');
  360. if (currentMetal >= (upgradesMetal + equipMetal)) {
  361. buyEquipment(x, true, true);
  362. _Log.println('Upgrading equipment ' + x);
  363. }
  364. } else {
  365. buyEquipment(x, true, true);
  366. _Log.println('Upgrading equipment ' + x);
  367. }
  368. }
  369. }
  370. }
  371. }
  372. };
  373.  
  374. var _Job = {
  375. needFarmer: 25,
  376. needLumber: 25,
  377. needMiner: 25,
  378. needScientist: 1,
  379. selectAutoJob: function () {
  380. var canGetScience = game.global.challengeActive !== "Scientist";
  381. var upgradePrice = _Upgrade.getMaximumResourceUpgradePrice();
  382. var scienceNeeded = _Upgrade.getUpgradePriceSumForRes('science');
  383. var setBasic = function () {
  384. if (_GameHelpers.canGatherMetal() && _GameHelpers.isMetalChallenge()) {
  385. setGather('metal');
  386. } else {
  387. if (canGetScience && scienceNeeded > 0) {
  388. setGather('science');
  389. } else {
  390. setGather('food');
  391. }
  392. }
  393. };
  394. if (scienceNeeded > game.resources.science.owned && canGetScience) {
  395. setGather('science');
  396. } else {
  397. if (upgradePrice !== false) {
  398. for (var x in upgradePrice) {
  399. if (upgradePrice.hasOwnProperty(x)) {
  400. if (x === 'wood' || x === 'metal' || x === 'science' || x === 'food') {
  401. setGather(x);
  402. } else {
  403. setBasic();
  404. }
  405. break;
  406. }
  407. }
  408. } else {
  409. setBasic();
  410. }
  411. }
  412. },
  413. buyJobs: function ($obj, unemployed, objName, jobId) {
  414. if ($obj.length > 0) {
  415. var needAllMax = _Job.needFarmer + _Job.needLumber + _Job.needMiner + _Job.needScientist;
  416. var breeding = _GameHelpers.getBreedingCount();
  417. var cnt = 1;
  418. var minBreeding = _GameHelpers.getMinimumBreeding();
  419. if (unemployed > needAllMax * 1000000000 && (breeding - 10000000000 > minBreeding)) {
  420. game.global.buyAmt = 10000000000;
  421. cnt = 10000000000;
  422. }
  423. else if (unemployed > needAllMax * 100000000 && (breeding - 1000000000 > minBreeding)) {
  424. game.global.buyAmt = 1000000000;
  425. cnt = 1000000000;
  426. }
  427. else if (unemployed > needAllMax * 10000000 && (breeding - 100000000 > minBreeding)) {
  428. game.global.buyAmt = 100000000;
  429. cnt = 100000000;
  430. }
  431. else if (unemployed > needAllMax * 1000000 && (breeding - 10000000 > minBreeding)) {
  432. game.global.buyAmt = 10000000;
  433. cnt = 10000000;
  434. }
  435. else if (unemployed > needAllMax * 100000 && (breeding - 1000000 > minBreeding)) {
  436. game.global.buyAmt = 1000000;
  437. cnt = 1000000;
  438. }
  439. else if (unemployed > needAllMax * 10000 && (breeding - 100000 > minBreeding)) {
  440. game.global.buyAmt = 100000;
  441. cnt = 100000;
  442. }
  443. else if (unemployed > needAllMax * 1000 && (breeding - 10000 > minBreeding)) {
  444. game.global.buyAmt = 10000;
  445. cnt = 10000;
  446. }
  447. else if (unemployed > needAllMax * 100 && (breeding - 1000 > minBreeding)) {
  448. game.global.buyAmt = 1000;
  449. cnt = 1000;
  450. }
  451. else if (unemployed > needAllMax * 10 && (breeding - 100 > minBreeding)) {
  452. numTab(4);
  453. cnt = 100;
  454. }
  455. else if (unemployed > needAllMax * 2.5 && (breeding - 25 > minBreeding)) {
  456. numTab(3);
  457. cnt = 25;
  458. }
  459. else if (unemployed > needAllMax && (breeding - 10 > minBreeding)) {
  460. numTab(2);
  461. cnt = 10;
  462. }
  463. else {
  464. numTab(1);
  465. cnt = 1;
  466. }
  467. buyJob(jobId, true, true); // confirmed, noTip
  468. numTab(1); // +1
  469. _Log.println('New ' + objName + (cnt > 1 ? " x" + cnt : ''), 'Combat');
  470. return cnt;
  471. } else {
  472. return 0;
  473. }
  474. },
  475. getJobsNeededCounts: function () {
  476. var maxTrimps = game.resources.trimps.realMax();
  477. var unemployed = Math.ceil(maxTrimps / 2) - game.resources.trimps.employed;
  478. var jobsTotal =
  479. unemployed +
  480. game.jobs.Farmer.owned +
  481. game.jobs.Lumberjack.owned +
  482. game.jobs.Miner.owned +
  483. game.jobs.Scientist.owned;
  484. var hasFarmer = game.jobs.Farmer.locked === 0;
  485. var hasLumber = game.jobs.Lumberjack.locked === 0;
  486. var hasMiner = game.jobs.Miner.locked === 0;
  487. var hasScientist = game.jobs.Scientist.locked === 0;
  488. var needAll =
  489. (hasFarmer ? _Job.needFarmer : 0) +
  490. (hasLumber ? _Job.needLumber : 0) +
  491. (hasMiner ? _Job.needMiner : 0) +
  492. (hasScientist ? _Job.needScientist : 0);
  493. if (needAll < 1) needAll = 1;
  494. var minOwned = Math.min(
  495. game.jobs.Farmer.owned,
  496. game.jobs.Lumberjack.owned,
  497. game.jobs.Miner.owned,
  498. Math.floor(jobsTotal * 0.25)
  499. );
  500. if (game.global.world < 20) minOwned = minOwned / 2;
  501. if (minOwned > 30) minOwned = 30; // for science
  502. if (minOwned < 1) minOwned = 1;
  503. var jobsWithoutScientists = jobsTotal - minOwned;
  504.  
  505. return {
  506. Scientist: _Job.needScientist ? minOwned : -1,
  507. Farmer: _Job.needFarmer ? Math.floor(jobsWithoutScientists * _Job.needFarmer / needAll) : -1,
  508. Lumberjack: _Job.needLumber ? Math.floor(jobsWithoutScientists * _Job.needLumber / needAll) : -1,
  509. Miner: _Job.needMiner ? Math.floor(jobsWithoutScientists * _Job.needMiner / needAll) : -1
  510. };
  511. },
  512. autoJobs: function () {
  513. var breeding = game.resources.trimps.owned - game.resources.trimps.employed;
  514. if (breeding < (_GameHelpers.getMinimumBreeding() + 1) && game.global.challengeActive !== 'Trapper') return;
  515.  
  516. var maxTrimps = game.resources.trimps.realMax();
  517. var unemployed = Math.ceil(maxTrimps / 2) - game.resources.trimps.employed;
  518.  
  519. var trainerCost = _GameHelpers.getJobPrice('Trainer', 'food');
  520. if ((trainerCost < game.resources.food.owned) && unemployed <= 0 && game.jobs.Farmer.owned > 1 && game.jobs.Trainer.locked === 0) {
  521. _Log.println('Fire farmer, sorry. We need trainers.');
  522. game.global.firing = true;
  523. buyJob('Farmer', true, true);
  524. game.global.firing = false;
  525. }
  526.  
  527. if (unemployed <= 0) return;
  528.  
  529. if (trainerCost <= game.resources.food.owned && game.jobs.Trainer.locked === 0) {
  530. buyJob('Trainer', true, true);
  531. _Log.println('New trainer');
  532. return 1;
  533. }
  534.  
  535. if (game.jobs.Geneticist.locked === 0 && _GameHelpers.getBreedingTotalSpeed() > maxTrimps * 2) {
  536. buyJob('Geneticist', true, true);
  537. _Log.println('New geneticist');
  538. return 1;
  539. }
  540.  
  541. var cnt = 0;
  542. var $jobsBlock = $('#jobsHere');
  543.  
  544. var $explorer = $jobsBlock.find('.thingColorCanAfford[id=Explorer]');
  545. if ($explorer.length > 0) {
  546. buyJob('Explorer', true, true);
  547. _Log.println('New explorer');
  548. return ++cnt;
  549. }
  550.  
  551. var $farmer = $jobsBlock.find('.thingColorCanAfford[id=Farmer]');
  552.  
  553. var toHire = _Job.getJobsNeededCounts();
  554.  
  555. if (toHire.Farmer > 0 && game.jobs.Farmer.owned < toHire.Farmer) {
  556. cnt += _Job.buyJobs($farmer, unemployed, 'farmer', 'Farmer');
  557. } else if (toHire.Lumberjack > 0 && game.jobs.Lumberjack.owned < toHire.Lumberjack) {
  558. var $lumber = $jobsBlock.find('.thingColorCanAfford[id=Lumberjack]');
  559. cnt += _Job.buyJobs($lumber, unemployed, 'lumberjack', 'Lumberjack');
  560. } else if (toHire.Miner > 0 && game.jobs.Miner.owned < toHire.Miner) {
  561. var $miner = $jobsBlock.find('.thingColorCanAfford[id=Miner]');
  562. cnt += _Job.buyJobs($miner, unemployed, 'miner', 'Miner');
  563. } else if (toHire.Scientist > 0 && game.jobs.Scientist.owned < toHire.Scientist) {
  564. var $science = $jobsBlock.find('.thingColorCanAfford[id=Scientist]');
  565. cnt += _Job.buyJobs($science, unemployed, 'scientist', 'Scientist');
  566. }
  567.  
  568. if (unemployed > 0 && cnt === 0) {
  569. cnt += _Job.buyJobs($farmer, unemployed, 'farmer', 'Farmer');
  570. }
  571.  
  572. return cnt;
  573. }
  574. };
  575.  
  576. var _Buildings = {
  577. buyTribute: function () {
  578. if (_GameHelpers.isMetalChallenge()) return;
  579. var canAfford = canAffordBuilding("Tribute", false, false, false, true);
  580. if (canAfford && game.buildings.Tribute.locked !== 1) {
  581. buyBuilding("Tribute", true, true);
  582. _Log.println('Building ' + "Tribute");
  583. }
  584. },
  585. buyGym: function () {
  586. var canAfford = canAffordBuilding("Gym", false, false, false, true);
  587. if (canAfford && game.buildings.Gym.locked !== 1) {
  588. buyBuilding("Gym", true, true);
  589. _Log.println('Building ' + "Gym");
  590. }
  591. },
  592. hasInQueue: function (item) {
  593. for (var x in game.global.buildingsQueue) {
  594. var queueItem = game.global.buildingsQueue[x].split('.')[0];
  595. if (queueItem === item) {
  596. return true;
  597. }
  598. }
  599. return false;
  600. },
  601. autoBuy: function () {
  602. if (_GameHelpers.isMetalChallenge()) {
  603. _Buildings.buyGym();
  604. return;
  605. } // buy only Gym and Trainer
  606. var toBuy;
  607. for (var item in game.buildings) {
  608. if (item === 'Barn' || item === 'Shed' || item === 'Forge' || item === 'Wormhole' || item === 'Trap') continue;
  609. if (!game.buildings.Collector.locked &&
  610. (item === 'Mansion' || item === 'Hotel' || item === 'Resort' || item === 'House' || item === 'Hut')) continue;
  611. if (game.upgrades.Gigastation.done >= 10 && item === 'Collector') continue;
  612.  
  613. if (game.buildings.hasOwnProperty(item)) {
  614. if (parseInt(game.buildings[item].locked) === 1) continue;
  615. var canAfford = canAffordBuilding(item, false, false, false, true);
  616. if (canAfford) {
  617. if (item === 'Nursery') {
  618. var isElectro = game.global.challengeActive === "Electricity";
  619. var mult = game.global.brokenPlanet ? (game.global.world >= 80 ? 2 : 1.5) : 1;
  620. var enoughNursery = (game.buildings.Nursery.owned >= (game.buildings.Tribute.owned * mult) ||
  621. game.buildings.Nursery.owned >= (game.buildings.Gym.owned * mult));
  622.  
  623. if ((isElectro || !enoughNursery) && !_Buildings.hasInQueue('Nursery'))
  624. {
  625. toBuy = item;
  626. }
  627. } else {
  628. toBuy = item;
  629. }
  630. }
  631. }
  632. }
  633. if (typeof toBuy !== 'undefined') {
  634. buyBuilding(toBuy, true, true);
  635. _Log.println('Building ' + toBuy);
  636. }
  637. }
  638. };
  639.  
  640. var _Log = {
  641. println: function (mes, type) {
  642. if (typeof type === 'undefined') type = "Story";
  643. message("BOT: " + mes, type);
  644. },
  645. message: function (messageString, type, lootIcon, extraClass, extraTag, htmlPrefix) {
  646. if (type === 'Loot' && lootIcon === null) return;
  647. if (type === 'Combat' && (lootIcon === null || typeof lootIcon === 'undefined')) return;
  648. if (type === 'Loot' &&
  649. (messageString.indexOf('You just found') > -1 ||
  650. messageString.indexOf('You found') > -1 ||
  651. messageString.indexOf('That guy just left') > -1 ||
  652. (messageString.indexOf(' dropped ') > -1 && messageString.indexOf('That ') > -1) ||
  653. messageString.indexOf(' manage to ') > -1 ||
  654. messageString.indexOf('Then he died') > -1 ||
  655. messageString.indexOf(' popped out!') > -1 ||
  656. messageString.indexOf('That Feyimp gave you') > -1 ||
  657. messageString.indexOf('in that dead Tauntimp') > -1 ||
  658. messageString.indexOf('fragments from that Flutimp') > -1 ||
  659. messageString.indexOf('That Jestimp gave you') > -1 ||
  660. messageString.indexOf('That Titimp made your Trimps super strong') > -1 ||
  661. messageString.indexOf('You scored ') > -1 ||
  662. messageString.indexOf('Hulking Mutimp ') > -1 ||
  663. messageString.indexOf('Cubist art is your favorite!') > -1 ||
  664. messageString.indexOf('Reward encountered: ') > -1 ||
  665. messageString.indexOf('Findings: ') > -1 ||
  666. messageString.indexOf('Salvage results: ') > -1 ||
  667. messageString.indexOf('You hear nearby Kittimps ') > -1
  668. )) return;
  669. if (type === 'Story' && typeof lootIcon === 'undefined' &&
  670. messageString.indexOf('BOT: New ') > -1) return;
  671. var showTimestamps = parseInt(game.options.menu.timestamps.enabled) === 1;
  672. if (type === 'Notices' && messageString === 'Game Saved!') {
  673. var t = showTimestamps ? getCurrentTime() : updatePortalTimer(true);
  674. $('#saveIndicator').find('.autosaving').text(t);
  675. return;
  676. }
  677. if (messageString.indexOf('The ground up Venimp now increases your Trimps') > -1) {
  678. _BotUI.updateSuperTrimps();
  679. return;
  680. }
  681. if (messageString.indexOf('You killed a Magnimp! The strong magnetic forces now increase your loot by') > -1) {
  682. _BotUI.updateSuperTrimps();
  683. return;
  684. }
  685. if (messageString.indexOf('Seeing the Whipimps fall is causing all of your Trimps to work') > -1) {
  686. _BotUI.updateSuperTrimps();
  687. return;
  688. }
  689.  
  690. var log = document.getElementById("log");
  691. var displayType = "block";
  692. var prefix = "";
  693. var addId = "";
  694. if (messageString === "Game Saved!" || extraClass === 'save') {
  695. addId = " id='saveGame'";
  696. if (document.getElementById('saveGame') !== null) {
  697. log.removeChild(document.getElementById('saveGame'));
  698. }
  699. }
  700. if (game.options.menu.timestamps.enabled) {
  701. messageString = (showTimestamps ? getCurrentTime() : updatePortalTimer(true)) + " " + messageString;
  702. }
  703. if (!htmlPrefix) {
  704. if (lootIcon && lootIcon.charAt(0) === "*") {
  705. lootIcon = lootIcon.replace("*", "");
  706. prefix = "icomoon icon-";
  707. }
  708. else prefix = "glyphicon glyphicon-";
  709. if (type === "Story") messageString = "<span class='glyphicon glyphicon-star'></span> " + messageString;
  710. if (type === "Combat") messageString = "<span class='glyphicon glyphicon-flag'></span> " + messageString;
  711. if (type === "Loot" && lootIcon) messageString = "<span class='" + prefix + lootIcon + "'></span> " + messageString;
  712. if (type === "Notices") {
  713. messageString = "<span class='glyphicon glyphicon-off'></span> " + messageString;
  714. }
  715. } else {
  716. messageString = htmlPrefix + " " + messageString;
  717. }
  718. var messageHTML = "<span" + addId + " class='" + type + "Message message" + " " + extraClass + "' style='display: " + displayType + "'>" + messageString + "</span>";
  719. pendingLogs.all.push(messageHTML);
  720. postMessages();
  721.  
  722. var $allLogs = $('#log').find('span');
  723. $allLogs.slice(0, -30).remove();
  724. }
  725. };
  726.  
  727. var _Map = {
  728. needAttackCurrentMap: function () {
  729. return (typeof game.mapsAttacked[game.global.world] === 'undefined');
  730. },
  731. hasMapOfCurrentLevel: function () {
  732. for (var x in game.global.mapsOwnedArray) {
  733. if (game.global.mapsOwnedArray.hasOwnProperty(x)) {
  734. var mapObj = game.global.mapsOwnedArray[x];
  735. if (parseInt(mapObj.level) === parseInt(game.global.world)) return true;
  736. }
  737. }
  738. return false;
  739. },
  740. buyNewMapOfCurrentLevel: function () {
  741. if (!_Map.isSelectingMap()) {
  742. mapsClicked(true);
  743. }
  744. var money = game.resources.fragments.owned;
  745. if (money > 0) {
  746. var currentMapPrice = updateMapCost(true);
  747. if (money >= currentMapPrice) {
  748. var result = buyMap();
  749. if (result === 1) {
  750. _Log.println('Bought new map level ' + game.global.world);
  751. } else {
  752. console.log('Buy map result = ' + result);
  753. }
  754. } else {
  755. console.log('No fragments (' + money + ') to buy map for ' + currentMapPrice);
  756. }
  757. }
  758. },
  759. attackMapOfCurrentLevel: function (knownMapId, isPrestige) {
  760. var x, mapObj;
  761. var breeding = _GameHelpers.getBreedingCount();
  762.  
  763. game.global.lookingAtMap = '';
  764. if (typeof knownMapId === 'undefined') {
  765. for (x in game.global.mapsOwnedArray) {
  766. if (game.global.mapsOwnedArray.hasOwnProperty(x)) {
  767. mapObj = game.global.mapsOwnedArray[x];
  768. var isVoid = mapObj.location === "Void";
  769. if (isVoid && _GameHelpers.isMetalChallenge()) continue; // skip Void on Metal challenge
  770. if (parseInt(mapObj.level) === parseInt(game.global.world)) {
  771. game.global.lookingAtMap = mapObj.id;
  772. break;
  773. }
  774. }
  775. }
  776. } else {
  777. game.global.lookingAtMap = knownMapId;
  778. }
  779.  
  780. if (game.global.lookingAtMap !== '') {
  781. _Log.println('Attacking ' + (isPrestige ? 'prestige ' : '') + 'map ' + game.global.lookingAtMap);
  782. game.options.menu.alwaysAbandon.enabled = 1; // GO TO MAPS!
  783. mapsClicked(true);
  784. game.mapsAttacked[game.global.world] = true;
  785. game.global.repeatMap = true; // REPEAT
  786. repeatClicked(true);
  787. runMap();
  788. if (breeding < (_GameHelpers.getMinimumBreeding() + 1)) fightManual();
  789. } else {
  790. if (!_GameHelpers.isMetalChallenge()) console.log('where is my map?');
  791. }
  792. },
  793. getPrestigeMapToAttack: function () {
  794. for (var x in game.global.mapsOwnedArray) {
  795. if (game.global.mapsOwnedArray.hasOwnProperty(x)) {
  796. var mapObj = game.global.mapsOwnedArray[x];
  797. if (parseInt(mapObj.clears) === 0
  798. && parseInt(mapObj.level) <= parseInt(game.global.world)
  799. && mapObj.noRecycle) {
  800. return mapObj.id;
  801. }
  802. }
  803. }
  804. return -1;
  805. },
  806. attackCurrentMap: function () {
  807. document.getElementById("mapLevelInput").value = game.global.world;
  808.  
  809. var prestigeMapToAttack = _Map.getPrestigeMapToAttack();
  810. if (prestigeMapToAttack !== -1) {
  811. _Map.attackMapOfCurrentLevel(prestigeMapToAttack, true);
  812. return;
  813. }
  814.  
  815. if (!_Map.hasMapOfCurrentLevel()) {
  816. _Map.buyNewMapOfCurrentLevel();
  817. }
  818.  
  819. if (_Map.hasMapOfCurrentLevel()) {
  820. _Map.attackMapOfCurrentLevel();
  821. } else {
  822. console.log('no map of current level ' + game.global.world);
  823. }
  824. },
  825. isAbleToAttackMaps: function() {
  826. return (game.global.world >= 6) && (!game.global.preMapsActive || game.global.currentMapId !== '');
  827. },
  828. isSelectingMap: function() {
  829. return document.getElementById("grid").style.display === 'none' &&
  830. document.getElementById("preMaps").style.display === 'block';
  831. },
  832. mapAttackStrategy: function () {
  833. if (!_Map.isAbleToAttackMaps()) return;
  834.  
  835. if (game.global.pauseFight) {
  836. _Log.println('Enabling auto attack!');
  837. fightManual();
  838. game.global.pauseFight = false;
  839. pauseFight(true); // update only
  840. } else {
  841. if (_Map.needAttackCurrentMap()) {
  842. _Map.attackCurrentMap();
  843. } else {
  844. if (_Map.hasMapOfCurrentLevel() && game.global.currentMapId === '') {
  845. game.global.lookingAtMap = '';
  846. var map_id, map_name = '', isVoid;
  847. for (var x in game.global.mapsOwnedArray) {
  848. if (game.global.mapsOwnedArray.hasOwnProperty(x)) {
  849. var mapObj = game.global.mapsOwnedArray[x];
  850. isVoid = mapObj.location === "Void";
  851. if (isVoid && _GameHelpers.isMetalChallenge()) continue; // skip Void on Metal challenge
  852. if (mapObj.level <= game.global.world && mapObj.noRecycle === true && mapObj.clears === 0) {
  853. game.global.lookingAtMap = mapObj.id;
  854. map_id = x;
  855. map_name = mapObj.name;
  856. break;
  857. }
  858. }
  859. }
  860. if (game.global.lookingAtMap !== '' && typeof map_id !== 'undefined') {
  861. isVoid = game.global.mapsOwnedArray[map_id].location === "Void";
  862. if (isVoid) {
  863. if (_GameHelpers.isMetalChallenge()) return;
  864. if (game.global.lastClearedMapCell >= game.global.mapGridArray.length - 2) {
  865. _Log.println('Attacking Void map ' + map_name + ' level (' + game.global.mapsOwnedArray[map_id].level + ')');
  866. } else {
  867. return;// attack Void only in last 2 cells
  868. }
  869. } else {
  870. _Log.println('Attacking prestige map ' + map_name + ' level (' + game.global.mapsOwnedArray[map_id].level + ')');
  871. }
  872. game.options.menu.alwaysAbandon.enabled = 1; // GO TO MAPS!
  873. mapsClicked(true);
  874. game.global.repeatMap = true; // REPEAT
  875. repeatClicked(true);
  876. game.global.mapsOwnedArray[map_id].clears = 1;
  877. runMap();
  878. if (_GameHelpers.getBreedingCount() < (_GameHelpers.getMinimumBreeding() + 1)) fightManual();
  879. }
  880. } else {
  881. if (game.global.currentMapId !== '') {
  882. var lastMapCell = game.global.mapGridArray[game.global.mapGridArray.length - 1];
  883. var specialGift = '';
  884. if (lastMapCell.special !== '') {
  885. specialGift = game.mapUnlocks[lastMapCell.special];
  886. }
  887. var needExitMap = (specialGift === '' || specialGift.prestige !== true) &&
  888. lastMapCell.special !== 'Heirloom' &&
  889. lastMapCell.name !== 'Warden' &&
  890. lastMapCell.name !== 'Robotrimp' &&
  891. specialGift.canRunOnce !== true;
  892. if (needExitMap) {
  893. _Log.println('Leaving map ' + game.global.currentMapId + '...');
  894. mapsClicked(true); // go to maps
  895. recycleMap(-1, true);
  896. mapsClicked(); // go to world
  897. }
  898. } else if (_Map.isSelectingMap()) {
  899. mapsClicked(); // go to world
  900. }
  901. }
  902. }
  903. }
  904. },
  905. mapDeleter: function() {
  906. if (game.global.currentMapId === '') {
  907. for (var x in game.global.mapsOwnedArray) {
  908. var map = game.global.mapsOwnedArray[x];
  909. if (map.level < (game.global.world - 10) && map.noRecycle !== true) {
  910. game.global.lookingAtMap = map['id'];
  911. _Log.println('Deleting map ' + map.name + ' (' + map.level + ')');
  912. recycleMap(-1, true);
  913. break;
  914. }
  915. }
  916. }
  917. }
  918. };
  919.  
  920. var _Upgrade = {
  921. autoUpgrade: function () {
  922. for (var item in game.upgrades) {
  923. if (game.upgrades.hasOwnProperty(item)) {
  924. var upgrade = game.upgrades[item];
  925. if (parseInt(upgrade.locked) === 1) continue;
  926. var canAfford = canAffordTwoLevel(upgrade);
  927. if (canAfford) {
  928. if (item === "Coordination") {
  929. if (!canAffordCoordinationTrimps()) continue;
  930. }
  931. if (item === "Gigastation") {
  932. var minAddon = Math.floor(game.global.highestLevelCleared / 6);
  933. var minWaprstation = Math.floor(game.global.world / 6) + minAddon + game.upgrades.Gigastation.done * 2;
  934. if (minWaprstation < 6 + minAddon) minWaprstation = 6 + minAddon;
  935. if (game.buildings.Warpstation.owned < minWaprstation) continue;
  936. }
  937. buyUpgrade(item, true, true);
  938. _Log.println('Researching ' + item + ' level ' + parseInt(upgrade.done));
  939. _Job.selectAutoJob();
  940. return 1;
  941. }
  942. }
  943. }
  944. return 0;
  945. },
  946. getUpgradePrice: function (upgradeObject) {
  947. var price, result = {};
  948. for (var cost in upgradeObject.cost) {
  949. if (upgradeObject.cost.hasOwnProperty(cost)) {
  950. if (typeof upgradeObject.cost[cost] === 'object' && typeof upgradeObject.cost[cost][1] === 'undefined') {
  951. var costItem = upgradeObject.cost[cost];
  952. for (var item in costItem) {
  953. if (costItem.hasOwnProperty(item)) {
  954. price = costItem[item];
  955. if (upgradeObject.prestiges && (item === "metal" || item === "wood")) {
  956. if (game.global.challengeActive === "Daily" && typeof game.global.dailyChallenge.metallicThumb !== 'undefined') {
  957. price *= dailyModifiers.metallicThumb.getMult(game.global.dailyChallenge.metallicThumb.strength);
  958. }
  959. price *= Math.pow(1 - game.portal.Artisanistry.modifier, game.portal.Artisanistry.level);
  960. }
  961. if (typeof price === 'function') price = price();
  962. if (typeof price[1] !== 'undefined') price = resolvePow(price, upgradeObject);
  963. result[item] = price;
  964. }
  965. }
  966. }
  967. }
  968. }
  969. return result;
  970. },
  971. getAllUpgradePrice: function () {
  972. var totalPrice = {};
  973. for (var item in game.upgrades) {
  974. if (game.upgrades.hasOwnProperty(item)) {
  975. var upgrade = game.upgrades[item];
  976. if (parseInt(upgrade.locked) === 1) continue;
  977. var price = _Upgrade.getUpgradePrice(upgrade);
  978. for (var res in price) {
  979. if (price.hasOwnProperty(res)) {
  980. if (typeof totalPrice[res] === 'undefined') totalPrice[res] = 0;
  981. totalPrice[res] += price[res];
  982. }
  983. }
  984. }
  985. }
  986. return totalPrice;
  987. },
  988. getUpgradePriceSumForRes: function (res) {
  989. var totalPrice = _Upgrade.getAllUpgradePrice();
  990. if (typeof totalPrice[res] !== 'undefined') {
  991. return totalPrice[res];
  992. } else {
  993. return 0;
  994. }
  995. },
  996. getMaximumResourceUpgradePrice: function () {
  997. var totalPrice = _Upgrade.getAllUpgradePrice(), maxPriceName = '', maxPrice = 0;
  998. for (var res in totalPrice) {
  999. if (totalPrice.hasOwnProperty(res)) {
  1000. if (totalPrice[res] > maxPrice) {
  1001. maxPrice = totalPrice[res];
  1002. maxPriceName = res;
  1003. }
  1004. }
  1005. }
  1006. var result = {};
  1007. if (maxPriceName !== '') {
  1008. result[maxPriceName] = maxPrice;
  1009. return result;
  1010. } else {
  1011. return false;
  1012. }
  1013. }
  1014. };
  1015.  
  1016. var _BotUI = {
  1017. _logEnabled: true,
  1018. _tTitimp: undefined,
  1019. _tStyleFix: undefined,
  1020. styleUpdate: function () {
  1021. // remove counts
  1022. //noinspection CssUnusedSymbol
  1023. $('head').append($("<style type=\"text/css\">\n" +
  1024. "span.thingName{font-size:85%;}\n"+
  1025. ".queueItem,.btn{padding:0}\n" +
  1026. ".thingColorCanNotAfford.upgradeThing{background-color:#530053;}\n" +
  1027. "#battleSideTitle{padding:0}\n" +
  1028. ".battleSideBtnContainer{margin-top:0;}\n" +
  1029. "#logBtnGroup{display:none}\n" +
  1030. "#log{height:100%;}\n" +
  1031. ".glyphicon-apple{color:orangered;}\n" +
  1032. ".glyphicon-tree-deciduous{color:limegreen;}\n"+
  1033. ".icomoon.icon-cubes{color:silver;}\n"+
  1034. ".icomoon.icon-diamond{color:white;}\n"+
  1035. "#buildingsTitleDiv,#upgradesTitleDiv,#equipmentTitleDiv{display:none}\n"+
  1036. "#buildingsQueue{height:30px}\n"+
  1037. "#buyHere .alert.badge{display:none}\n"+
  1038. '</style>'));
  1039.  
  1040. // remove tabs
  1041. $('#buyTabs').hide();
  1042. filterTabs('all');
  1043. // fix height
  1044. $('#topRow,#queueContainer').css('margin-bottom', '0');
  1045. $('#jobsTitleDiv').css('padding', '0').css('font-size', 'smaller');
  1046. $('#buyHere').css('margin', '0').css('padding', '0').css('overflow-x', 'hidden');
  1047. $('#queueContainer').css('height', '70px');
  1048. $('#numTabs').css('margin', '0');
  1049. $('#buyContainer').css('height', 'calc(99vh - 20vw - 96px)');
  1050. // add button
  1051. $('#settingsTable').find('tr').append('<td class="btn btn-info" id="botStart" title="' + _GameHelpers.getBotVersion() + '">Bot start</td>');
  1052. $('#botStart').on('click', _BotStrategy.onStartButton);
  1053. // add grid
  1054. var $grid = $('<table style="width:100%;margin-top:4px;font-size:smaller;"><tr>' +
  1055. '<td id="magnimp-cell"><span class="glyphicon glyphicon-magnet"></span><label style="margin-left:4px" title="Magimp">...</label></td>' +
  1056. '<td id="venimp-cell"><span class="glyphicon glyphicon-glass"></span><label style="margin-left:4px" title="Venimp">...</label></td>' +
  1057. '</tr><tr>' +
  1058. '<td id="whipimp-cell"><span class="glyphicon glyphicon-star"></span><label style="margin-left:4px" title="Whipimp">...</label></td>' +
  1059. '<td id="titimp-cell"><span class="icomoon icon-hammer"></span><label style="margin-left:4px" title="Titimp">' + prettify(game.global.titimpLeft) + '</label></td>' +
  1060. '</tr></table>');
  1061. $('#battleBtnsColumn').append($grid);
  1062. _BotUI.updateSuperTrimps();
  1063. },
  1064. styleFix: function () {
  1065. _BotUI.disableLog();
  1066.  
  1067. var $buyBoxThings = $('.buyBox').find('.thing');
  1068. $buyBoxThings.find('br').remove();
  1069. $buyBoxThings.find('.thingOwned').css('margin-left', '4px');
  1070.  
  1071. $('#buildingsTitleDiv,#upgradesTitleDiv,#equipmentTitleDiv').css('display', 'none');
  1072.  
  1073. if (typeof game.passedMaps === 'undefined') game.passedMaps = {};
  1074. if (typeof game.mapsAttacked === 'undefined') game.mapsAttacked = {};
  1075.  
  1076. for (var x in game.passedMaps) if (x > game.global.world) {
  1077. // Game restart?
  1078. game.passedMaps = {};
  1079. game.mapsAttacked = {};
  1080. $('#venimp-cell').find('label').text('...');
  1081. $('#magnimp-cell').find('label').text('...');
  1082. $('#whipimp-cell').find('label').text('...');
  1083. break;
  1084. }
  1085.  
  1086. var hasItem = false;
  1087. if (typeof game.mapUnlocks === 'undefined') {
  1088. clearInterval(_BotUI._tStyleFix);
  1089. _BotUI._tStyleFix = setInterval(_BotUI.styleFix, 2000);
  1090. } else {
  1091. for (x in game.mapUnlocks) {
  1092. if (game.mapUnlocks.hasOwnProperty(x)) {
  1093. var notPass = game.mapUnlocks[x].startAt <= game.global.world && (typeof game.passedMaps[game.mapUnlocks[x].startAt] === 'undefined' || game.passedMaps[game.mapUnlocks[x].startAt] < 1);
  1094. if (notPass) {
  1095. $('#battleSideTitle').css('background-color', notPass ? '#A00' : '#600');
  1096. hasItem = true;
  1097. break;
  1098. }
  1099. }
  1100. }
  1101. }
  1102. if (!hasItem) {
  1103. $('#battleSideTitle').css('background-color', 'transparent');
  1104. }
  1105. game.passedMaps[game.global.world] = game.global.mapBonus;
  1106. if (game.global.mapBonus > 0) {
  1107. for (x in game.mapUnlocks) {
  1108. if (game.mapUnlocks.hasOwnProperty(x)) {
  1109. if (game.mapUnlocks[x].startAt < game.global.world) {
  1110. game.passedMaps[game.mapUnlocks[x].startAt] = 1;
  1111. }
  1112. }
  1113. }
  1114. }
  1115. },
  1116. disableLog: function () {
  1117. if (_BotUI._logEnabled) {
  1118. message = _Log.message;
  1119. _BotUI._logEnabled = false;
  1120. }
  1121. },
  1122. updateSuperTrimps: function () {
  1123. var whipStrength = Math.pow(1.003, game.unlocks.impCount.Whipimp);
  1124. whipStrength = prettify((whipStrength - 1) * 100) + "%";
  1125. var magimpStrength = Math.pow(1.003, game.unlocks.impCount.Magnimp);
  1126. magimpStrength = prettify((magimpStrength - 1) * 100) + "%";
  1127. var venimpStrength = Math.pow(1.003, game.unlocks.impCount.Venimp);
  1128. venimpStrength = prettify((venimpStrength - 1) * 100) + "%";
  1129.  
  1130. var mag = $('#magnimp-cell').find('label');
  1131. if (mag.text() !== magimpStrength) mag.text(magimpStrength);
  1132. var whip = $('#whipimp-cell').find('label');
  1133. if (whip.text() !== whipStrength) whip.text(whipStrength);
  1134. var ven = $('#venimp-cell').find('label');
  1135. if (ven.text() !== venimpStrength) ven.text(venimpStrength);
  1136. },
  1137. titimpUpdate: function () {
  1138. $('#titimp-cell').find('label').text(prettify(game.global.titimpLeft > 0 ? game.global.titimpLeft : 0));
  1139. },
  1140. initTrimpsTools: function() {
  1141. var TrimpsTools = {
  1142. Helpers: _GameHelpers,
  1143. Strategy: _BotStrategy,
  1144. Equipment: _Equipment,
  1145. Job: _Job,
  1146. Buildings: _Buildings,
  1147. Log: _Log,
  1148. Map: _Map,
  1149. Upgrade: _Upgrade,
  1150. UI: _BotUI
  1151. };
  1152.  
  1153. if (typeof game.TrimpsTools === 'undefined') {
  1154. game.TrimpsTools = TrimpsTools;
  1155. }
  1156. if (typeof unsafeWindow !== 'undefined') unsafeWindow.TrimpsTools = TrimpsTools;
  1157. },
  1158. init: function () {
  1159. _BotUI._tStyleFix = setInterval(_BotUI.styleFix, 2000);
  1160. _BotUI._tTitimp = setInterval(_BotUI.titimpUpdate, 500);
  1161.  
  1162. _BotUI.styleUpdate();
  1163. _BotUI.styleFix();
  1164. _BotUI.disableLog();
  1165.  
  1166. _BotUI.initTrimpsTools();
  1167. }
  1168. };
  1169.  
  1170. setTimeout(function () {
  1171. _Log.println('Trimps BOT version ' + _GameHelpers.getBotVersion());
  1172. _BotUI.init();
  1173. _BotStrategy.stop(); // start passive watcher
  1174. }, 1000);
  1175.  
  1176. })();