Critter Auto Script

Basic Script to Automate Critter Mound

目前為 2020-03-17 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Critter Auto Script
// @namespace    http://tampermonkey.net/
// @version      0.9.2
// @description  Basic Script to Automate Critter Mound
// @author       You
// @match        https://crittermound.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var first, mother, father;

    var main = function() {
        if (game.femaleMound().length > 0) {
            first = game.femaleMound()[0];
            mother = game.mother();
            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) {
                game.Move("Mate", "Female", game, game)
                console.log("New Queen");
            } else {
                if (Math.random() >= 0.5) {
                    if (game.maxArmyMoundSize() > game.armyMound().length) {
                        game.Move("Army", "Female", game, game)
                        console.log("New Female Army");
                    } else {
                        console.log("To many Army")
                    }
                } else {
                    game.Move("Worker", "Female", game, game)
                    console.log("New Female Worker");
                }
            }
        }

        if (game.maleMound().length > 0) {
            first = game.maleMound()[0];
            mother = game.father();
            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) {
                game.Move("Mate", "Male", game, game);
                console.log("New King");
            } else {
                if (Math.random() >= 0.5) {
                    if (game.maxArmyMoundSize() > game.armyMound().length) {
                        game.Move("Army", "Male", game, game)
                        console.log("New Male Army");
                    } else {
                        console.log("To many Army")
                    }
                } else {
                    game.Move("Worker", "Male", game, game)
                    console.log("New Male Worker");
                }
            }
        }
    };

    function workerCode() {
        this.onmessage = function (event) {
        }

        var time = 500;
        setTimeout(function () { Tick() }, time);

        function Tick() {
            postMessage("Tick");
            setTimeout(function () { Tick() }, time);
        }
    }

    var blob = new Blob([
        "(" + workerCode.toString() + ")()"
    ], {type: "text/javascript"});

    // Note: window.webkitURL.createObjectURL() in Chrome 10+.
    var worker = new Worker(window.URL.createObjectURL(blob));
    worker.onmessage = function (e) {
        main();
    };
    worker.postMessage("hello"); // Start the worker.

})();