card

package
v0.3.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package card implements data structures used by Spy Cards Online.

Index

Constants

View Source
const (
	// PortraitCustomEmbedded is an embedded PNG custom portrait.
	PortraitCustomEmbedded uint8 = 254
	// PortraitCustomExternal is a FileID of an external portrait.
	PortraitCustomExternal uint8 = 255

	// DefaultPortraitCount is the number of portrait slots that are used in
	// the enemy portrait sprite sheet, not counting the digits at the end.
	DefaultPortraitCount = 233
)
View Source
const (
	PosInf = "∞"
	NegInf = "-∞"
)

Infinity symbol strings.

View Source
const (
	// ExtensionOverrideCustom (SetStageIPFS, SetMusic, SetStage): override even
	// if a custom override is already active.
	ExtensionOverrideCustom uint64 = 1 << 0
)

Extension flags.

Variables

View Source
var AssetStages = []*AssetStage{
	{
		DisplayName: "Metal Island Auditorium",
		Name:        "stage0001",
		CIDs: []ContentIdentifier{
			ContentIdentifier("\x01\x70\x12\x20\xee\xb4\x57\xb7\x33\x4b\xa0\xea\x6e\x1e\xc3\x61\x8a\xae\xea\x25\x3c\xa6\xf5\xdb\x79\xda\xee\x01\xfd\x9e\xb8\x1b\xe2\x2e\xb2\x1f"),
		},
	},
	{
		DisplayName: "Golden Hills",
		Name:        "stage0002",
		CIDs: []ContentIdentifier{
			ContentIdentifier("\x01\x70\x12\x20\x57\xfb\x38\x4d\x61\x01\x58\x3f\x31\xd1\xc7\x94\x2c\x69\xb3\x16\x85\x36\x8b\x33\x41\x08\xae\x21\x6e\x55\xc7\x1d\x83\x45\x09\x81"),
		},
	},
	{
		DisplayName: "Forsaken Lands",
		Name:        "stage0003",
		CIDs: []ContentIdentifier{
			ContentIdentifier("\x01\x70\x12\x20\x27\x68\x54\xff\x4b\x10\xf4\xbb\xb0\xea\xf0\x8d\xac\x1b\x35\x16\xf1\xd2\x13\xde\xa6\xa1\x42\x7b\x2c\xfd\x70\x9e\x7e\xe2\xa7\xd0"),
		},
	},
	{
		DisplayName: "Doppel's Underground Tavern",
		Name:        "stage0004",
	},
	{
		DisplayName: "Broodmother",
		Name:        "broodmother",
		CIDs: []ContentIdentifier{
			ContentIdentifier("\x01\x70\x12\x20\xc0\xfe\x0d\x55\x32\x99\x6a\xd9\x08\x38\x65\x26\xc5\x6c\x8e\x94\x39\x8f\x6b\xe8\xc0\xf6\xae\x54\x62\x7c\x7e\x00\xba\x84\x05\x35"),
			ContentIdentifier("\x01\x70\x12\x20\x19\x4a\x41\xc7\xa4\x58\x17\x1a\x43\xea\x80\x58\xa7\x0c\x09\x47\xb8\x63\x18\xea\x0b\xe7\x1e\xc4\x06\xb1\x84\x75\xc7\xd3\x7a\x30"),
		},
	},
	{
		DisplayName: "Abandoned Tent",
		Name:        "abandoned-tent",
		CIDs: []ContentIdentifier{
			ContentIdentifier("\x01\x70\x12\x20\xff\xc1\x94\x32\xfd\x47\x84\xa3\x22\xaa\xa3\x40\xd3\x5f\xdd\x1c\x8f\xac\x66\xab\x50\x09\xe3\xed\x96\x4c\xf2\x4d\xdd\xd9\x06\x85"),
			ContentIdentifier("\x01\x70\x12\x20\x25\x36\x35\x3a\x3f\x93\xed\xeb\x30\x70\xda\x67\x4f\xd1\x59\xf8\x0c\x1e\xd3\x55\x93\x84\xb6\xc9\x66\x0e\x8a\xbe\xac\x5e\x74\xbe"),
		},
	},
	{
		DisplayName: "Ant Kingdom Mine",
		Name:        "mine",
		CIDs: []ContentIdentifier{
			ContentIdentifier("\x01\x70\x12\x20\x84\x04\x70\x53\xf8\x48\xf4\xb8\xf8\x5e\xaa\x6f\xd9\xe7\x63\xb5\x4a\xaf\xd1\x42\xac\x00\x27\xae\xe5\xcc\x97\xe5\x3f\x32\x6f\xe3"),
		},
	},
	{
		DisplayName: "Ant Kingdom Plaza",
		Name:        "bugaria-main",
		CIDs: []ContentIdentifier{
			ContentIdentifier("\x01\x70\x12\x20\x02\x72\x20\x2b\x09\x81\x50\x51\x9b\xb6\xdf\xe5\x43\xd4\xb5\x3d\x36\xea\x05\x35\x55\x41\x28\x5d\xfd\x35\xb0\xc7\xf7\x18\x8d\x66"),
		},
	},
}

AssetStages are the stages included with Spy Cards Online, with data about the previous encodings of their IDs.

View Source
var DefaultGameRules = GameRules{
	MaxHP:             5,
	HandMinSize:       3,
	HandMaxSize:       5,
	DrawPerRound:      2,
	CardsPerDeck:      15,
	MinTP:             2,
	MaxTP:             10,
	TPPerRound:        1,
	BossCards:         1,
	MiniBossCards:     2,
	DuplicateBoss:     1,
	DuplicateMiniBoss: 1,
	DuplicateEffect:   0,
	DuplicateAttacker: 0,
	CardsPerRound:     0,
}

DefaultGameRules is the default game rules for Spy Cards Online.

Functions

func RandomRecording added in v0.3.4

func RandomRecording(ctx context.Context, mode string, not ...string) (string, error)

Types

type AssetStage added in v0.3.19

type AssetStage struct {
	Name        string
	DisplayName string
	CIDs        []ContentIdentifier
}

type BannedCards

type BannedCards struct {
	Flags BannedCardsFlags
	Cards []ID
}

BannedCards is a custom game mode field representing cards that cannot be used in decks or summoned via random summons in this game mode.

If Cards is empty, all vanilla cards (that is, cards with an ID less than 128) are banned.

func (*BannedCards) Marshal

func (f *BannedCards) Marshal(w *format.Writer) error

Marshal implements Field.

func (*BannedCards) Type

func (f *BannedCards) Type() FieldType

Type implements Field.

func (*BannedCards) Unmarshal

func (f *BannedCards) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*BannedCards) UpdateID added in v0.2.68

func (f *BannedCards) UpdateID(oldID, newID ID)

UpdateID implements Field.

type BannedCardsFlags added in v0.2.72

type BannedCardsFlags uint64

BannedCardsFlags is a bitfield of flags for BannedCards.

const (
	BannedCardTypeMask       BannedCardsFlags = 3 << 0
	BannedCardTypeBanned     BannedCardsFlags = 0 << 0
	BannedCardTypeUnpickable BannedCardsFlags = 1 << 0
	BannedCardTypeHiddenHome BannedCardsFlags = 2 << 0
)

Constants for BannedCardsFlags.

type BugFablesVersion added in v0.3.1

type BugFablesVersion uint8

BugFablesVersion is a version of Bug Fables: The Everlasting Sapling.

const (
	BugFables105 BugFablesVersion = iota // Bug Fables 1.0.5
	BugFables11                          // Bug Fables 1.1
	BugFables111                         // Bug Fables 1.1.1

	LatestVersion = BugFables111
)

Constants for BugFablesVersion.

func (BugFablesVersion) String added in v0.3.1

func (i BugFablesVersion) String() string

type ContentIdentifier added in v0.2.72

type ContentIdentifier []byte

ContentIdentifier is an IPFS CID.

func (ContentIdentifier) String added in v0.2.72

func (cid ContentIdentifier) String() string

type CosmeticData

type CosmeticData struct {
	CharacterName string `json:"character"`
}

CosmeticData is non-essential data representing choices made by each player before the match began.

type Deck

type Deck []ID

Deck is a partially ordered list of Spy Cards cards, with boss first, then mini-boss, and then enemy (attacker and effect) cards.

func (Deck) MarshalBinary

func (d Deck) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (Deck) MarshalText

func (d Deck) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Deck) UnmarshalBinary

func (d *Deck) UnmarshalBinary(b []byte) (err error)

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*Deck) UnmarshalText

func (d *Deck) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (Deck) Validate

func (d Deck) Validate(set *Set) error

Validate returns a non-nil error if the deck is not a valid deck for the given card set.

type DeckLimitFilter added in v0.2.68

type DeckLimitFilter struct {
	Count     uint64
	Filter    Filter
	CondCount uint64
	Condition Filter
}

DeckLimitFilter limits the number of cards that may appear in a deck based on a filter.

func (*DeckLimitFilter) Marshal added in v0.2.68

func (f *DeckLimitFilter) Marshal(w *format.Writer) error

Marshal implements Field.

func (*DeckLimitFilter) Type added in v0.2.68

func (f *DeckLimitFilter) Type() FieldType

Type implements Field.

func (*DeckLimitFilter) Unmarshal added in v0.2.68

func (f *DeckLimitFilter) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*DeckLimitFilter) UpdateID added in v0.2.68

func (f *DeckLimitFilter) UpdateID(oldID, newID ID)

UpdateID implements Field.

type Def

type Def struct {
	ID     ID
	Name   string
	Tribes []TribeDef
	TP     int64

	Rank           Rank
	Portrait       uint8
	CustomPortrait []byte
	Effects        []*EffectDef
	Extensions     []*Extension
	// contains filtered or unexported fields
}

Def is a card definition.

func Vanilla

func Vanilla(base BugFablesVersion, id ID) *Def

Vanilla returns a card definition for a given ID.

func (*Def) Description

func (cd *Def) Description(set *Set) *RichDescription

Description returns a description of this card.

func (*Def) DisplayName

func (cd *Def) DisplayName() string

DisplayName returns the name of this card.

func (*Def) MarshalBinary

func (cd *Def) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Def) MarshalText

func (cd *Def) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Def) ToHTML added in v0.3.13

func (cd *Def) ToHTML(ctx context.Context, set *Set) string

func (*Def) UnmarshalBinary

func (cd *Def) UnmarshalBinary(b []byte) (err error)

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*Def) UnmarshalText

func (cd *Def) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (*Def) UpdateID added in v0.2.73

func (cd *Def) UpdateID(oldID, newID ID)

UpdateID changes all references to oldID to newID.

type EffectDef

type EffectDef struct {
	Type     EffectType
	Priority uint8
	Flags    EffectFlag

	Text    string
	Amount  int64
	Amount2 int64
	Amount3 int64
	Filter  Filter

	Result  *EffectDef
	Result2 *EffectDef
}

EffectDef is a Spy Cards Online card effect definition.

func (*EffectDef) Complete added in v0.3.1

func (e *EffectDef) Complete() bool

Complete returns false if the EffectDef expects a result but does not have a result.

func (*EffectDef) Description

func (e *EffectDef) Description(card *Def, set *Set, parents ...*EffectDef) []*RichDescription

Description returns a description of this effect.

func (*EffectDef) IsPassive added in v0.3.17

func (e *EffectDef) IsPassive(card *Def) bool

func (*EffectDef) Marshal

func (e *EffectDef) Marshal(w *format.Writer) (err error)

Marshal encodes the EffectDef in a binary format.

func (*EffectDef) Unmarshal

func (e *EffectDef) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal decodes the EffectDef from a binary format.

func (*EffectDef) UpdateID added in v0.2.73

func (e *EffectDef) UpdateID(oldID, newID ID)

UpdateID changes all references to oldID to newID.

type EffectFlag

type EffectFlag uint64

EffectFlag is a combination bitfield type for all effect flags.

const (
	FlagFlavorTextHideRemaining EffectFlag = 1 << 0
	FlagFlavorTextCustomColor   EffectFlag = 1 << 1

	FlagStatDEF      EffectFlag = 1 << 0
	FlagStatInfinity EffectFlag = 1 << 1
	FlagStatOpponent EffectFlag = 1 << 2

	FlagSummonOpponent  EffectFlag = 1 << 0
	FlagSummonReplace   EffectFlag = 1 << 1
	FlagSummonInvisible EffectFlag = 1 << 2

	FlagHealInfinity EffectFlag = 1 << 0
	FlagHealOpponent EffectFlag = 1 << 1
	FlagHealRaw      EffectFlag = 1 << 2

	FlagTPInfinity EffectFlag = 1 << 0

	FlagNumbInfinity      EffectFlag = 1 << 0
	FlagNumbSelf          EffectFlag = 1 << 1
	FlagNumbHighest       EffectFlag = 1 << 2
	FlagNumbIgnoreATK     EffectFlag = 1 << 3
	FlagNumbIgnoreDEF     EffectFlag = 1 << 4
	FlagNumbAvoidZero     EffectFlag = 1 << 5
	FlagNumbResult        EffectFlag = 1 << 6
	FlagNumbResult2       EffectFlag = 1 << 7
	FlagNumbSummon        EffectFlag = 1 << 8
	FlagNumbIgnorePrevent EffectFlag = 1 << 9

	FlagMultiplyHealingOpponent     EffectFlag = 1 << 0
	FlagMultiplyHealingFuture       EffectFlag = 1 << 1
	FlagMultiplyHealingTypeMask     EffectFlag = 3 << 2
	FlagMultiplyHealingTypeAll      EffectFlag = 0 << 2
	FlagMultiplyHealingTypeNegative EffectFlag = 1 << 2
	FlagMultiplyHealingTypePositive EffectFlag = 2 << 2

	FlagPreventNumbOpponent EffectFlag = 1 << 0

	FlagModifyCardsOpponent        EffectFlag = 1 << 0
	FlagModifyCardsTypeMask        EffectFlag = 3 << 1
	FlagModifyCardsTypeAdd         EffectFlag = 0 << 1
	FlagModifyCardsTypeRemove      EffectFlag = 1 << 1
	FlagModifyCardsTypeMove        EffectFlag = 2 << 1
	FlagModifyCardsTypeReplace     EffectFlag = 3 << 1
	FlagModifyCardsTargetMask      EffectFlag = 3 << 3
	FlagModifyCardsTargetAny       EffectFlag = 0 << 3
	FlagModifyCardsTargetHand      EffectFlag = 1 << 3
	FlagModifyCardsTargetDeck      EffectFlag = 2 << 3
	FlagModifyCardsTargetField     EffectFlag = 3 << 3
	FlagModifyCardsRequireMask     EffectFlag = 3 << 5
	FlagModifyCardsRequireNone     EffectFlag = 0 << 5
	FlagModifyCardsRequireSelf     EffectFlag = 1 << 5
	FlagModifyCardsRequireOpponent EffectFlag = 2 << 5
	FlagModifyCardsResult          EffectFlag = 1 << 7
	FlagModifyCardsResult2         EffectFlag = 1 << 8
	FlagModifyCardsNamedGroup      EffectFlag = 1 << 9

	FlagModifyCardCostInfinity EffectFlag = 1 << 0
	FlagModifyCardCostSet      EffectFlag = 1 << 1

	FlagDrawCardOpponent  EffectFlag = 1 << 0
	FlagDrawCardIgnoreMax EffectFlag = 1 << 1
	FlagDrawCardUseFilter EffectFlag = 1 << 2
	FlagDrawCardResult    EffectFlag = 1 << 3

	FlagModifyGameRuleRelative       EffectFlag = 1 << 0
	FlagModifyGameRulePlayerMask     EffectFlag = 3 << 1
	FlagModifyGameRulePlayerSelf     EffectFlag = 0 << 1
	FlagModifyGameRulePlayerOpponent EffectFlag = 1 << 1
	FlagModifyGameRulePlayerBoth     EffectFlag = 2 << 1

	FlagDelaySetupOpponent EffectFlag = 1 << 0
	FlagDelaySetupDelete   EffectFlag = 1 << 1

	FlagCondCardOpponent         EffectFlag = 1 << 0
	FlagCondCardTypeMask         EffectFlag = 3 << 1
	FlagCondCardTypeGreaterEqual EffectFlag = 0 << 1
	FlagCondCardTypeLessThan     EffectFlag = 1 << 1
	FlagCondCardTypeEach         EffectFlag = 2 << 1
	FlagCondCardAllowNumb        EffectFlag = 1 << 3
	FlagCondCardLocationMask     EffectFlag = 3 << 4
	FlagCondCardLocationField    EffectFlag = 0 << 4
	FlagCondCardLocationHand     EffectFlag = 1 << 4
	FlagCondCardLocationDeck     EffectFlag = 2 << 4

	FlagCondLimitGreaterThan EffectFlag = 1 << 0

	FlagCondWinnerTypeMask      EffectFlag = 7 << 0
	FlagCondWinnerTypeWinner    EffectFlag = 0 << 0
	FlagCondWinnerTypeLoser     EffectFlag = 1 << 0
	FlagCondWinnerTypeTie       EffectFlag = 2 << 0
	FlagCondWinnerTypeNotTie    EffectFlag = 3 << 0
	FlagCondWinnerTypeNotWinner EffectFlag = 4 << 0
	FlagCondWinnerTypeNotLoser  EffectFlag = 5 << 0

	FlagCondApplyNextRound        EffectFlag = 1 << 0
	FlagCondApplyOpponent         EffectFlag = 1 << 1
	FlagCondApplyShowMask         EffectFlag = 3 << 2
	FlagCondApplyShowJustEffect   EffectFlag = 0 << 2
	FlagCondApplyShowOriginalText EffectFlag = 1 << 2
	FlagCondApplyShowNothing      EffectFlag = 2 << 2

	FlagCondCoinTails    EffectFlag = 1 << 0
	FlagCondCoinNegative EffectFlag = 1 << 1
	FlagCondCoinStat     EffectFlag = 1 << 2
	FlagCondCoinWeighted EffectFlag = 1 << 3

	FlagCondStatOpponent     EffectFlag = 1 << 0
	FlagCondStatLessThan     EffectFlag = 1 << 1
	FlagCondStatTypeMask     EffectFlag = 3 << 2
	FlagCondStatTypeATK      EffectFlag = 0 << 2
	FlagCondStatTypeDEF      EffectFlag = 1 << 2
	FlagCondStatTypeHP       EffectFlag = 2 << 2
	FlagCondStatTypeTP       EffectFlag = 3 << 2
	FlagCondStatMultiple     EffectFlag = 1 << 4
	FlagCondStatMathMask     EffectFlag = 3 << 5
	FlagCondStatMathNone     EffectFlag = 0 << 5
	FlagCondStatMathAdd      EffectFlag = 1 << 5
	FlagCondStatMathSubtract EffectFlag = 2 << 5
	FlagCondStatMathOpponent EffectFlag = 1 << 7
	FlagCondStatMathTypeMask EffectFlag = 3 << 8
	FlagCondStatMathTypeATK  EffectFlag = 0 << 8
	FlagCondStatMathTypeDEF  EffectFlag = 1 << 8
	FlagCondStatMathTypeHP   EffectFlag = 2 << 8
	FlagCondStatMathTypeTP   EffectFlag = 3 << 8

	FlagCondInHandHide       EffectFlag = 1 << 0
	FlagCondInHandOnPlayMask EffectFlag = 3 << 1
	FlagCondInHandOnPlayNone EffectFlag = 0 << 1
	FlagCondInHandOnPlayAlso EffectFlag = 1 << 1
	FlagCondInHandOnPlayOnly EffectFlag = 2 << 1

	FlagCondCompareTargetCardInvert EffectFlag = 1 << 0

	FlagCondOnExileGroup EffectFlag = 1 << 0
)

Constants for EffectFlag.

type EffectType

type EffectType uint8

EffectType is an enumeration of effect types.

const (
	FlavorText                 EffectType = 0
	EffectStat                 EffectType = 1
	EffectEmpower              EffectType = 2
	EffectSummon               EffectType = 3
	EffectHeal                 EffectType = 4
	EffectTP                   EffectType = 5
	EffectNumb                 EffectType = 6
	EffectRawStat              EffectType = 7
	EffectMultiplyHealing      EffectType = 8
	EffectPreventNumb          EffectType = 9
	EffectModifyAvailableCards EffectType = 10
	EffectModifyCardCost       EffectType = 11
	EffectDrawCard             EffectType = 12
	EffectModifyGameRule       EffectType = 13
	EffectDelaySetup           EffectType = 14
	CondCard                   EffectType = 128
	CondLimit                  EffectType = 129
	CondWinner                 EffectType = 130
	CondApply                  EffectType = 131
	CondCoin                   EffectType = 132
	CondStat                   EffectType = 133
	CondInHand                 EffectType = 134
	CondLastEffect             EffectType = 135
	CondOnNumb                 EffectType = 136
	CondMultipleEffects        EffectType = 137
	CondOnDiscard              EffectType = 138
	CondCompareTargetCard      EffectType = 139
	CondOnExile                EffectType = 140
)

Constants for EffectType.

func (EffectType) IsCondition added in v0.3.3

func (et EffectType) IsCondition() bool

func (EffectType) IsPassive added in v0.3.3

func (et EffectType) IsPassive() bool

func (EffectType) IsRoot added in v0.3.3

func (et EffectType) IsRoot() bool

func (EffectType) String

func (i EffectType) String() string

type Extension added in v0.2.72

type Extension struct {
	Type      ExtensionType
	Flags     uint64
	CID       ContentIdentifier
	Name      string
	LoopStart float32
	LoopEnd   float32
	// contains filtered or unexported fields
}

Extension is an extension field that allows cards to have meta-game effects.

func (*Extension) Marshal added in v0.2.72

func (e *Extension) Marshal(w *format.Writer) error

Marshal encodes the extension field.

func (*Extension) Unmarshal added in v0.2.72

func (e *Extension) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal decodes the extension field.

type ExtensionType added in v0.2.72

type ExtensionType uint64

ExtensionType is an extension field type.

const (
	ExtensionSetStageIPFS ExtensionType = 0
	ExtensionSetMusic     ExtensionType = 1
	ExtensionPlaySound    ExtensionType = 2
	ExtensionSetStage     ExtensionType = 3
)

Constants for ExtensionType.

func (ExtensionType) String added in v0.2.72

func (i ExtensionType) String() string

type ExternalMode added in v0.2.75

type ExternalMode struct {
	Name         string
	Cards        string
	Revision     int
	QuickJoin    bool
	AnyRecording bool
}

ExternalMode is a Spy Cards Online game mode as returned by the server.

func FetchMode added in v0.2.75

func FetchMode(ctx context.Context, name, revision string) (*ExternalMode, error)

FetchMode downloads a game mode from the server.

type Field

type Field interface {
	Type() FieldType
	Marshal(w *format.Writer) error
	Unmarshal(r *format.Reader, formatVersion uint64) error
	UpdateID(oldID, newID ID)
}

Field is an interface implemented by all custom game mode fields.

func NewField

func NewField(t FieldType) (Field, error)

NewField constructs a Field with a given FieldType.

type FieldType

type FieldType uint64

FieldType is an enumeration of Spy Cards Online game mode field types.

const (
	FieldMetadata        FieldType = 0
	FieldBannedCards     FieldType = 1
	FieldGameRules       FieldType = 2
	FieldSummonCard      FieldType = 3
	FieldVariant         FieldType = 4
	FieldUnfilterCard    FieldType = 5
	FieldDeckLimitFilter FieldType = 6
	FieldTimer           FieldType = 7
	FieldTurn0Effect     FieldType = 8
	FieldVanillaVersion  FieldType = 9
	FieldGroup           FieldType = 10
	FieldSpecialFlags    FieldType = 11
)

Constants for FieldType.

func (FieldType) String

func (i FieldType) String() string

type Filter added in v0.2.72

type Filter []FilterComponent

Filter is a card filter, introduced in card format 5.

func (Filter) IsMatch added in v0.3.4

func (f Filter) IsMatch(card *Def, target ID) bool

IsMatch returns true if the specified card matches this filter.

func (Filter) IsSingleCard added in v0.2.72

func (f Filter) IsSingleCard() bool

IsSingleCard returns true if this filter is a single card filter.

func (*Filter) Marshal added in v0.2.72

func (f *Filter) Marshal(w *format.Writer) error

Marshal encodes the card filter.

func (*Filter) Unmarshal added in v0.2.72

func (f *Filter) Unmarshal(r *format.Reader) (err error)

Unmarshal decodes a card filter.

type FilterComponent added in v0.2.72

type FilterComponent struct {
	Type        FilterType
	Rank        Rank
	Tribe       Tribe
	CustomTribe string
	CardID      ID
	TP          int64
}

FilterComponent is a single component of a card filter.

func (FilterComponent) String added in v0.3.14

func (fc FilterComponent) String() string

type FilterType added in v0.2.72

type FilterType uint8

FilterType is a type of card filter.

const (
	FilterSingleCard FilterType = 1
	FilterTribe      FilterType = 16
	FilterNotTribe   FilterType = 32
	FilterRank       FilterType = 48
	FilterTP         FilterType = 64
	FilterTarget     FilterType = 65
)

Constants for FilterType.

func (FilterType) String added in v0.2.72

func (i FilterType) String() string

type GameMode

type GameMode struct {
	Fields []Field

	VariantApplied bool
}

GameMode is a custom Spy Cards Online game mode.

func (*GameMode) Get

func (gm *GameMode) Get(t FieldType) Field

Get returns the first field of a given FieldType, or nil.

func (*GameMode) GetAll

func (gm *GameMode) GetAll(t FieldType) []Field

GetAll returns a slice of fields with a given FieldType.

func (*GameMode) MarshalBinary

func (gm *GameMode) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*GameMode) MarshalText

func (gm *GameMode) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*GameMode) UnmarshalBinary

func (gm *GameMode) UnmarshalBinary(b []byte) (err error)

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*GameMode) UnmarshalText

func (gm *GameMode) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (*GameMode) Variant

func (gm *GameMode) Variant(i int) (*GameMode, *Variant)

Variant returns the game mode modified by the Variant with the given index.

type GameRules

type GameRules struct {
	MaxHP             uint64
	HandMinSize       uint64
	HandMaxSize       uint64
	DrawPerRound      uint64
	CardsPerDeck      uint64
	MinTP             uint64
	MaxTP             uint64
	TPPerRound        uint64
	BossCards         uint64
	MiniBossCards     uint64
	DuplicateBoss     uint64
	DuplicateMiniBoss uint64
	DuplicateEffect   uint64
	DuplicateAttacker uint64
	CardsPerRound     uint64
}

GameRules is a custom game mode field holding modified Spy Cards rules.

func (*GameRules) Marshal

func (f *GameRules) Marshal(w *format.Writer) error

Marshal implements Field.

func (*GameRules) Type

func (f *GameRules) Type() FieldType

Type implements Field.

func (*GameRules) Unmarshal

func (f *GameRules) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*GameRules) UpdateID added in v0.2.68

func (f *GameRules) UpdateID(oldID, newID ID)

UpdateID implements Field.

type Group added in v0.3.7

type Group struct {
	Flags GroupFlags
	Title string
	Cards []ID
}

func (*Group) Marshal added in v0.3.7

func (f *Group) Marshal(w *format.Writer) error

func (*Group) Type added in v0.3.7

func (f *Group) Type() FieldType

func (*Group) Unmarshal added in v0.3.7

func (f *Group) Unmarshal(r *format.Reader, formatVersion uint64) error

func (*Group) UpdateID added in v0.3.7

func (f *Group) UpdateID(oldID, newID ID)

type GroupFlags added in v0.3.7

type GroupFlags uint64

type ID

type ID uint64

ID is a numeric identifier for a Spy Cards card.

IDs below 128 correspond to the card's internal enemy ID in Bug Fables.

IDs 128 and above are custom Attacker, Effect, Mini-Boss, and Boss cards, in repeating groups of 32 IDs.

const (
	Zombiant           ID = 0
	Jellyshroom        ID = 1
	Spider             ID = 2
	Zasp               ID = 3
	Cactiling          ID = 4
	Psicorp            ID = 5
	Thief              ID = 6
	Bandit             ID = 7
	Inichas            ID = 8
	Seedling           ID = 9
	Numbnail           ID = 14
	Mothiva            ID = 15
	Acornling          ID = 16
	Weevil             ID = 17
	VenusBud           ID = 19
	Chomper            ID = 20
	AcolyteAria        ID = 21
	Kabbu              ID = 23
	VenusGuardian      ID = 24
	WaspTrooper        ID = 25
	WaspBomber         ID = 26
	WaspDriller        ID = 27
	WaspScout          ID = 28
	Midge              ID = 29
	Underling          ID = 30
	MonsieurScarlet    ID = 31
	GoldenSeedling     ID = 32
	ArrowWorm          ID = 33
	Carmina            ID = 34
	SeedlingKing       ID = 35
	Broodmother        ID = 36
	Plumpling          ID = 37
	Flowerling         ID = 38
	Burglar            ID = 39
	Astotheles         ID = 40
	MotherChomper      ID = 41
	Ahoneynation       ID = 42
	BeeBoop            ID = 43
	SecurityTurret     ID = 44
	Denmuki            ID = 45
	HeavyDroneB33      ID = 46
	Mender             ID = 47
	Abomihoney         ID = 48
	DuneScorpion       ID = 49
	TidalWyrm          ID = 50
	Kali               ID = 51
	Zombee             ID = 52
	Zombeetle          ID = 53
	TheWatcher         ID = 54
	PeacockSpider      ID = 55
	Bloatshroom        ID = 56
	Krawler            ID = 57
	HauntedCloth       ID = 58
	Warden             ID = 61
	JumpingSpider      ID = 63
	MimicSpider        ID = 64
	LeafbugNinja       ID = 65
	LeafbugArcher      ID = 66
	LeafbugClubber     ID = 67
	Madesphy           ID = 68
	TheBeast           ID = 69
	ChomperBrute       ID = 70
	Mantidfly          ID = 71
	GeneralUltimax     ID = 72
	WildChomper        ID = 73
	Cross              ID = 74
	Poi                ID = 75
	PrimalWeevil       ID = 76
	FalseMonarch       ID = 77
	Mothfly            ID = 78
	MothflyCluster     ID = 79
	Ironnail           ID = 80
	Belostoss          ID = 81
	Ruffian            ID = 82
	WaterStrider       ID = 83
	DivingSpider       ID = 84
	Cenn               ID = 85
	Pisci              ID = 86
	DeadLanderα        ID = 87
	DeadLanderβ        ID = 88
	DeadLanderγ        ID = 89
	WaspKing           ID = 90
	TheEverlastingKing ID = 91
	Maki               ID = 92
	Kina               ID = 93
	Yin                ID = 94
	UltimaxTank        ID = 95
	Zommoth            ID = 96
	Riz                ID = 97
	Devourer           ID = 98
	Stratos            ID = 111
	Delilah            ID = 112
)

Constants for ID.

func VanillaOrder added in v0.2.78

func VanillaOrder(back Rank) []ID

VanillaOrder returns the order of default cards for a specified back design.

func (ID) BasicIndex

func (i ID) BasicIndex() int

BasicIndex returns the index of the card in the list of vanilla cards with its back (boss, mini-boss, or enemy).

func (ID) Rank

func (i ID) Rank() Rank

Rank returns the rank of a card.

func (ID) String

func (i ID) String() string

String returns the default name for this card ID.

type Metadata

type Metadata struct {
	Title          string
	Author         string
	Description    string
	LatestChanges  string
	Portrait       uint8
	CustomPortrait []byte
}

Metadata is a custom game mode field holding human-readable descriptions of the game mode.

func (*Metadata) Marshal

func (f *Metadata) Marshal(w *format.Writer) error

Marshal implements Field.

func (*Metadata) Type

func (f *Metadata) Type() FieldType

Type implements Field.

func (*Metadata) Unmarshal

func (f *Metadata) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*Metadata) UpdateID added in v0.2.68

func (f *Metadata) UpdateID(oldID, newID ID)

UpdateID implements Field.

type ModifiedCardPosition added in v0.2.77

type ModifiedCardPosition struct {
	InHand   bool
	Position uint64
	CardID   ID
}

ModifiedCardPosition is a card modified by the Modify Available Cards effect.

type Number added in v0.3.10

type Number struct {
	Amount    int64
	AmountInf int64
	NaN       bool
}

Number is an integer that may be infinite or invalid.

func Num added in v0.3.10

func Num(amount int64) Number

Num is a convenience function that returns a Number representing the specified amount.

func (*Number) Add added in v0.3.10

func (n *Number) Add(x Number, allowSubtractingInf bool)

Add increases the value of n by x.

func (Number) Less added in v0.3.10

func (n Number) Less(x Number) bool

Less returns true if n is less than x.

func (*Number) Negate added in v0.3.10

func (n *Number) Negate()

Negate sets n's value to -n.

func (Number) String added in v0.3.10

func (n Number) String() string

type Rank

type Rank uint8

Rank is an enumeration of card types.

const (
	Attacker Rank = 0
	Effect   Rank = 1
	MiniBoss Rank = 2 // Mini-Boss
	Boss     Rank = 3
	Token    Rank = 4
	Enemy    Rank = 5

	RankNone Rank = 7 // None
)

Constants for Rank.

func (Rank) Back

func (r Rank) Back(useEffectBack bool) Rank

Back returns Enemy for Attacker and Effect as these ranks share a card back. Otherwise, Back returns r unchanged.

func (Rank) String

func (i Rank) String() string

func (Rank) ToHTML added in v0.3.13

func (r Rank) ToHTML(ctx context.Context, set *Set) string

type Recording

type Recording struct {
	FormatVersion  uint64
	Version        [3]uint64
	ModeName       string
	Perspective    uint8 // 0 = none, n = Player n
	Cosmetic       [2]CosmeticData
	RematchCount   uint64
	WonMatches     uint64
	Start          time.Time
	SpoilerGuard   [2]*[32]byte
	SharedSeed     [32]byte
	PrivateSeed    [2][4]byte
	CustomCards    Set
	CustomCardsRaw string
	InitialDeck    [2]Deck
	Rounds         []RecordingRound
}

Recording is a recording of a Spy Cards Online match.

func FetchRecording added in v0.2.75

func FetchRecording(ctx context.Context, code string) (*Recording, error)

FetchRecording downloads and decodes a recording from the server, or decodes a base64-encoded recording, depending on the length of the code.

func (*Recording) MarshalBinary

func (sc *Recording) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Recording) MarshalText

func (sc *Recording) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Recording) UnmarshalBinary

func (sc *Recording) UnmarshalBinary(b []byte) (err error)

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*Recording) UnmarshalText

func (sc *Recording) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type RecordingRound

type RecordingRound struct {
	TurnSeed  [8]byte
	TurnSeed2 [8]byte
	Ready     [2]uint64
}

RecordingRound is data for one round of Spy Cards Online.

type RichDescription

type RichDescription struct {
	Effect *EffectDef

	Text    string
	Content []*RichDescription

	// Color overrides the parent's color if it is non-zero.
	Color sprites.Color
}

RichDescription is a segment of a Spy Cards card description.

func (*RichDescription) String

func (d *RichDescription) String() string

String implements fmt.Stringer.

func (*RichDescription) Typeset added in v0.2.73

func (d *RichDescription) Typeset(font sprites.FontID, x, y, z, sx, sy, spaceX, spaceY float32, effect *EffectDef, center bool, render func(x, y, z, sx, sy float32, text string, tint sprites.Color, isEffect bool))

Typeset arranges the text in an area for rendering.

type Set

type Set struct {
	External string
	Mode     *GameMode
	Spoiler  []*BannedCards
	Variant  int
	Cards    []*Def

	SpoilerGuard [2]*[32]byte

	PortraitSheet *gfx.AssetTexture
	PortraitIndex map[string]int

	AppliedPR         bool
	RandomByBackOrder bool
	FastAnimation     bool
	// contains filtered or unexported fields
}

Set is a set of custom cards.

func (*Set) BuildPortraitIndex added in v0.3.10

func (cs *Set) BuildPortraitIndex()

func (*Set) ByBack added in v0.2.75

func (cs *Set) ByBack(back Rank, d Deck) []*Def

ByBack returns the cards in this Set with the specified back design that are available for deck building.

func (*Set) Card

func (cs *Set) Card(id ID) *Def

Card returns the card with the given ID.

func (*Set) CopyFrom added in v0.3.19

func (cs *Set) CopyFrom(s *Set)

CopyFrom copies non-cache fields.

The vanilla map cannot be copied as it contains sync primitives.

func (*Set) MarshalText

func (cs *Set) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Set) UnmarshalText

func (cs *Set) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (*Set) VanillaVersion added in v0.3.1

func (cs *Set) VanillaVersion() BugFablesVersion

VanillaVersion returns the Bug Fables version used for vanilla cards.

type Sets

type Sets []Set

Sets is a combination of sets of cards.

func (Sets) Apply

func (cs Sets) Apply() (*Set, error)

Apply creates a Set that is the combination of cards in these sets, replacing IDs to ensure they don't overlap.

func (Sets) MarshalText

func (cs Sets) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Sets) UnmarshalText

func (cs *Sets) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type SpecialFlag added in v0.3.10

type SpecialFlag uint64
const (
	SpecialSubtractInf      SpecialFlag // Allow Subtracting Infinities
	SpecialEffectBack                   // Use Effect Card Back
	SpecialNoDamageOnWin                // No Damage on Win
	SpecialRevealSelection              // Reveal Card Selection
	SpecialBothPlayersAreP1             // Both Players are Player 1
	SpecialAutoReady                    // Auto-Ready if Negative TP
	SpecialHideGameLog                  // Hide Game Log
	SpecialFlagCount                    // (not a special flag; denotes end of special flags)
)

Values for SpecialFlag.

func (SpecialFlag) String added in v0.3.10

func (i SpecialFlag) String() string

type SpecialFlags added in v0.3.10

type SpecialFlags struct {
	Flags SpecialFlagsFlags
	Set   map[SpecialFlag]bool
}

func (*SpecialFlags) Marshal added in v0.3.10

func (f *SpecialFlags) Marshal(w *format.Writer) error

func (*SpecialFlags) Type added in v0.3.10

func (f *SpecialFlags) Type() FieldType

func (*SpecialFlags) Unmarshal added in v0.3.10

func (f *SpecialFlags) Unmarshal(r *format.Reader, formatVersion uint64) error

func (*SpecialFlags) UpdateID added in v0.3.10

func (f *SpecialFlags) UpdateID(oldID, newID ID)

type SpecialFlagsFlags added in v0.3.10

type SpecialFlagsFlags uint64

type SummonCard

type SummonCard struct {
	Flags SummonCardFlags
	ID    ID
}

SummonCard is a custom game mode field that summons a card at the start of the match.

func (*SummonCard) Marshal

func (f *SummonCard) Marshal(w *format.Writer) error

Marshal implements Field.

func (*SummonCard) Type

func (f *SummonCard) Type() FieldType

Type implements Field.

func (*SummonCard) Unmarshal

func (f *SummonCard) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*SummonCard) UpdateID added in v0.2.68

func (f *SummonCard) UpdateID(oldID, newID ID)

UpdateID implements Field.

type SummonCardFlags

type SummonCardFlags uint64

SummonCardFlags is a bitfield of flags for SummonCards.

const (
	SummonCardBothPlayers SummonCardFlags = 1 << 0
)

Constants for SummonCardFlags.

type Timer added in v0.2.72

type Timer struct {
	StartTime  uint64
	MaxTime    uint64
	PerTurn    uint64
	MaxPerTurn uint64
}

Timer limits the amount of time players may spend per turn.

func (*Timer) Marshal added in v0.2.72

func (f *Timer) Marshal(w *format.Writer) error

Marshal implements Field.

func (*Timer) Type added in v0.2.72

func (f *Timer) Type() FieldType

Type implements Field.

func (*Timer) Unmarshal added in v0.2.72

func (f *Timer) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*Timer) UpdateID added in v0.2.72

func (f *Timer) UpdateID(oldID, newID ID)

UpdateID implements Field.

type Tribe

type Tribe uint8

Tribe is a 4-bit identifier for a Bug Fables Spy Cards tribe.

const (
	TribeSeedling   Tribe = 0  // Seedling
	TribeWasp       Tribe = 1  // Wasp
	TribeFungi      Tribe = 2  // Fungi
	TribeZombie     Tribe = 3  // Zombie
	TribePlant      Tribe = 4  // Plant
	TribeBug        Tribe = 5  // Bug
	TribeBot        Tribe = 6  // Bot
	TribeThug       Tribe = 7  // Thug
	TribeUnknown    Tribe = 8  // ???
	TribeChomper    Tribe = 9  // Chomper
	TribeLeafbug    Tribe = 10 // Leafbug
	TribeDeadLander Tribe = 11 // Dead Lander
	TribeMothfly    Tribe = 12 // Mothfly
	TribeSpider     Tribe = 13 // Spider
	TribeCustom     Tribe = 14 // (custom)
	TribeNone       Tribe = 15 // (none)
	TribeWideCustom Tribe = 16 // (wide tribe for UI)
)

Constants for Tribe.

func (Tribe) String

func (i Tribe) String() string

type TribeDef

type TribeDef struct {
	Tribe Tribe

	Red   uint8
	Green uint8
	Blue  uint8

	CustomName string
}

TribeDef represents a built-in or custom tribe.

func (TribeDef) Color

func (t TribeDef) Color() sprites.Color

Color returns the color associated with this TribeDef.

func (TribeDef) Name

func (t TribeDef) Name() string

Name returns the display name of this TribeDef.

type Turn0Effect added in v0.2.76

type Turn0Effect struct {
	Flags  uint64
	Effect *EffectDef
}

Turn0Effect applies an effect before the first round of play.

func (*Turn0Effect) Marshal added in v0.2.76

func (f *Turn0Effect) Marshal(w *format.Writer) error

Marshal implements Field.

func (*Turn0Effect) Type added in v0.2.76

func (f *Turn0Effect) Type() FieldType

Type implements Field.

func (*Turn0Effect) Unmarshal added in v0.2.76

func (f *Turn0Effect) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*Turn0Effect) UpdateID added in v0.2.76

func (f *Turn0Effect) UpdateID(oldID, newID ID)

UpdateID implements Field.

type TurnData added in v0.2.75

type TurnData struct {
	Ready    [2]uint64
	Played   [2][]ID
	InHand   [2]uint64
	HandID   [2][]ID
	Modified [2][][]ModifiedCardPosition
}

TurnData is the data stored for one round of Spy Cards Online to allow verification.

type UnfilterCard

type UnfilterCard struct {
	Flags UnfilterCardFlags
	ID    ID
}

UnfilterCard is a custom game mode field that summons a card at the start of the match.

func (*UnfilterCard) Marshal

func (f *UnfilterCard) Marshal(w *format.Writer) error

Marshal implements Field.

func (*UnfilterCard) Type

func (f *UnfilterCard) Type() FieldType

Type implements Field.

func (*UnfilterCard) Unmarshal

func (f *UnfilterCard) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*UnfilterCard) UpdateID added in v0.2.68

func (f *UnfilterCard) UpdateID(oldID, newID ID)

UpdateID implements Field.

type UnfilterCardFlags

type UnfilterCardFlags uint64

UnfilterCardFlags is a bitfield of flags for UnfilterCards.

type UnknownDeck

type UnknownDeck []Rank

UnknownDeck is a Deck that only knows the backs of the cards within it.

func (UnknownDeck) MarshalBinary

func (ud UnknownDeck) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*UnknownDeck) UnmarshalBinary

func (ud *UnknownDeck) UnmarshalBinary(b []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type VanillaVersion added in v0.3.1

type VanillaVersion struct {
	Version BugFablesVersion
}

VanillaVersion overrides the vanilla Spy Cards card set.

func (*VanillaVersion) Marshal added in v0.3.1

func (f *VanillaVersion) Marshal(w *format.Writer) error

Marshal implements Field.

func (*VanillaVersion) Type added in v0.3.1

func (f *VanillaVersion) Type() FieldType

Type implements Field.

func (*VanillaVersion) Unmarshal added in v0.3.1

func (f *VanillaVersion) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*VanillaVersion) UpdateID added in v0.3.1

func (f *VanillaVersion) UpdateID(oldID, newID ID)

UpdateID implements Field.

type Variant

type Variant struct {
	Title string
	NPC   string
	Rules []Field
}

Variant is a custom game mode field representing a sub-mode.

Variants can be selected when starting a match, and append their rules to the game mode's set of fields.

If at least one Variant is present, one variant is always applied.

func (*Variant) Marshal

func (f *Variant) Marshal(w *format.Writer) error

Marshal implements Field.

func (*Variant) Type

func (f *Variant) Type() FieldType

Type implements Field.

func (*Variant) Unmarshal

func (f *Variant) Unmarshal(r *format.Reader, formatVersion uint64) (err error)

Unmarshal implements Field.

func (*Variant) UpdateID added in v0.2.68

func (f *Variant) UpdateID(oldID, newID ID)

UpdateID implements Field.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL