// ==UserScript== // @name 超级挑战 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 图鉴数≥1115解锁,挑战强力Boss,击败后固定掉落麻辣鸭腿。修复奖励不发放问题,商店购买增加中文提示。 // @author 人民当家做主 // @match https://play-pokechill.github.io/* // @match https://g1tyx.github.io/play-pokechill/* // @icon https://play-pokechill.github.io/img/icons/icon.png // @grant none // ==/UserScript== (function() { 'use strict'; const REQUIRED_DEX = 1115; const ENTRY_COST = 0; const SPICY_LEG = 'spicyDuckLeg'; const SPICY_LEG_IMAGE_URL = 'https://picui.ogmua.cn/s1/2026/03/10/69b009718818c.webp'; if (typeof afkSeconds === 'undefined') var afkSeconds = 0; // Boss列表(只需ID和价格,技能自动生成) const BOSS_CONFIG = [ { id: 'arceus', price: 9999, stars: 10 }, { id: 'burmySandy', price: 5, stars: 2 }, { id: 'burmyTrash', price: 5, stars: 2 }, { id: 'galarianMrmime', price: 20, stars: 4 }, { id: 'kyuremWhite', price: 90, stars: 9 }, { id: 'megaAbsol', price: 70, stars: 7 }, { id: 'megaAltaria', price: 65, stars: 7 }, { id: 'megaAmpharos', price: 60, stars: 6 }, { id: 'megaAudino', price: 50, stars: 6 }, { id: 'megaBanette', price: 55, stars: 6 }, { id: 'megaGardevoir', price: 75, stars: 8 }, { id: 'megaHoundoom', price: 60, stars: 6 }, { id: 'megaKangaskhan', price: 70, stars: 7 }, { id: 'megaLopunny', price: 65, stars: 7 }, { id: 'megaMedicham', price: 55, stars: 6 }, { id: 'megaRayquaza', price: 99, stars: 10 }, { id: 'megaSableye', price: 50, stars: 5 }, { id: 'megaSalamence', price: 80, stars: 8 }, { id: 'megaSharpedo', price: 55, stars: 6 }, { id: 'megaSlowbro', price: 65, stars: 7 } ]; // 价格映射表 const priceMap = {}; // ========== 确保麻辣鸭腿永久存在 ========== function ensureSpicyLeg() { if (!item[SPICY_LEG]) { item[SPICY_LEG] = { id: SPICY_LEG, name: '麻辣鸭腿', rename: '麻辣鸭腿', type: 'key', got: 0, info: function() { return '超级挑战中掉落的稀有物品,可用于兑换强力宝可梦。'; } }; } if (item[SPICY_LEG].got === undefined) item[SPICY_LEG].got = 0; } // ========== 劫持 loadGame,确保物品每次加载后都存在 ========== const originalLoadGame = window.loadGame; window.loadGame = function() { const result = originalLoadGame ? originalLoadGame() : undefined; ensureSpicyLeg(); return result; }; // ========== 重写 setWildPkmn 以强制退出战斗并发放奖励 ========== const originalSetWildPkmn = window.setWildPkmn; window.setWildPkmn = function() { if (saved.currentArea && saved.currentArea.startsWith('superChallenge_')) { const area = areas[saved.currentArea]; if (area && area.trainer) { let maxTrainerSlot = 1; if (area.team && area.team.slot2) maxTrainerSlot = 2; if (area.team && area.team.slot3) maxTrainerSlot = 3; if (typeof currentTrainerSlot !== 'undefined' && currentTrainerSlot > maxTrainerSlot) { console.log('[超级挑战] 训练家胜利,发放奖励'); if (area.itemReward) { const rewards = area.itemReward; for (const key in rewards) { const reward = rewards[key]; const rewardId = reward.item; const amount = reward.amount || 1; if (item[rewardId] !== undefined) { for (let i = 0; i < amount; i++) { item[rewardId].got++; item[rewardId].newItem++; } } if (pkmn[rewardId] !== undefined) { pkmn[rewardId].newPokemon = true; } } } area.defeated = true; if (typeof leaveCombat === 'function') leaveCombat(); wildPkmnHp = wildPkmnHpMax; return; } } } if (originalSetWildPkmn) originalSetWildPkmn(); }; // ========== 等待游戏加载 ========== function waitForGame() { if (typeof areas !== 'undefined' && typeof item !== 'undefined' && typeof pkmn !== 'undefined' && typeof givePkmn !== 'undefined' && typeof saveGame !== 'undefined' && typeof updatePreviewTeam !== 'undefined') { init(); } else { setTimeout(waitForGame, 100); } } function init() { ensureSpicyLeg(); defineChallengeAreas(); addMainCardToExploreMenu(); addShopItems(); observeMenu(); injectCustomStyles(); hookItemShopImages(); startHealthCheck(); setInterval(updateCardLock, 5000); console.log('[超级挑战] 已启动,奖励修复版 + 商店中文提示'); } // ========== 生成有效技能 ========== function generateValidMoves(pokemonId) { const boss = pkmn[pokemonId]; if (!boss) { console.warn(`[超级挑战] Boss ${pokemonId} 不存在,使用默认技能`); return ['tackle']; } const types = Array.isArray(boss.type) ? boss.type : []; const moves = []; const used = new Set(); if (boss.signature && boss.signature.id && move[boss.signature.id]) { moves.push(boss.signature.id); used.add(boss.signature.id); } const candidates = []; for (let moveId in move) { if (used.has(moveId)) continue; const m = move[moveId]; if (!m) continue; const power = m.power; if (power === undefined || power <= 0) continue; const moveset = Array.isArray(m.moveset) ? m.moveset : []; const canLearn = moveset.includes('all') || types.some(t => moveset.includes(t)); if (!canLearn) continue; candidates.push({ id: moveId, power: power }); } candidates.sort((a, b) => b.power - a.power); for (let cand of candidates) { if (moves.length >= 4) break; if (!used.has(cand.id)) { moves.push(cand.id); used.add(cand.id); } } const defaultMoves = ['hyperBeam', 'earthquake', 'fireBlast', 'thunderbolt']; for (let d of defaultMoves) { if (moves.length >= 4) break; if (!used.has(d) && move[d]) { moves.push(d); used.add(d); } } while (moves.length < 4) moves.push('tackle'); return moves; } // ========== 创建挑战区域 ========== function defineChallengeAreas() { // 球果池(基于游戏内已有物品) const APRICORN_COMMON = ['yellowApricorn', 'pinkApricorn', 'greenApricorn']; // 普通球果 const APRICORN_RARE = ['whiteApricorn']; // 稀有球果 const APRICORN_VERY_RARE = ['blackApricorn']; // 非常稀有球果 BOSS_CONFIG.forEach(({ id, stars }) => { const areaId = `superChallenge_${id}`; // 基础奖励:麻辣鸭腿 const itemReward = { 1: { item: SPICY_LEG, amount: 1 } }; let rewardIndex = 2; // 奖励序号从2开始 // 根据星级决定球果奖励 if (stars >= 1 && stars <= 3) { // 1-3星:1个普通球果 const berry = APRICORN_COMMON[Math.floor(Math.random() * APRICORN_COMMON.length)]; itemReward[rewardIndex++] = { item: berry, amount: 1 }; } else if (stars >= 4 && stars <= 6) { // 4-6星:2个普通球果 for (let i = 0; i < 2; i++) { const berry = APRICORN_COMMON[Math.floor(Math.random() * APRICORN_COMMON.length)]; itemReward[rewardIndex++] = { item: berry, amount: 1 }; } } else if (stars >= 7 && stars <= 9) { // 7-9星:2个普通球果 + 1个稀有球果 for (let i = 0; i < 2; i++) { const berry = APRICORN_COMMON[Math.floor(Math.random() * APRICORN_COMMON.length)]; itemReward[rewardIndex++] = { item: berry, amount: 1 }; } const rareBerry = APRICORN_RARE[Math.floor(Math.random() * APRICORN_RARE.length)]; itemReward[rewardIndex++] = { item: rareBerry, amount: 1 }; } else if (stars === 10) { // 10星:2个普通球果 + 1个稀有球果 + 1个非常稀有球果 for (let i = 0; i < 2; i++) { const berry = APRICORN_COMMON[Math.floor(Math.random() * APRICORN_COMMON.length)]; itemReward[rewardIndex++] = { item: berry, amount: 1 }; } const rareBerry = APRICORN_RARE[Math.floor(Math.random() * APRICORN_RARE.length)]; itemReward[rewardIndex++] = { item: rareBerry, amount: 1 }; const veryRareBerry = APRICORN_VERY_RARE[Math.floor(Math.random() * APRICORN_VERY_RARE.length)]; itemReward[rewardIndex++] = { item: veryRareBerry, amount: 1 }; } // 额外金色瓶盖奖励(保持原设计) if (stars >= 7 && stars <= 9) { itemReward[rewardIndex++] = { item: 'goldenBottleCap', amount: 1 }; } else if (stars === 10) { itemReward[rewardIndex++] = { item: 'goldenBottleCap', amount: 2 }; } // 创建挑战区域 areas[areaId] = { id: areaId, name: `超级挑战·${format(id)}`, type: 'event', trainer: true, encounter: true, level: 100, difficulty: 2000, hpPercentage: 100, icon: pkmn[id], background: 'space', unlockRequirement: function() { return item.whiteApricorn && item.whiteApricorn.got >= ENTRY_COST; }, unlockDescription: `需要 ${ENTRY_COST} 个白色球果`, encounterEffect: function() { if (item.whiteApricorn) item.whiteApricorn.got -= ENTRY_COST; }, team: { slot1: pkmn[id] }, fieldEffect: [], timed: false, ticketIndex: 0, defeated: false, itemReward: itemReward, drops: { common: [] }, spawns: { common: [] }, reward: [] }; }); } // ========== 卡片添加到旅行菜单 ========== function addMainCardToExploreMenu() { const exploreMenu = document.getElementById('explore-menu'); if (!exploreMenu) return; const old = document.getElementById('superChallengeMainCard'); if (old) old.remove(); const card = document.createElement('div'); card.id = 'superChallengeMainCard'; card.className = 'explore-ticket'; card.style.marginBottom = '10px'; card.style.cursor = 'pointer'; card.innerHTML = `
超级挑战
`; exploreMenu.appendChild(card); card.addEventListener('click', openChallengeMenu); updateCardLock(); } function updateCardLock() { const card = document.getElementById('superChallengeMainCard'); if (!card) return; const reqSpan = card.querySelector('#dexRequirement'); if (!reqSpan) return; const dexCount = getDexCount(); if (dexCount >= REQUIRED_DEX) { card.style.filter = 'brightness(1)'; card.style.pointerEvents = 'auto'; reqSpan.innerHTML = `已解锁 (${dexCount}/${REQUIRED_DEX})`; } else { card.style.filter = 'brightness(0.5) grayscale(80%)'; card.style.pointerEvents = 'none'; reqSpan.innerHTML = `需要图鉴数 ${REQUIRED_DEX} (当前 ${dexCount})`; } } function getDexCount() { return Object.values(pkmn).filter(p => p && p.caught > 0).length; } // ========== 打开挑战菜单 ========== let currentOverlay = null; function openChallengeMenu() { if (getDexCount() < REQUIRED_DEX) return; if (currentOverlay) closeChallengeMenu(); const overlay = document.createElement('div'); overlay.className = 'super-challenge-overlay'; overlay.id = 'superChallengeOverlay'; overlay.addEventListener('click', e => { if (e.target === overlay) closeChallengeMenu(); }); const container = document.createElement('div'); container.className = 'super-challenge-container'; container.innerHTML = `
🔥超级挑战🔥
`; overlay.appendChild(container); document.body.appendChild(overlay); currentOverlay = overlay; document.getElementById('superChallengeCloseBtn').addEventListener('click', closeChallengeMenu); const listDiv = document.getElementById('superChallengeList'); const sortedBosses = [...BOSS_CONFIG].sort((a, b) => (a.stars || 5) - (b.stars || 5)); sortedBosses.forEach(({ id, stars }) => { const boss = pkmn[id]; if (!boss) return; const starCount = stars || 5; const starString = '★'.repeat(starCount) + '☆'.repeat(10 - starCount); const card = document.createElement('div'); card.className = 'super-challenge-card'; card.setAttribute('data-boss', id); card.innerHTML = `
${format(id)}
等级100 · 难度 ${starString}
${starString}
`; card.addEventListener('click', e => { e.stopPropagation(); startChallenge(id); closeChallengeMenu(); }); listDiv.appendChild(card); }); replaceSpicyLegImages(); } function closeChallengeMenu() { if (currentOverlay) { currentOverlay.remove(); currentOverlay = null; } } // ========== 开始挑战 ========== function startChallenge(bossId) { const areaId = `superChallenge_${bossId}`; if (!areas[areaId]) return; const moves = generateValidMoves(bossId); areas[areaId].team.slot1Moves = moves; saved.currentAreaBuffer = areaId; const previewExit = document.getElementById('preview-team-exit'); const teamMenu = document.getElementById('team-menu'); const menuButton = document.getElementById('menu-button-parent'); const exploreMenu = document.getElementById('explore-menu'); if (previewExit && teamMenu && menuButton && exploreMenu) { previewExit.style.display = 'flex'; teamMenu.style.zIndex = '50'; teamMenu.style.display = 'flex'; menuButton.style.display = 'none'; exploreMenu.style.display = 'none'; } afkSeconds = 0; if (typeof updatePreviewTeam === 'function') updatePreviewTeam(); } // ========== 商店兑换(添加条目并建立价格映射) ========== function addShopItems() { if (typeof shop === 'undefined') { setTimeout(addShopItems, 200); return; } BOSS_CONFIG.forEach(({ id, price }) => { const shopId = `shop_super_${id}`; if (shop[shopId]) return; shop[shopId] = { pkmn: id, price: price, currency: SPICY_LEG, category: 'pokemon', effect: function() { // 此 effect 会被原游戏调用,但我们用自定义点击替代,所以这里可以留空或简单处理 // 实际购买逻辑已在自定义事件中完成 } }; priceMap[id] = price; }); if (typeof updateItemShop === 'function') updateItemShop(); } // ========== 获取宝可梦中文名 ========== function getChineseName(id) { if (!window.format) return id; const displayName = window.format(id); if (window.EN_CN_DICT && window.EN_CN_DICT[displayName]) { return window.EN_CN_DICT[displayName]; } return displayName; // 后备 } // ========== 自定义商店点击处理(捕获阶段) ========== const customClickHandler = function(event) { const div = event.currentTarget; const id = div.dataset.pkmn; if (!id || priceMap[id] === undefined) return; // 阻止原游戏事件 event.stopPropagation(); event.preventDefault(); const price = priceMap[id]; if (item[SPICY_LEG].got < price) { alert('麻辣鸭腿不足!'); return; } item[SPICY_LEG].got -= price; givePkmn(pkmn[id], 1); saveGame(); updateItemShop(); // 刷新商店,会重新生成条目 const chineseName = getChineseName(id); alert('获得 ' + chineseName); }; // ========== 绑定自定义事件到商店中的宝可梦条目 ========== function bindShopEvents() { const shopListing = document.getElementById('shop-listing'); if (!shopListing) return; document.querySelectorAll('#shop-listing > div[data-pkmn]').forEach(div => { const id = div.dataset.pkmn; if (priceMap[id] !== undefined) { // 使用捕获阶段确保先于原游戏事件执行 div.addEventListener('click', customClickHandler, { capture: true }); } }); } // ========== 血量监测,强制退出 ========== let battleEnded = false; function startHealthCheck() { setInterval(() => { if (!saved.currentArea || !saved.currentArea.startsWith('superChallenge_')) { battleEnded = false; return; } if (battleEnded) return; let hp = window.wildPkmnHp; if (hp === undefined && window.wildPkmn && window.wildPkmn.hp !== undefined) { hp = window.wildPkmn.hp; } if (hp !== undefined && hp <= 0) { battleEnded = true; console.log('[超级挑战] 血量归零,尝试退出'); if (typeof updateWildPkmn === 'function') updateWildPkmn(); setTimeout(() => { const leaveBtn = document.getElementById('explore-leave'); if (leaveBtn) leaveBtn.click(); else if (typeof leaveCombat === 'function') leaveCombat(); }, 500); } }, 500); } // ========== 图片替换 & 事件绑定 ========== function hookItemShopImages() { const originalUpdateItemShop = window.updateItemShop; if (typeof originalUpdateItemShop === 'function') { window.updateItemShop = function() { originalUpdateItemShop(); setTimeout(() => { replaceSpicyLegImages(); bindShopEvents(); // 每次刷新商店后重新绑定 }, 50); }; } setInterval(replaceSpicyLegImages, 2000); } function replaceSpicyLegImages() { document.querySelectorAll(`img[src*="${SPICY_LEG}.png"], .spicy-leg-icon`).forEach(img => { if (img.src !== SPICY_LEG_IMAGE_URL) img.src = SPICY_LEG_IMAGE_URL; img.style.width = '32px'; img.style.height = '32px'; img.classList.add('spicy-leg-icon'); }); } // ========== 确保卡片存在 ========== function observeMenu() { const observer = new MutationObserver(() => { const exploreMenu = document.getElementById('explore-menu'); if (exploreMenu && !document.getElementById('superChallengeMainCard')) { addMainCardToExploreMenu(); } }); observer.observe(document.body, { childList: true, subtree: true }); } // ========== 样式注入 ========== function injectCustomStyles() { const style = document.createElement('style'); style.textContent = ` .super-challenge-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 10000; display: flex; justify-content: center; align-items: center; animation: tooltipBoxAppear 0.2s ease; } .super-challenge-container { width: 650px; max-width: 90vw; max-height: 80vh; background: var(--dark1); border: 2px solid var(--light2); border-radius: 12px; box-shadow: 0 0 30px rgba(255, 69, 0, 0.6); display: flex; flex-direction: column; overflow: hidden; animation: tooltipBoxAppear 0.2s ease; color: var(--light2); font-family: 'Winky Sans', sans-serif; } .super-challenge-header { background: var(--dark2); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--light1); } .super-challenge-header span:first-child { font-size: 1.8rem; font-weight: bold; color: #ff9966; text-shadow: 2px 2px 0 #aa3300; } .super-challenge-close { font-size: 2rem; cursor: pointer; color: var(--light1); transition: 0.1s; line-height: 1; } .super-challenge-close:hover { color: #ff8888; transform: scale(1.1); } .super-challenge-list { padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: var(--dark1); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='white' fill-opacity='0.03'%3E%3Cpolygon fill-rule='evenodd' points='8 4 12 6 8 8 6 12 4 8 0 6 4 4 6 0 8 4'/%3E%3C/g%3E%3C/svg%3E"); } .super-challenge-card { background: rgba(0, 0, 0, 0.45); border: 1px solid var(--light1); border-radius: 10px; padding: 12px 15px; display: flex; align-items: center; gap: 15px; cursor: pointer; transition: 0.1s; color: white; backdrop-filter: blur(2px); } .super-challenge-card:hover { filter: brightness(1.2); border-color: #ffaa66; transform: translateY(-2px); box-shadow: 0 5px 10px rgba(0,0,0,0.5); } .super-challenge-card:active { transform: scale(0.98); } .super-challenge-card img { width: 64px; height: 64px; image-rendering: pixelated; background: rgba(0,0,0,0.2); border-radius: 8px; } .super-challenge-card-info { flex: 1; } .super-challenge-card-name { font-size: 1.3rem; font-weight: 200; margin-bottom: 4px; } .super-challenge-card-desc { font-size: 0.9rem; opacity: 0.7; } .super-challenge-card-stars { background: var(--dark2); padding: 5px 12px; border-radius: 20px; color: #ffd966; border: 1px solid #ffaa33; display: flex; align-items: center; gap: 4px; font-size: 1rem; white-space: nowrap; } .super-challenge-card-stars img { width: 32px !important; height: 32px !important; margin-right: 2px; vertical-align: middle; } #superChallengeMainCard .explore-ticket-left span:first-child { font-size: 1.5rem !important; } #superChallengeMainCard .explore-ticket-left span strong { font-size: 1.2rem !important; padding: 4px 10px !important; } `; document.head.appendChild(style); } const originalLeaveCombat = window.leaveCombat; window.leaveCombat = function() { if (saved.currentArea && saved.currentArea.startsWith('superChallenge_')) { wildPkmnHp = wildPkmnHpMax; // 立即重置Boss血量 } if (originalLeaveCombat) originalLeaveCombat(); }; waitForGame(); })();