Documentation ¶
Overview ¶
Package match implements gameplay logic for Spy Cards Online.
Index ¶
- Constants
- func LoadDecks() []card.Deck
- func PrivateShuffle(scg *matchnet.SecureCardGame, cards []*Card, remote bool)
- func PublicShuffle(scg *matchnet.SecureCardGame, cards []*Card)
- func SaveDeck(d card.Deck)
- type ActiveCard
- type Card
- type CardEffect
- type CardMode
- type GameLog
- type HandCard
- type Init
- type Match
- func (m *Match) BeginTurn(turnData *card.TurnData) error
- func (m *Match) FilterCards(f card.Filter, allowBanned, allowUnfiltered bool) []card.ID
- func (m *Match) Finalize(gc *matchnet.GameConn) (*card.Recording, error)
- func (m *Match) IndexSet()
- func (m *Match) InitState(rng *rng.RNG, network Network)
- func (m *Match) ProcessQueuedEffect(r *rng.RNG, network Network) []CardEffect
- func (m *Match) RecomputePassives(turnData *card.TurnData)
- func (m *Match) ShuffleAndDraw(scg *matchnet.SecureCardGame, haveRemoteSeed bool)
- func (m *Match) SyncInHand(sync func([]byte) []byte, turnData *card.TurnData) error
- func (m *Match) Winner() uint8
- type Network
- type Number
- type Recording
- type Side
- type State
Constants ¶
const ModeCustom = "custom"
ModeCustom is the name of the ad-hoc custom game mode.
Variables ¶
This section is empty.
Functions ¶
func PrivateShuffle ¶ added in v0.2.75
func PrivateShuffle(scg *matchnet.SecureCardGame, cards []*Card, remote bool)
PrivateShuffle shuffles a set of cards.
func PublicShuffle ¶ added in v0.2.75
func PublicShuffle(scg *matchnet.SecureCardGame, cards []*Card)
PublicShuffle shuffles a set of cards where only the backs are known.
Types ¶
type ActiveCard ¶ added in v0.2.75
type ActiveCard struct { Card *Card Mode CardMode Desc *card.RichDescription Effects []*card.EffectDef UnNumb int64 ATK Number DEF Number ActiveEffect *card.EffectDef }
ActiveCard is a a card that's on the field.
type CardEffect ¶ added in v0.2.75
type CardEffect struct { Card *ActiveCard Effect *card.EffectDef Player uint8 }
CardEffect is a queued effect.
type CardMode ¶ added in v0.2.75
type CardMode uint64
CardMode is the reason a card was played.
const ( ModeDefault CardMode = iota ModeSetup ModeSetupOriginal ModeSummoned ModeInvisibleSummoned ModeNumb ModeInHand ModePortraitOnly )
Constants for CardMode.
func (CardMode) Hide ¶ added in v0.2.77
Hide returns true if cards with this mode should be hidden from players.
type GameLog ¶ added in v0.2.75
GameLog is a human-readable description of the events that occurred in a Spy Cards Online match.
func (*GameLog) Pop ¶ added in v0.2.75
func (l *GameLog) Pop()
Pop moves to the parent log level, closing the current log group.
type HandCard ¶ added in v0.2.77
HandCard has additional data for cards currently in a player's hand.
type Init ¶ added in v0.2.75
type Init struct { // Mode is the name of the game mode, one of the following: // - an empty string (vanilla) // - "custom" (ad-hoc custom) // - name.v, where name is a lowercase ascii string and // v is a positive integer (hosted community game mode) Mode string // Version is the Spy Cards Online version number at the time this match // was played. Version [3]uint64 // Custom is the encoded custom cards. For vanilla, this should be empty. // For hosted game modes, this should match the mode's data as returned by // the server. For ad-hoc custom game modes, this may be any non-empty // string of card data. Custom string // Variant is the game mode variant. Variant may be 0 if there are no // variants defined by the game mode. Otherwise, Variant must be less than // the number of variants defined by the game mode. Variant uint64 External *card.ExternalMode CachedVariant *card.Variant Latest bool }
Init is the initial data, known before a match is established.
type Match ¶ added in v0.2.75
type Match struct { // Init holds data known before the match is established. Init *Init // Start is the timestamp of the start of the first round. That is, when // both players finished selecting their decks. Start time.Time // Rematches is the number of matches that happened within this // matchmaking session so far. It starts at 0 and increases by 1 each // time the players agree to a rematch. Rematches uint64 Wins, Losses uint64 // Perspective is the player number (either 1 or 2, for hosting player or // joining player, respectively). Perspective uint8 UnknownDeck uint8 // Cosmetic holds non-critical cosmetic data for the players of the match. Cosmetic [2]card.CosmeticData // Set is the modified card set, with changes applied by spoiler guard, etc. Set *card.Set // Rules is a copy of the rules from Set for convenience. Rules [2]card.GameRules // Timer is a copy of the timer from Set for convenience. Timer card.Timer // Banned is a cache of banned cards from Set. Banned map[card.ID]bool // Unpickable is a cache of unpickable cards from Set. Unpickable map[card.ID]bool // Unfiltered is a cache of unfiltered cards from Set. Unfiltered map[card.ID]bool HasReplaceSummon map[card.ID]bool OrderForSummon map[card.ID]int // State is the mutable state of the match. State State // Log is the game log. Log GameLog }
Match is the data for a specific match.
func (*Match) FilterCards ¶ added in v0.2.75
func (*Match) Finalize ¶ added in v0.2.77
Finalize verifies a match and returns a recording of the match.
func (*Match) ProcessQueuedEffect ¶ added in v0.2.75
func (m *Match) ProcessQueuedEffect(r *rng.RNG, network Network) []CardEffect
func (*Match) RecomputePassives ¶ added in v0.3.2
func (*Match) ShuffleAndDraw ¶ added in v0.2.75
func (m *Match) ShuffleAndDraw(scg *matchnet.SecureCardGame, haveRemoteSeed bool)
func (*Match) SyncInHand ¶ added in v0.2.77
type Network ¶ added in v0.2.77
type Network interface { SendModifiedCards([]card.ModifiedCardPosition) error RecvModifiedCards() []card.ModifiedCardPosition }
Network is the required networking interface for card effect processing.
type Number ¶ added in v0.2.75
Number is an integer that may be infinite or invalid.
type Recording ¶ added in v0.2.75
func NewRecording ¶ added in v0.2.75
func (*Recording) CreateMatch ¶ added in v0.3.1
func (*Recording) NumRounds ¶ added in v0.2.75
NumRounds returns the total number of rounds in the recording (the final round in the recording is after the winner of the match is determined).
func (*Recording) Round ¶ added in v0.2.75
Round returns a processed round from the match recording.
func (*Recording) RoundProcessed ¶ added in v0.2.76
RoundProcessed returns true if the specified round has finished processing.
type Side ¶ added in v0.2.75
type Side struct { HP Number TP Number ATK Number DEF Number RawATK Number RawDEF Number FinalATK Number FinalDEF Number HealMulP int64 HealMulN int64 HealP Number HealN Number Hand []HandCard Deck []*Card Discard []*Card Exile []*Card Field []*ActiveCard Setup []*ActiveCard Limit map[*card.EffectDef]int64 ModTP map[card.ID]int64 }
Side is mutable state for a single player.
type State ¶ added in v0.2.75
type State struct { // Round is the current round number. Round uint64 // Sides holds state that is separate for each player. Sides [2]Side // Queue is the card effect queue. Queue []CardEffect PreQueue []CardEffect // OnNumb is the effects that activate on numb. OnNumb []CardEffect // MaxPriority is the latest effect priority processed this turn. MaxPriority uint8 // RoundWinner is the player who won this round. RoundWinner uint8 // TurnData is used to record networked card modifications. TurnData *card.TurnData }
State is the mutable state of the match.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package matchnet handles networking for Spy Cards Online.
|
Package matchnet handles networking for Spy Cards Online. |
Package minimal provides functions for playing Spy Cards Online in a non-interactive context.
|
Package minimal provides functions for playing Spy Cards Online in a non-interactive context. |
Package npc implements computer-controlled Spy Cards Online players.
|
Package npc implements computer-controlled Spy Cards Online players. |
Package visual implements the graphical interface for Spy Cards Online.
|
Package visual implements the graphical interface for Spy Cards Online. |