adminoo

testadmin

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/540905/1614877/adminoo.js

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

Tabs.AutoRoyalConquestTab = {
    tabOrder: 8002,
    tabLabel: 'Auto Royal Conquest',
    tabColor: 'green',
    myDiv: null,
    isInitialized: false,
    autoAttackInterval: null,
    troopTypes: [
        { name: "Supply Troop", id: "supplyTroop" },
        { name: "Militiaman", id: "militiaman" },
        { name: "Scout", id: "scout" },
        { name: "Pikeman", id: "pikeman" },
        { name: "Swordsman", id: "swordsman" },
        { name: "Archer", id: "archer" },
        { name: "Supply Wagon", id: "supplyWagon" },
        { name: "Ballista", id: "ballista" },
        { name: "Battering Ram", id: "batteringRam" },
        { name: "Catapult", id: "catapult" },
        { name: "Heavy Cavalry", id: "heavyCavalry" }
    ],

    init: function(div) {
        var t = this;
        t.myDiv = div;
        t.myDiv.style.display = 'none';
        t.isInitialized = true;
        t.updateStatus('Ready to automate Royal Conquest');
    },

    paint: function() {
        var t = this;
        if (!t.isInitialized) {
            t.updateStatus('Please initialize first');
            return;
        }

        var troopInputs = t.troopTypes.map(function(troop) {
            return `
                <div class="inputGroup">
                    <label for="troop_${troop.id}">${troop.name}:</label>
                    <input type="number" id="troop_${troop.id}" class="btInput troopInputBox" value="0" min="0" />
                </div>
            `;
        }).join('');

        var m = `
            <div class="divHeader" align="center">Auto Royal Conquest</div>
            <div class="monitorContainer">
                <div style="display: flex; flex-wrap: wrap; gap: 10px;">
                    ${troopInputs}
                </div>
                <div class="inputGroup" style="margin-top: 15px;">
                    <button id="startAutoAttack" class="buttonv2 std green">Start Auto</button>
                    <button id="stopAutoAttack" class="buttonv2 std red">Stop</button>
                </div>
                <div id="autoConquestStatus" class="statusMessage"></div>
            </div>
        `;

        t.myDiv.innerHTML = m;

        $("#startAutoAttack", t.myDiv).click(function() {
            t.startAutoAttack();
        });
        $("#stopAutoAttack", t.myDiv).click(function() {
            t.stopAutoAttack();
        });
    },

    show: function() {
        var t = this;
        t.myDiv.style.display = 'block';
        t.paint();
        t.updateStatus('Ready to automate Royal Conquest');
    },

    hide: function() {
        var t = this;
        t.myDiv.style.display = 'none';
        t.stopAutoAttack();
        t.updateStatus('');
    },

    updateStatus: function(message) {
        var t = this;
        var statusEl = $("#autoConquestStatus", t.myDiv);
        statusEl.html(message);
        statusEl.css({
            'color': message.includes('Error') ? '#dc3545' : '#28a745',
            'background-color': message.includes('Error') ? '#f8d7da' : '#d4edda'
        });
    },

    startAutoAttack: function() {
        var t = this;
        if (t.autoAttackInterval) {
            t.updateStatus('Auto attack is already running');
            return;
        }
        t.updateStatus('Auto attack started');
        t.autoAttackInterval = setInterval(function() {
            try {
                t.performAttack();
            } catch (e) {
                t.updateStatus('Error: ' + e.message);
            }
        }, 5000); // Attack every 5 seconds (adjust as needed)
    },

    stopAutoAttack: function() {
        var t = this;
        if (t.autoAttackInterval) {
            clearInterval(t.autoAttackInterval);
            t.autoAttackInterval = null;
            t.updateStatus('Auto attack stopped');
        }
    },

    performAttack: function() {
        var t = this;
        // Gather troop values from the UI
        var troopValues = t.troopTypes.map(function(troop) {
            var val = parseInt($("#troop_" + troop.id, t.myDiv).val(), 10);
            return isNaN(val) ? 0 : val;
        });

        // Set values in the game's troop input fields
        // Assumes the order of .btInput fields in the DOM matches troopTypes
        var gameInputs = $(".btInput").filter(function() {
            // Only select visible troop input boxes in the Royal Conquest UI
            return $(this).is(":visible") && $(this).closest('.monitorContainer').length === 0;
        });

        troopValues.forEach(function(val, idx) {
            if (gameInputs[idx]) {
                $(gameInputs[idx]).val(val);
            }
        });

        // Click the attack button
        var attackBtn = $("button:contains('Attack')");
        if (attackBtn.length) {
            attackBtn[0].click();
            t.updateStatus('Attack sent with selected troops');
        } else {
            t.updateStatus('Error: Attack button not found');
        }
    }
};