Critter Auto Script

Basic Script to Automate Critter Mound

当前为 2020-03-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Critter Auto Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.9.2
  5. // @description Basic Script to Automate Critter Mound
  6. // @author You
  7. // @match https://crittermound.com/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. var first, mother, father;
  14.  
  15. var main = function() {
  16. if (game.femaleMound().length > 0) {
  17. first = game.femaleMound()[0];
  18. mother = game.mother();
  19. if (first.traits[0].trueValue > mother.traits[0].trueValue && first.traits[1].trueValue > mother.traits[1].trueValue && first.traits[2].trueValue > mother.traits[2].trueValue && first.traits[3].trueValue > mother.traits[3].trueValue && first.traits[4].trueValue > mother.traits[4].trueValue) {
  20. game.Move("Mate", "Female", game, game)
  21. console.log("New Queen");
  22. } else {
  23. if (Math.random() >= 0.5) {
  24. if (game.maxArmyMoundSize() > game.armyMound().length) {
  25. game.Move("Army", "Female", game, game)
  26. console.log("New Female Army");
  27. } else {
  28. console.log("To many Army")
  29. }
  30. } else {
  31. game.Move("Worker", "Female", game, game)
  32. console.log("New Female Worker");
  33. }
  34. }
  35. }
  36.  
  37. if (game.maleMound().length > 0) {
  38. first = game.maleMound()[0];
  39. mother = game.father();
  40. if (first.traits[0].trueValue > mother.traits[0].trueValue && first.traits[1].trueValue > mother.traits[1].trueValue && first.traits[2].trueValue > mother.traits[2].trueValue && first.traits[3].trueValue > mother.traits[3].trueValue && first.traits[4].trueValue > mother.traits[4].trueValue) {
  41. game.Move("Mate", "Male", game, game);
  42. console.log("New King");
  43. } else {
  44. if (Math.random() >= 0.5) {
  45. if (game.maxArmyMoundSize() > game.armyMound().length) {
  46. game.Move("Army", "Male", game, game)
  47. console.log("New Male Army");
  48. } else {
  49. console.log("To many Army")
  50. }
  51. } else {
  52. game.Move("Worker", "Male", game, game)
  53. console.log("New Male Worker");
  54. }
  55. }
  56. }
  57. };
  58.  
  59. function workerCode() {
  60. this.onmessage = function (event) {
  61. }
  62.  
  63. var time = 500;
  64. setTimeout(function () { Tick() }, time);
  65.  
  66. function Tick() {
  67. postMessage("Tick");
  68. setTimeout(function () { Tick() }, time);
  69. }
  70. }
  71.  
  72. var blob = new Blob([
  73. "(" + workerCode.toString() + ")()"
  74. ], {type: "text/javascript"});
  75.  
  76. // Note: window.webkitURL.createObjectURL() in Chrome 10+.
  77. var worker = new Worker(window.URL.createObjectURL(blob));
  78. worker.onmessage = function (e) {
  79. main();
  80. };
  81. worker.postMessage("hello"); // Start the worker.
  82.  
  83. })();