Trimps tools

Trimps tools (visual)

目前为 2018-12-10 提交的版本,查看 最新版本

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