IdlePixel Slap Chop Select Monster Addon

Slap Chop select monster addon

目前為 2024-07-05 提交的版本,檢視 最新版本

// ==UserScript==
// @name         IdlePixel Slap Chop Select Monster Addon
// @version      1.0.0
// @description  Slap Chop select monster addon
// @author       Dounford
// @license      MIT
// @match        *://idle-pixel.com/login/play*
// @grant        none
// @require      https://gf.qytechs.cn/scripts/441206-idlepixel/code/IdlePixel+.js
// @namespace https://gf.qytechs.cn/users/1175326
// ==/UserScript==

(function() {
    'use strict';
	
	const rareEnemies = {field:['chicken','rat','spider','bee','lizard'],forest:['snake','ants','wolf','thief','forest_ent'],cave:['bear','goblin','bat','skeleton'],volcano:['fire_hawk','fire_snake','fire_golem','fire_witch']}
	const superRareEnemies = {northern_field:['ice_hawk','ice_golem','ice_witch','yeti'],mansion:['ghost','grandma','exorcist','reaper'],beach:['shark','sea_soldier','puffer_fish','saltwater_crocodile']}

    class SelectMonsterPlugin extends IdlePixelPlusPlugin {
        constructor() {
            super("selectMonster", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                },
            });
        }

        onLogin() {
            IdlePixelPlus.plugins.selectMonster.tryInit();
        }
		
		toTitleCase(str) {
		  return str
			.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
			.map(x => x.slice(0, 1).toUpperCase() + x.slice(1))
			.join(' ');
		}

		init() {
			let rareDiv = document.querySelector('#modal-rare-monster-potion div div .modal-body center');
			let superRareDiv = document.querySelector('#modal-super-rare-monster-potion div div .modal-body center');
			rareDiv.innerHTML = '';
			superRareDiv.innerHTML = '';

			for (let area in rareEnemies) {
				rareEnemies[area].forEach((enemy) => {
					let enemyDiv = document.createElement('div');
					enemyDiv.setAttribute('onclick',`IdlePixelPlus.plugins.selectMonster.selectFight('${area}','${enemy}');Modals.toggle("modal-rare-monster-potion");`);
					enemyDiv.className = 'fight-area-select-monster-card hover';
					enemyDiv.style = 'height: auto;width: 25%';
					enemyDiv.innerHTML = `${this.toTitleCase(enemy)}
						<div class="center">
							<img class="w100" src="https://cdn.idle-pixel.com/images/${enemy}_icon.png">
						</div>`
					rareDiv.insertAdjacentElement('beforeend',enemyDiv)
				})
			}

			for (let area in superRareEnemies) {
				superRareEnemies[area].forEach((enemy) => {
					let enemyDiv = document.createElement('div');
					enemyDiv.setAttribute('onclick',`IdlePixelPlus.plugins.selectMonster.selectFight('${area}','${enemy}');Modals.toggle("modal-super-rare-monster-potion");`);
					enemyDiv.className = 'fight-area-select-monster-card hover';
					enemyDiv.style = 'height: auto;width: auto';
					enemyDiv.innerHTML = `${IdlePixelPlus.plugins.selectMonster.toTitleCase(enemy)}
						<div class="center">
							<img class="w100" src="https://cdn.idle-pixel.com/images/${enemy}_icon.png">
						</div>`
					superRareDiv.insertAdjacentElement('beforeend',enemyDiv)
				})
			}
			
			Object.values(IdlePixelPlus.info.combatZones).forEach((zone) => {
				document.querySelector(`#slapchop-quickfight-${zone.id} button`).setAttribute('onclick',`Globals.last_area_fight='${zone.id}';IdlePixelPlus.plugins.selectMonster.quickWithSelect('${zone.id}')`)
			})
			console.log('Slap Chop Addon initiated')
		}

		tryInit() {
			if (document.getElementById('slapchop-quickfight')) {
				IdlePixelPlus.plugins.selectMonster.init();
			} else {
				setTimeout(function(){IdlePixelPlus.plugins.selectMonster.tryInit()},5000)
				console.log('Slap Chop not found')
			}
		}
		
		quickWithSelect(zoneId) {
			if ((IdlePixelPlus.info.combatZones[zoneId].commonMonsters.includes(Globals.last_area_fight_select_monster) || IdlePixelPlus.info.combatZones[zoneId].rareMonsters.includes(Globals.last_area_fight_select_monster)) && (var_rare_monster_potion_timer > 0 || (typeof var_super_rare_monster_potion_timer !== 'undefined' && var_super_rare_monster_potion_timer > 0))) {
				websocket.send('SELECT_MONSTER_FIGHT=' + zoneId + "~" + Globals.last_area_fight_select_monster)
			} else {
				sCCombat().quickFight(zoneId)
			}
		}

		selectFight(area,enemy) {
			if(area == "field" || area == "forest" || area == "cave" || area == "volcano" || area == "blood_field" || area == "blood_forest" || area == "blood_cave" || area == "blood_volcano") {
				if(Items.getItem("rare_monster_potion_timer") == 0 && Items.getItem("rare_monster_potion") > 0) {
					Globals.last_area_fight_select_monster = enemy;
					websocket.send('SELECT_MONSTER_FIGHT_AND_DRINK=' + area + "~" + enemy);
					return;
				}
			}
			if(area == "northern_field" || area == "mansion" || area == "beach") {
				if(Items.getItem("super_rare_monster_potion_timer") == 0 && Items.getItem("super_rare_monster_potion") > 0) {
					Globals.last_area_fight_select_monster = enemy;
					websocket.send('SELECT_MONSTER_FIGHT_AND_DRINK=' + area + "~" + enemy);
					return;
				}
			}
			Globals.last_area_fight_select_monster = enemy;
			websocket.send('SELECT_MONSTER_FIGHT=' + area + "~" + enemy);
		}
    }

    const plugin = new SelectMonsterPlugin();
    IdlePixelPlus.registerPlugin(plugin);

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址