Documentation ¶
Overview ¶
Package card implements data structures used by Spy Cards Online.
Index ¶
- Constants
- Variables
- type BannedCards
- type CosmeticData
- type Deck
- func (d Deck) MarshalBinary() ([]byte, error)
- func (d Deck) MarshalText() ([]byte, error)
- func (d Deck) Shuffle(shared, private *rng.RNG)
- func (d Deck) ToUnknown() UnknownDeck
- func (d *Deck) UnmarshalBinary(b []byte) (err error)
- func (d *Deck) UnmarshalText(b []byte) error
- func (d Deck) Validate(ctx context.Context, set *Set) error
- type Def
- func (cd *Def) CustomPortraitImage(ctx context.Context) (*image.RGBA, error)
- func (cd *Def) Description(set *Set) *RichDescription
- func (cd *Def) DisplayName() string
- func (cd *Def) EffectiveTP() (int64, bool)
- func (cd *Def) MarshalBinary() ([]byte, error)
- func (cd *Def) MarshalText() ([]byte, error)
- func (cd *Def) UnmarshalBinary(b []byte) (err error)
- func (cd *Def) UnmarshalText(b []byte) error
- type EffectDef
- type EffectFlag
- type EffectType
- type Field
- type FieldType
- type GameMode
- func (gm *GameMode) Get(t FieldType) Field
- func (gm *GameMode) GetAll(t FieldType) []Field
- func (gm *GameMode) MarshalBinary() ([]byte, error)
- func (gm *GameMode) MarshalText() ([]byte, error)
- func (gm *GameMode) UnmarshalBinary(b []byte) (err error)
- func (gm *GameMode) UnmarshalText(b []byte) error
- func (gm *GameMode) Variant(i int) (*GameMode, *Variant)
- type GameRules
- type ID
- type Metadata
- type Rank
- type Recording
- type RecordingRound
- type RichDescription
- type Set
- type Sets
- type SummonCard
- type SummonCardFlags
- type Tribe
- type TribeDef
- type UnfilterCard
- type UnfilterCardFlags
- type UnknownDeck
- type Variant
Constants ¶
const ( // PortraitCustomEmbedded is an embedded PNG custom portrait. PortraitCustomEmbedded uint8 = 254 // PortraitCustomExternal is a FileID of an external portrait. PortraitCustomExternal uint8 = 255 )
Variables ¶
var DefaultGameRules = GameRules{
MaxHP: 5,
HandMinSize: 3,
HandMaxSize: 5,
DrawPerTurn: 2,
CardsPerDeck: 15,
MinTP: 2,
MaxTP: 10,
TPPerTurn: 1,
BossCards: 1,
MiniBossCards: 2,
}
DefaultGameRules is the default game rules for Spy Cards Online.
Functions ¶
This section is empty.
Types ¶
type BannedCards ¶
type BannedCards struct {
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.
type CosmeticData ¶
type CosmeticData struct {
CharacterName string
}
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 ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (Deck) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (Deck) ToUnknown ¶
func (d Deck) ToUnknown() UnknownDeck
ToUnknown returns an UnknownDeck of the backs of the cards in this Deck.
func (*Deck) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Deck) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Def ¶
type Def struct { ID ID Name string Tribes []TribeDef TP int64 TPInf bool Portrait uint8 CustomPortrait []byte Effects []*EffectDef }
Def is a card definition.
func (*Def) CustomPortraitImage ¶
CustomPortraitImage decodes the custom portrait for this card.
It returns nil if this card does not have a custom portrait.
func (*Def) Description ¶
func (cd *Def) Description(set *Set) *RichDescription
Description returns a description of this card.
func (*Def) DisplayName ¶
DisplayName returns the name of this card.
func (*Def) EffectiveTP ¶
EffectiveTP returns the TP cost of this card, taking unconditional effects into account.
func (*Def) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*Def) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Def) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Def) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type EffectDef ¶
type EffectDef struct { Type EffectType Flags EffectFlag Rank Rank Tribe Tribe Infinity bool Amount uint64 Card ID Text string CustomTribe string Result *EffectDef TailsResult *EffectDef }
EffectDef is a Spy Cards Online card effect definition.
func (*EffectDef) Description ¶
func (e *EffectDef) Description(card *Def, set *Set, parents ...*EffectDef) []*RichDescription
Description returns a description of this effect.
type EffectFlag ¶
type EffectFlag uint8
EffectFlag is a bitfield of effect flags.
const ( FlagNegate EffectFlag = 1 << 0 FlagOpponent EffectFlag = 1 << 1 FlagEach EffectFlag = 1 << 2 FlagLate EffectFlag = 1 << 3 FlagGeneric EffectFlag = 1 << 4 FlagDefense EffectFlag = 1 << 5 )
Constants for EffectFlag.
func (EffectFlag) Has ¶
func (f EffectFlag) Has(flag EffectFlag) bool
Has returns true if the bits in flag are set in f.
func (*EffectFlag) Set ¶
func (f *EffectFlag) Set(flag EffectFlag, on bool)
Set turns the bits in flag on or off in f.
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 CondCard EffectType = 128 CondLimit EffectType = 129 CondWinner EffectType = 130 CondApply EffectType = 131 CondCoin EffectType = 132 CondHP EffectType = 133 CondStat EffectType = 134 CondPriority EffectType = 135 CondOnNumb EffectType = 136 )
Constants for EffectType.
func (EffectType) String ¶
func (i EffectType) String() string
type Field ¶
type Field interface { Type() FieldType Marshal(w *format.Writer) error Unmarshal(r *format.Reader, formatVersion uint64) error }
Field is an interface implemented by all custom game mode fields.
type FieldType ¶
type FieldType uint64
FieldType is an enumeration of Spy Cards Online game mode field types.
type GameMode ¶
type GameMode struct {
Fields []Field
}
GameMode is a custom Spy Cards Online game mode.
func (*GameMode) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*GameMode) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*GameMode) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*GameMode) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type GameRules ¶
type GameRules struct { MaxHP uint64 HandMinSize uint64 HandMaxSize uint64 DrawPerTurn uint64 CardsPerDeck uint64 MinTP uint64 MaxTP uint64 TPPerTurn uint64 BossCards uint64 MiniBossCards uint64 }
GameRules is a custom game mode field holding modified Spy Cards rules.
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 )
Constants for ID.
func (ID) BasicIndex ¶
BasicIndex returns the index of the card in the list of vanilla cards with its back (boss, mini-boss, or enemy).
type Metadata ¶
Metadata is a custom game mode field holding human-readable descriptions of the game mode.
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 Enemy Rank = 4 RankNone Rank = 7 // None )
Constants for Rank.
type Recording ¶
type Recording struct { FormatVersion uint64 Version [3]uint64 ModeName string Perspective uint8 // 0 = none, n = Player n Cosmetic [2]CosmeticData RematchCount uint64 PrivateSeed [2][4]byte CustomCards Set InitialDeck [2]Deck Rounds []RecordingRound }
Recording is a recording of a Spy Cards Online match.
func (*Recording) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*Recording) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Recording) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Recording) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type RecordingRound ¶
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 color.RGBA }
RichDescription is a segment of a Spy Cards card description.
func (*RichDescription) String ¶
func (d *RichDescription) String() string
String implements fmt.Stringer.
type Set ¶
Set is a set of custom cards.
func (*Set) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Set) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Sets ¶
type Sets []Set
Sets is a combination of sets of cards.
func (Sets) Apply ¶
Apply creates a Set that is the combination of cards in these sets, replacing IDs to ensure they don't overlap.
func (Sets) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Sets) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
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.
type SummonCardFlags ¶
type SummonCardFlags uint64
SummonCardFlags is a bitfield of flags for SummonCards.
const (
SummonCardBothPlayers SummonCardFlags = 1 << 0
)
Constants for SummonCardFlags.
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) )
Constants for Tribe.
type TribeDef ¶
TribeDef represents a built-in or custom tribe.
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.
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) Shuffle ¶
func (ud UnknownDeck) Shuffle(shared *rng.RNG)
Shuffle shuffles a deck of card backs.
func (*UnknownDeck) UnmarshalBinary ¶
func (ud *UnknownDeck) UnmarshalBinary(b []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.