Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
  • Sign in / Register
Y
ygopro-scripts-888
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 4
    • Merge Requests 4
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Packages
    • Packages
    • List
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issues
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • MyCard
  • ygopro-scripts-888
  • Merge Requests
  • !75

Merged
Opened Nov 17, 2025 by Vury Leo@vuryleo
  • Report abuse
Report abuse

Add CATEGORY_EQUIP to cards that equip itself to other cards

  • Overview 0
  • Commits 4
  • Changes 38

use python script to detect

#!/usr/bin/env python3
import sqlite3
import re
from pathlib import Path

# --- config ---
CDB_PATH = "cards.cdb"
SCRIPT_DIR = Path("script")
WHITELIST_PATH = Path("whitelist.txt")
# ----------------

# any SetCategory(...) that mentions CATEGORY_EQUIP
RE_SETCAT_EQUIP = re.compile(r'SetCategory\s*\([^)]*CATEGORY_EQUIP', re.IGNORECASE)

def load_ids(path: Path):
    """Load whitelist.txt with BOM detection."""
    ids = set()
    if not path.exists():
        return ids

    raw = path.read_bytes()

    if raw.startswith(b'\xff\xfe'):
        text = raw.decode('utf-16le')
    elif raw.startswith(b'\xfe\xff'):
        text = raw.decode('utf-16be')
    elif raw.startswith(b'\xef\xbb\xbf'):
        text = raw.decode('utf-8-sig')
    else:
        text = raw.decode('utf-8', errors="ignore")

    for line in text.splitlines():
        line = line.strip()
        if line and not line.startswith("#"):
            try:
                ids.add(int(line))
            except:
                pass

    return ids


def main():
    whitelist_ids = load_ids(WHITELIST_PATH)

    conn = sqlite3.connect(CDB_PATH)
    cur = conn.cursor()

    # Only cards we care about: whitelist + equip spells + union monsters
    q_marks = ",".join("?" for _ in whitelist_ids) if whitelist_ids else "NULL"
    whitelist_clause = f"d.id IN ({q_marks})" if whitelist_ids else "0"

    cur.execute(f"""
        SELECT d.id, d.type, t.name
        FROM datas d
        LEFT JOIN texts t ON d.id = t.id
        WHERE d.type = 262146       -- equip spell
           OR d.type = 1057         -- union monster
           OR ({whitelist_clause})  -- whitelisted cards
    """, tuple(whitelist_ids))

    rows = cur.fetchall()
    conn.close()

    bucket_whitelist = []
    bucket_equip = []
    bucket_union = []

    for cid, ctype, name in rows:
        lua_path = SCRIPT_DIR / f"c{cid}.lua"
        if not lua_path.exists():
            continue

        content = lua_path.read_text(encoding="utf-8", errors="ignore")

        # GOOD if any of:
        #   - SetCategory(...CATEGORY_EQUIP...)
        #   - aux.EnableUnionAttribute
        #   - aux.AddEquipSpellEffect
        if RE_SETCAT_EQUIP.search(content):
            continue
        if "aux.EnableUnionAttribute" in content:
            continue
        if "aux.AddEquipSpellEffect" in content:
            continue

        # From here, this card is "missing"
        name = name or ""

        if cid in whitelist_ids:
            bucket_whitelist.append((cid, name))

        if ctype == 262146:
            bucket_equip.append((cid, name))

        if ctype == 1057:
            bucket_union.append((cid, name))

    bucket_whitelist.sort()
    bucket_equip.sort()
    bucket_union.sort()

    print("=== WHITELIST (missing equip handling) ===")
    for cid, name in bucket_whitelist:
        print(f"{cid}\t{name}")

    print("\n=== EQUIP SPELL (missing equip handling) ===")
    for cid, name in bucket_equip:
        print(f"{cid}\t{name}")

    print("\n=== UNION MONSTER (missing equip handling) ===")
    for cid, name in bucket_union:
        print(f"{cid}\t{name}")


if __name__ == "__main__":
    main()

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b "add-new-equip" "origin/add-new-equip"

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout "origin/master"
git merge --no-ff "add-new-equip"

Step 4. Push the result of the merge to GitLab

git push origin "master"

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: mycard/ygopro-scripts-888!75

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.