DEF NONE EQU $0

; sCardCollection constants
DEF CARD_COLLECTION_SIZE EQU $200 ; cards
DEF MAX_AMOUNT_OF_CARD   EQU 99
DEF CARD_NOT_OWNED_F     EQU 7
DEF CARD_NOT_OWNED       EQU 1 << CARD_NOT_OWNED_F
DEF CARD_COUNT_MASK      EQU $7f

DEF CARD_COUNT_FROM_BUILT_DECKS EQU CARD_NOT_OWNED ; $80
; on the other hand, counting all owned cards uses $0 and $ff inconsistently

; sDeck* and generic deck constants
DEF NUM_DECKS                   EQU 4
DEF DECK_NAME_SIZE              EQU 24
DEF DECK_NAME_SIZE_WO_SUFFIX    EQU 20 ; name part before "deck"
DEF DECK_SIZE                   EQU 60
DEF DECK_SIZE_BYTES             EQU DECK_SIZE * 2
DEF DECK_STRUCT_SIZE            EQU DECK_NAME_SIZE + DECK_SIZE_BYTES
DEF DECK_COMPRESSED_SIZE        EQU ((DECK_SIZE + 7) / 8 + 1) * 8
DEF DECK_COMPRESSED_STRUCT_SIZE EQU DECK_NAME_SIZE + DECK_COMPRESSED_SIZE
DEF DECK_CONFIG_BUFFER_SIZE     EQU 80
DEF DECK_TEMP_BUFFER_SIZE       EQU 128 ; as DECK_COMPRESSED_STRUCT_SIZE + 32, DECK_SIZE_BYTES + 8, etc.
DEF DECK_BIG_TEMP_BUFFER_SIZE   EQU 256
DEF MAX_NUM_SAME_NAME_CARDS     EQU 4
DEF MAX_NUM_SUB_ENERGY_CARDS    EQU 9
DEF MAX_UNNAMED_DECK_NUM        EQU 999

DEF MAX_NUM_AUTO_DECK_LIST_DIFFERENT_CARDS EQU 43
DEF AUTO_DECK_LIST_BUFFER_SIZE             EQU 3 * MAX_NUM_AUTO_DECK_LIST_DIFFERENT_CARDS + 1

; card data offsets (data/cards.asm and card_data_struct)

RSRESET
; all card types
DEF CARD_DATA_TYPE                RB ; $00
DEF CARD_DATA_GFX                 RW ; $01
DEF CARD_DATA_NAME                RW ; $03
DEF CARD_DATA_RARITY              RB ; $05
DEF CARD_DATA_REAL_SET            RB ; $06
DEF CARD_DATA_SET                 RB ; $07
DEF CARD_DATA_ID                  RW ; $08
DEF CARD_DATA_EFFECT_COMMANDS     EQU _RS ; !TYPE_PKMN
DEF CARD_DATA_HP                  RB ; TYPE_PKMN $0a
DEF CARD_DATA_STAGE               RB ; TYPE_PKMN $0b
DEF CARD_DATA_NONPKMN_DESCRIPTION EQU _RS ; !TYPE_PKMN
DEF CARD_DATA_PREEVO_NAME         RW ; TYPE_PKMN $0c

DEF TRN_CARD_DATA_LENGTH    EQU _RS ; $0d
DEF ENERGY_CARD_DATA_LENGTH EQU _RS ; $0d

; TYPE_PKMN card only
DEF CARD_DATA_ATTACK1                 EQU _RS ; $0e
DEF CARD_DATA_ATTACK1_ENERGY_COST     RB 8 / 2 ; NUM_TYPES / 2
DEF CARD_DATA_ATTACK1_NAME            RW ; $12
DEF CARD_DATA_ATTACK1_DESCRIPTION     RW 2 ; $14
DEF CARD_DATA_ATTACK1_DAMAGE          RB ; $18
DEF CARD_DATA_ATTACK1_CATEGORY        RB ; $19
DEF CARD_DATA_ATTACK1_EFFECT_COMMANDS RW ; $1a
DEF CARD_DATA_ATTACK1_FLAG1           RB ; $1c
DEF CARD_DATA_ATTACK1_FLAG2           RB ; $1d
DEF CARD_DATA_ATTACK1_FLAG3           RB ; $1e
DEF CARD_DATA_ATTACK1_EFFECT_PARAM    RB ; $1f
DEF CARD_DATA_ATTACK1_ANIMATION       RB ; $20

; TYPE_PKMN card only
DEF CARD_DATA_ATTACK2                 EQU _RS ; $21
DEF CARD_DATA_ATTACK2_ENERGY_COST     RB 8 / 2 ; NUM_TYPES / 2
DEF CARD_DATA_ATTACK2_NAME            RW ; $25
DEF CARD_DATA_ATTACK2_DESCRIPTION     RW 2 ; $27
DEF CARD_DATA_ATTACK2_DAMAGE          RB ; $2b
DEF CARD_DATA_ATTACK2_CATEGORY        RB ; $2c
DEF CARD_DATA_ATTACK2_EFFECT_COMMANDS RW ; $2d
DEF CARD_DATA_ATTACK2_FLAG1           RB ; $2f
DEF CARD_DATA_ATTACK2_FLAG2           RB ; $30
DEF CARD_DATA_ATTACK2_FLAG3           RB ; $31
DEF CARD_DATA_ATTACK2_EFFECT_PARAM    RB ; $32
DEF CARD_DATA_ATTACK2_ANIMATION       RB ; $33

; TYPE_PKMN card only
DEF CARD_DATA_RETREAT_COST     RB ; $34
DEF CARD_DATA_WEAKNESS         RB ; $35
DEF CARD_DATA_RESISTANCE       RB ; $36
DEF CARD_DATA_CATEGORY         RW ; $37
DEF CARD_DATA_POKEDEX_NUMBER   RB ; $39
DEF CARD_DATA_DARK             RB ; $3a
DEF CARD_DATA_LEVEL            RB ; $3b
DEF CARD_DATA_LENGTH           RB ; $3c
DEF CARD_DATA_WEIGHT           RW ; $3d
DEF CARD_DATA_PKMN_DESCRIPTION RW ; $3f
DEF CARD_DATA_UNKNOWN2         RB ; $41

DEF PKMN_CARD_DATA_LENGTH EQU _RS ; $42

; generic type (color) constants
	const_def
	const FIRE        ; $00
	const GRASS       ; $01
	const LIGHTNING   ; $02
	const WATER       ; $03
	const FIGHTING    ; $04
	const PSYCHIC     ; $05
DEF NUM_COLORED_TYPES EQU const_value
	const COLORLESS   ; $06
DEF NUM_PKMN_TYPES EQU const_value
	const RAINBOW     ; $07
DEF NUM_TYPES EQU const_value

; generic type (color) flag constants
DEF FIRE_F      EQU $1 << FIRE      ; $01
DEF GRASS_F     EQU $1 << GRASS     ; $02
DEF LIGHTNING_F EQU $1 << LIGHTNING ; $04
DEF WATER_F     EQU $1 << WATER     ; $08
DEF FIGHTING_F  EQU $1 << FIGHTING  ; $10
DEF PSYCHIC_F   EQU $1 << PSYCHIC   ; $20
DEF COLORLESS_F EQU $1 << COLORLESS ; $40

; CARD_DATA_TYPE constants
DEF TYPE_PKMN_FIRE      EQU FIRE
DEF TYPE_PKMN_GRASS     EQU GRASS
DEF TYPE_PKMN_LIGHTNING EQU LIGHTNING
DEF TYPE_PKMN_WATER     EQU WATER
DEF TYPE_PKMN_FIGHTING  EQU FIGHTING
DEF TYPE_PKMN_PSYCHIC   EQU PSYCHIC
DEF TYPE_PKMN_COLORLESS EQU COLORLESS
DEF TYPE_PKMN_RAINBOW   EQU RAINBOW
	const_def TYPE_PKMN_RAINBOW + 1 - TYPE_PKMN_FIRE
DEF TYPE_ENERGY EQU const_value
	const TYPE_ENERGY_FIRE             ; $08
	const TYPE_ENERGY_GRASS            ; $09
	const TYPE_ENERGY_LIGHTNING        ; $0a
	const TYPE_ENERGY_WATER            ; $0b
	const TYPE_ENERGY_FIGHTING         ; $0c
	const TYPE_ENERGY_PSYCHIC          ; $0d
	const TYPE_ENERGY_DOUBLE_COLORLESS ; $0e
	const TYPE_ENERGY_UNUSED           ; $0f
	const TYPE_TRAINER                 ; $10
	const TYPE_TRAINER_UNUSED          ; $11
DEF NUM_CARD_TYPES EQU const_value - 1

DEF TYPE_PKMN      EQU %111
DEF TYPE_ENERGY_F  EQU 3
DEF TYPE_TRAINER_F EQU 4

; CARD_DATA_RARITY constants
DEF CIRCLE    EQU $0
DEF DIAMOND   EQU $1
DEF STAR      EQU $2
DEF WHITESTAR EQU $3
DEF PROMOSTAR EQU $ff

; rarities for Card Pop! and booster content
DEF CARDPOP_CIRCLE    EQU CIRCLE  ; $0
DEF CARDPOP_DIAMOND   EQU DIAMOND ; $1
DEF CARDPOP_STAR      EQU STAR    ; $2
DEF CARDPOP_PHANTOM   EQU $fe
DEF CARDPOP_ENERGY    EQU $ff

; card set constants (set 1)
	const_def
	const BEGINNING_POKEMON     ; $00
	const LEGENDARY_POWER       ; $01
	const ISLAND_OF_FOSSIL      ; $02
	const PSYCHIC_BATTLE        ; $03
	const SKY_FLYING_POKEMON    ; $04
	const WE_ARE_TEAM_ROCKET    ; $05
	const TEAM_ROCKETS_AMBITION ; $06
	const PROMOTIONAL           ; $07
DEF NUM_CARD_SETS EQU const_value
	const ENERGY                ; $08

DEF PRESENT_PACK EQU 7

; booster pack constants
	const_def
	const BOOSTER_BEGINNING_POKEMON            ; $0
	const BOOSTER_LEGENDARY_POWER              ; $1
	const BOOSTER_ISLAND_OF_FOSSIL             ; $2
	const BOOSTER_PSYCHIC_BATTLE               ; $3
	const BOOSTER_SKY_FLYING_POKEMON           ; $4
	const BOOSTER_WE_ARE_TEAM_ROCKET           ; $5
	const BOOSTER_TEAM_ROCKETS_AMBITION        ; $6
	const BOOSTER_DEBUG_10_STAR                ; $7
	const BOOSTER_PRESENT_10_ENERGY            ; $8
	const BOOSTER_PRESENT_FROM_ALL_SETS        ; $9
	const BOOSTER_PRESENT_FROM_NON_ROCKET_SETS ; $a
	const BOOSTER_PRESENT_FROM_LATTER_4_SETS   ; $b
	const BOOSTER_PRESENT_FROM_ROCKET_SETS     ; $c
	const BOOSTER_DEBUG_2_STAR                 ; $d

DEF NUM_BOOSTERS_PRESENT_REGULAR EQU BOOSTER_PRESENT_FROM_ROCKET_SETS - BOOSTER_PRESENT_10_ENERGY ; 4

; real card set constants
	const_def
	const BASE_SET        ; $00
	const JUNGLE          ; $01
	const FOSSIL          ; $02
	const TEAM_ROCKET     ; $03
	const EXPANSION_SHEET ; $04
	const GYM_HEROES      ; $05
	const BULBASAUR_DECK  ; $06
	const SQUIRTLE_DECK   ; $07
	const_def -2
	const GB              ; $fe
	const PRO             ; $ff

DEF NUM_CARDS_IN_BOOSTER EQU 10

; CARD_DATA_STAGE constants
	const_def
	const BASIC                 ; 0
	const STAGE1                ; 1
	const STAGE2                ; 2
DEF NUM_REGULAR_EVO_STAGES EQU const_value
	const STAGE2_WITHOUT_STAGE1 ; 3

; CARD_DATA_WEAKNESS and CARD_DATA_RESISTANCE constants
DEF WR_FIRE      EQU $80
DEF WR_GRASS     EQU $40
DEF WR_LIGHTNING EQU $20
DEF WR_WATER     EQU $10
DEF WR_FIGHTING  EQU $08
DEF WR_PSYCHIC   EQU $04

; CARD_DATA_ATTACK*_CATEGORY constants
DEF DAMAGE_NORMAL EQU $00
DEF DAMAGE_PLUS   EQU $01
DEF DAMAGE_MINUS  EQU $02
DEF DAMAGE_X      EQU $03
DEF POKEMON_POWER EQU $04
DEF RESIDUAL_F    EQU 7
DEF RESIDUAL      EQU 1 << RESIDUAL_F

; Bit mask for CheckLoadedAttackFlag
; for flag address from wLoadedAttackFlag1
DEF ATTACK_FLAG1_ADDRESS EQU $0 << 3
DEF ATTACK_FLAG2_ADDRESS EQU $1 << 3
DEF ATTACK_FLAG3_ADDRESS EQU $2 << 3

; CARD_DATA_ATTACK*_FLAG1 constants
DEF INFLICT_POISON_F           EQU %000
DEF INFLICT_SLEEP_F            EQU %001
DEF INFLICT_PARALYSIS_F        EQU %010
DEF INFLICT_CONFUSION_F        EQU %011
DEF LOW_RECOIL_F               EQU %100
DEF DAMAGE_TO_OPPONENT_BENCH_F EQU %101
DEF HIGH_RECOIL_F              EQU %110
DEF DRAW_CARD_F                EQU %111

; CARD_DATA_ATTACK*_FLAG2 constants
; bits 5, 6 and 7 cover a wide variety of effects
DEF SWITCH_OPPONENT_POKEMON_F  EQU %000
DEF HEAL_USER_F                EQU %001
DEF NULLIFY_OR_WEAKEN_ATTACK_F EQU %010
DEF DISCARD_ENERGY_F           EQU %011
DEF ATTACHED_ENERGY_BOOST_F    EQU %100
DEF FLAG_2_BIT_5_F             EQU %101
DEF FLAG_2_BIT_6_F             EQU %110
DEF FLAG_2_BIT_7_F             EQU %111

; CARD_DATA_ATTACK*_FLAG3 constants
; bit 1 covers a wide variety of effects
; bits 2-7 are unused
DEF BOOST_IF_TAKEN_DAMAGE_F    EQU %000
DEF SPECIAL_AI_HANDLING_F      EQU %001
DEF FLAG_3_BIT_2_F             EQU %010

; CARD_DATA_ATTACK*_FLAG1_F constants
DEF INFLICT_POISON           EQU $1 << INFLICT_POISON_F
DEF INFLICT_SLEEP            EQU $1 << INFLICT_SLEEP_F
DEF INFLICT_PARALYSIS        EQU $1 << INFLICT_PARALYSIS_F
DEF INFLICT_CONFUSION        EQU $1 << INFLICT_CONFUSION_F
DEF LOW_RECOIL               EQU $1 << LOW_RECOIL_F
DEF DAMAGE_TO_OPPONENT_BENCH EQU $1 << DAMAGE_TO_OPPONENT_BENCH_F
DEF HIGH_RECOIL              EQU $1 << HIGH_RECOIL_F
DEF DRAW_CARD                EQU $1 << DRAW_CARD_F

; CARD_DATA_ATTACK*_FLAG2_F constants
; bits 5, 6 and 7 cover a wide variety of effects
DEF SWITCH_OPPONENT_POKEMON  EQU $1 << SWITCH_OPPONENT_POKEMON_F
DEF HEAL_USER                EQU $1 << HEAL_USER_F
DEF NULLIFY_OR_WEAKEN_ATTACK EQU $1 << NULLIFY_OR_WEAKEN_ATTACK_F
DEF DISCARD_ENERGY           EQU $1 << DISCARD_ENERGY_F
DEF ATTACHED_ENERGY_BOOST    EQU $1 << ATTACHED_ENERGY_BOOST_F
DEF FLAG_2_BIT_5             EQU $1 << FLAG_2_BIT_5_F
DEF FLAG_2_BIT_6             EQU $1 << FLAG_2_BIT_6_F
DEF FLAG_2_BIT_7             EQU $1 << FLAG_2_BIT_7_F

; CARD_DATA_ATTACK*_FLAG3_F constants
; bit 1 covers a wide variety of effects
; bits 2-7 are unused
DEF BOOST_IF_TAKEN_DAMAGE    EQU $1 << BOOST_IF_TAKEN_DAMAGE_F
DEF SPECIAL_AI_HANDLING      EQU $1 << SPECIAL_AI_HANDLING_F
DEF FLAG_3_BIT_2             EQU $1 << FLAG_3_BIT_2_F

; special CARD_DATA_RETREAT_COST values
DEF UNABLE_RETREAT EQU $64

; attack index constants
DEF FIRST_ATTACK_OR_PKMN_POWER EQU $0
DEF SECOND_ATTACK              EQU $1

; whether attack with the ATTACHED_ENERGY_BOOST flag
; has limit on attached energy cards boost.
DEF MAX_ENERGY_BOOST_IS_LIMITED     EQU $2
DEF MAX_ENERGY_BOOST_IS_NOT_LIMITED EQU $3

; CARD_DATA_AI_INFO constants
DEF AI_INFO_BENCH_UTILITY EQU $1
DEF AI_INFO_ENCOURAGE_EVO EQU $2
DEF AI_INFO_UNK_03        EQU $3
DEF AI_INFO_UNK_05        EQU $5
DEF AI_INFO_UNK_08        EQU $8

DEF HAS_EVOLUTION_F       EQU 4
DEF HAS_EVOLUTION         EQU 1 << HAS_EVOLUTION_F

; receiving card struct constants
RSRESET
DEF CARD_RECEIVE_STRUCT_CARD_ID           RW ; $0
DEF CARD_RECEIVE_STRUCT_TEXTS             EQU _RS
DEF CARD_RECEIVE_STRUCT_DIALOG_NAME       RW ; $2
DEF CARD_RECEIVE_STRUCT_DIALOG_NAME_SHORT RW ; $4
DEF CARD_RECEIVE_STRUCT_RECEIVED_TEXT     RW ; $6
DEF CARD_RECEIVE_STRUCT_ALT               RB ; $8
DEF CARD_RECEIVE_STRUCT_ALT_RECEIVED_TEXT RW ; $9

DEF CARD_RECEIVE_STRUCT_TEXTS_SIZE EQU _RS - CARD_RECEIVE_STRUCT_TEXTS ; $9
DEF CARD_RECEIVE_STRUCT_SIZE EQU _RS ; $b

; wDeckCheckCardCounts struct
RSRESET
DEF DECKCHECKSTRUCT_ENERGY          RB ; $00
DEF DECKCHECKSTRUCT_BASIC_PKMN      RB ; $01
DEF DECKCHECKSTRUCT_STAGE1_PKMN     RB ; $02
DEF DECKCHECKSTRUCT_STAGE2_PKMN     RB ; $03
DEF DECKCHECKSTRUCT_TRAINER         RB ; $04
DEF DECKCHECKSTRUCT_ENERGY_PER_TYPE RB NUM_TYPES ; $05
DEF DECKCHECKSTRUCT_PKMN_PER_TYPE   RB NUM_TYPES ; $0d
DEF DECKCHECKSTRUCT_ENERGY_SURPLUS  RB NUM_TYPES ; $15
DEF DECKCHECKSTRUCT_RAINBOW_ENERGY  RB ; $1d

DEF DECKCHECKSTRUCT_LENGTH EQU _RS ; $1e

; sending cards
DEF MAX_NUM_CARDS_TO_SEND EQU 60
