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
  • !74

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

Remove CATEGORY_EQUIP from cards that equip other cards

  • Overview 0
  • Commits 19
  • Changes 186

You can find whitelist on document

$ python detect.py > remove.txt
$ python remove.py

python scripts

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

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

# load whitelist IDs
whitelist = set()
whitelist_file = Path(WHITELIST_PATH)
if whitelist_file.exists():
    for line in whitelist_file.read_text(encoding="utf-8").splitlines():
        line = line.strip()
        if line and not line.startswith("#"):
            try:
                whitelist.add(int(line))
            except ValueError:
                pass

# connect to sqlite
conn = sqlite3.connect(CDB_PATH)
cur = conn.cursor()

# fetch id + name (type check here)
# 262146 -> equip spell
# 1057 -> union monster
cur.execute("""
    SELECT d.id, d.type, t.name
    FROM datas d
    LEFT JOIN texts t ON d.id = t.id
    WHERE d.type != 262146
      AND d.type != 1057
""")
rows = cur.fetchall()
conn.close()

results = []

for cid, ctype, name in rows:
    if cid in whitelist:
        continue

    lua_path = SCRIPT_DIR / f"c{cid}.lua"
    if not lua_path.exists():
        continue

    try:
        content = lua_path.read_text(encoding="utf-8", errors="ignore")
    except:
        continue

    if "CATEGORY_EQUIP" in content:
        results.append((cid, name or ""))

# sort by card ID
results.sort(key=lambda x: x[0])

# # print in Excel-friendly format (;-separated)
# for cid, name in results:
#     print(f"{cid};{name}")

# print in list
for cid, name in results:
    print(f"{cid}")
#!/usr/bin/env python3
import re
from pathlib import Path

# --- config ---
SCRIPT_DIR = Path("script")
REMOVE_LIST = Path("remove.txt")
# ----------------

def load_ids(path: Path):
    ids = set()
    if not path.exists():
        return ids

    raw = path.read_bytes()

    # Detect BOM
    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 not line or line.startswith("#"):
            continue
        try:
            ids.add(int(line))
        except:
            pass

    return ids


# Regex patterns
re_only_setcategory = re.compile(
    r'^[ \t]*[A-Za-z0-9_:.]*SetCategory\(\s*CATEGORY_EQUIP\s*\)[ \t]*$'
)
re_only_setop = re.compile(
    r'^[ \t]*Duel\.SetOperationInfo\(\s*0\s*,\s*CATEGORY_EQUIP\b[^)]*\)[ \t]*$'
)


def process_lines(lines):
    new_lines = []

    for line in lines:
        original_line = line

        # 1) If the entire line is SetCategory(CATEGORY_EQUIP) → remove
        if re_only_setcategory.match(line):
            continue

        # 2) If entire line is Duel.SetOperationInfo(…, CATEGORY_EQUIP, …) → remove
        if re_only_setop.match(line):
            continue

        # 3) partial replacements inside the line
        modified = line

        # Remove +CATEGORY_EQUIP
        modified = re.sub(r'\+\s*CATEGORY_EQUIP\b', '', modified)
        # Remove CATEGORY_EQUIP+
        modified = re.sub(r'\bCATEGORY_EQUIP\s*\+', '', modified)

        # If CATEGORY_EQUIP is the only expression left (rare)
        if modified.strip() == "":
            continue  # remove empty result line

        new_lines.append(modified)

    return new_lines


def main():
    ids = load_ids(REMOVE_LIST)

    for cid in sorted(ids):
        lua_file = SCRIPT_DIR / f"c{cid}.lua"
        if not lua_file.exists():
            print(f"skip {cid} (no file)")
            continue

        # Read raw bytes to preserve original line endings
        raw = lua_file.read_bytes()

        # Detect newline style
        if b"\r\n" in raw:
            newline = "\r\n"
        else:
            newline = "\n"

        # Decode
        text = raw.decode("utf-8", errors="ignore")

        # Split while preserving empty lines
        lines = text.splitlines()

        # Process line-by-line
        new_lines = process_lines(lines)

        # Join with original newline style
        new_text = newline.join(new_lines)

        # Write back with exact newline setting
        with open(lua_file, "w", encoding="utf-8", newline="") as f:
            f.write(new_text)

        print(f"updated {cid}.lua")

if __name__ == "__main__":
    main()
Edited Nov 17, 2025 by Vury Leo

Check out, review, and merge locally

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

git fetch origin
git checkout -b "equip-self-only" "origin/equip-self-only"

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 "equip-self-only"

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!74

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.