Card Database - Fluorohydride/ygopro GitHub Wiki

Card Database Description

The YGOPro card database uses the SQLite format, with the file name cards.cdb, located in the program's root directory.

Some fields are represented using binary bits.

Database Structure

CREATE TABLE datas(
	id INTEGER PRIMARY KEY,
	ot INTEGER,
	alias INTEGER,
	setcode INTEGER,
	type INTEGER,
	atk INTEGER,
	def INTEGER,
	level INTEGER,
	race INTEGER,
	attribute INTEGER,
	category INTEGER
);

CREATE TABLE texts(
	id INTEGER PRIMARY KEY,
	name TEXT,
	"desc" TEXT,
	str1 TEXT,
	str2 TEXT,
	str3 TEXT,
	str4 TEXT,
	str5 TEXT,
	str6 TEXT,
	str7 TEXT,
	str8 TEXT,
	str9 TEXT,
	str10 TEXT,
	str11 TEXT,
	str12 TEXT,
	str13 TEXT,
	str14 TEXT,
	str15 TEXT,
	str16 TEXT
);

Database Field Descriptions

datas Table

  • id: The 8-digit password at the bottom-left corner of the card

    • Token cards: The password +1 of the card that generates the token
    • Cards without password: Custom password assigned by YGOPro
  • ot: Card availability (OCG/TCG, etc.)

    • 0x1: AVAIL_OCG
    • 0x2: AVAIL_TCG
    • 0x4: AVAIL_CUSTOM (custom cards)
    • 0x8: AVAIL_SC (Simplified Chinese)
  • alias: Alias for cards with the same name

    • 0: Not an alias card
    • abs(alias - id) < CARD_ARTWORK_VERSIONS_OFFSET: Alternate artwork card, alias is the actual code, id is the actual code +1
      • For example, the original Blue-Eyes White Dragon has id 89631139 and alias 0, while alternate artworks have id 89631140, 89631141, etc., and alias 89631139
    • Other alias values: Cards with the same name by rule, alias is the code of the corresponding card, id is the actual code
      • For example, Umi has id 22702055 and alias 0, while A Legendary Ocean has id 295517 and alias 22702055
  • setcode: Card archetype (fields included in the card name)

    • Stores 4 values in a single int64, each occupying 16 bits
    • The last 12 bits of each value represent the root field, and the first 4 bits represent the subfield
      • For example, 0x10dc represents Super Quantum, 0x20dc represents Super Quantal Mech Beast, where 0x0dc is the root field Super Quant, and 0x1000 and 0x2000 are subfields
      • Note the inclusion relationship between subfields, e.g., 0x107a represents Noble Knights, 0x207a represents Noble Arms, and 0x507a represents Infernoble Knights, where 0x507a (subfield 0b0101) includes 0x107a (subfield 0b0001) but not 0x207a (subfield 0b0010)
    • Refer to the setnames section in strings.conf for the list
  • type: Card type

    • Refer to TYPE_* in constants.lua
    • Normal Spells and Normal Traps do not use TYPE_NORMAL
    • Trap Monsters do not have TYPE_TRAPMONSTER set in the database but require attributes, levels, ATK/DEF, etc.
  • atk: Card's attack points

    • -1: Indicates the attack points are question mark
  • def: Card's defense points

    • -1: Indicates the defense points are question mark
    • Link Monsters store link markers in this field, refer to LINK_MARKER_* in constants.lua or the numeric keypad layout
  • level: Card's level

    • This field is a 32-bit integer:
      • Bits 0-7: Represent the card's level
      • Bits 8-15: Reserved
      • Bits 16-23: Represent the right Pendulum Scale
      • Bits 24-31: Represent the left Pendulum Scale
    • For example, 0x04040007 represents a Level 7 Pendulum Monster with a left scale of 4 and a right scale of 4
    • The rank of Xyz Monsters and the link value of Link Monsters are also stored in this field
  • race: Card's race

    • Refer to RACE_* in constants.lua
  • attribute: Card's attribute

    • Refer to ATTRIBUTE_* in constants.lua
  • category: Card's effect type

    • Used in search only
    • Refer to the section starting with !system 1100 in system.conf

texts Table

  • id: The 8-digit password at the bottom-left corner of the card

    • Matches the id field in the datas table
  • name: Card's name

  • desc: Card's effect text

    • The format for Pendulum Monsters is as follows:

      ← (Left Scale) 【Pendulum】 (Right Scale) →
      (Pendulum Effect)
      【Monster Effect】
      (Monster Effect)
      
  • str1 ~ str16: Card's hint texts

    • Used for pop-up hints during duels