小丑牌 Balatro 卡牌定位工具

The Soul 的搜索增强版,帮助快速定位目标牌和位置。内置 蓝图、头脑、可乐的搜索,其他自行调用函数找到 `window.findCardInAnte(底注, 英文牌名)`

当前为 2025-01-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         小丑牌 Balatro 卡牌定位工具
// @namespace    balatro-soul-util
// @version      0.0.1
// @description  The Soul 的搜索增强版,帮助快速定位目标牌和位置。内置 蓝图、头脑、可乐的搜索,其他自行调用函数找到 `window.findCardInAnte(底注, 英文牌名)`
// @author       liam61
// @match        mathisfun0.github.io/The-Soul/
// @license MIT
 
// ==/UserScript==
const findCardInAnte = (ante, targets) => {
    const findIndexOfCard = (ante, target) => {
        const anteEl = document.querySelector('#scrollingContainer').children[ante - 1]
        if (!anteEl) return []
        
        const cardListEl = anteEl.querySelector('.scrollable')

        const arr = [...cardListEl.children].reduce( (arr, card, index) => {
            const el = card.querySelector('div')

            if (el.textContent.includes(target)) {
                arr.push({ card: target, index })
            }
            return arr
        }, [])

        return arr
    }

    const print = (targetCardList) => {
        const msgArr = targetCardList.map(({ card, index }) => {
            const realIndex = index + 1
            const order = realIndex % 3
                
            return `[ante ${ante}] ${card} index: ${realIndex}, round: ${Math.ceil(realIndex / 3)}, order: ${order != 0 ? order : 3}`
        })

        if (targetCardList.length) {
            console.log(msgArr.join('\n'))
            console.log('\n')
        }
    }

    (Array.isArray(targets) ? targets : [targets])
        .map((target) => findIndexOfCard(ante, target))
        .sort((list1, list2) => list1[0]?.index - list2[0]?.index)
        .forEach(print)
}

window.findCardInAnte = findCardInAnte

Array.from({ length: 21 }, (_, i) => i + 1).map((ante) => findCardInAnte(ante, ['Blueprint', 'Brainstorm', 'Diet Cola']))