小丑牌 Balatro 卡牌定位工具

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

目前為 2025-01-29 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         小丑牌 Balatro 卡牌定位工具
// @namespace    balatro-soul-util
// @version      0.0.3
// @description  The Soul 的搜索增强版,帮助快速定位目标牌和位置。内置 蓝图、头脑、可乐的搜索,其他自行调用函数找到 `window.findCardInAnte(底注, 英文牌名)`
// @author       liam61
// @match        mathisfun0.github.io/The-Soul/
// @license MIT

// ==/UserScript==

(function (global) {
  const findCardInAnte = (ante, targets, orderType = 'card') => {
    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}   \tindex: ${realIndex}, round: ${Math.ceil(realIndex / 3)}, order: ${
          order != 0 ? order : 3
        }`;
      });

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

    const targetLists = (Array.isArray(targets) ? targets : [targets]).map((target) => findIndexOfCard(ante, target));

    if (orderType === 'card') {
      targetLists.sort((list1, list2) => list1[0]?.index - list2[0]?.index).forEach(print);
    } else if (orderType === 'order') {
      const orderedList = targetLists
        .reduce((arr, item) => {
          arr.push(...item);
          return arr;
        }, [])
        .sort((item1, item2) => item1.index - item2.index);

      print(orderedList);
    }
  };

  global.findCardInAnte = findCardInAnte;
  global.findPresetCard = () => {
    return Array.from({ length: 40 }, (_, i) => i + 1).map((ante) =>
      findCardInAnte(
        ante,
        ['Blueprint', 'Brainstorm', 'Diet Cola', 'Showman', 'The Idol', 'Sock and'],
        'order'
      )
    );
  };

  global.findPresetCard();
})(window);