match

package
v0.2.79 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package match implements gameplay logic for Spy Cards Online.

Index

Constants

View Source
const ModeCustom = "custom"

Variables

This section is empty.

Functions

func LoadDecks added in v0.2.75

func LoadDecks() []card.Deck

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.

func SaveDeck added in v0.2.75

func SaveDeck(d card.Deck)

func SortQueue added in v0.2.75

func SortQueue(q []CardEffect)

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 Card

type Card struct {
	Set  *card.Set
	Def  *card.Def
	Back card.Rank
}

Card is an instance of a card in the game.

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
const (
	ModeDefault CardMode = iota
	ModeSetup
	ModeSetupOriginal
	ModeSummoned
	ModeInvisibleSummoned
	ModeNumb
	ModeInHand
)

func (CardMode) Hide added in v0.2.77

func (m CardMode) Hide() bool

func (CardMode) Ignore added in v0.2.75

func (m CardMode) Ignore() bool

func (CardMode) String added in v0.2.75

func (i CardMode) String() string

type GameLog added in v0.2.75

type GameLog struct {
	Disabled bool
	// contains filtered or unexported fields
}

func (*GameLog) Log added in v0.2.75

func (l *GameLog) Log(message string)

func (*GameLog) Logf added in v0.2.75

func (l *GameLog) Logf(message string, args ...interface{})

func (*GameLog) Pop added in v0.2.75

func (l *GameLog) Pop()

func (*GameLog) Push added in v0.2.75

func (l *GameLog) Push(title string)

func (*GameLog) Pushf added in v0.2.75

func (l *GameLog) Pushf(title string, args ...interface{})

type HandCard added in v0.2.77

type HandCard struct {
	*Card
	InHandTurns int64
	Temporary   bool
}

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.

func (*Init) Cards added in v0.2.75

func (i *Init) Cards(ctx context.Context) (*card.Set, error)

func (*Init) Suffix added in v0.2.75

func (i *Init) Suffix() string

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

	// 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 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
	// contains filtered or unexported fields
}

Match is the data for a specific match.

func (*Match) ApplyInHand added in v0.2.77

func (m *Match) ApplyInHand()

func (*Match) BeginTurn added in v0.2.75

func (m *Match) BeginTurn(turnData *card.TurnData)

func (*Match) FilterCards added in v0.2.75

func (m *Match) FilterCards(f card.Filter, allowBanned, allowUnfiltered bool) []card.ID

func (*Match) Finalize added in v0.2.77

func (m *Match) Finalize(fn func(func(card.Deck, card.Deck, card.UnknownDeck, []byte, []byte, []byte) error, func([]byte, []byte, *card.TurnData) error) error) (*card.Recording, error)

func (*Match) IndexSet added in v0.2.75

func (m *Match) IndexSet()

func (*Match) InitState added in v0.2.75

func (m *Match) InitState(rng *rng.RNG, network Network)

func (*Match) ProcessQueuedEffect added in v0.2.75

func (m *Match) ProcessQueuedEffect(r *rng.RNG, network Network) []CardEffect

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

func (m *Match) SyncInHand(sync func([]byte) []byte, turnData *card.TurnData) error

func (*Match) Winner added in v0.2.75

func (m *Match) Winner() uint8

type Network added in v0.2.77

type Network interface {
	SendModifiedCards([]card.ModifiedCardPosition)
	RecvModifiedCards() []card.ModifiedCardPosition
}

type Number added in v0.2.75

type Number struct {
	Amount    int64
	AmountInf int64
	NaN       bool
}

func (*Number) Add added in v0.2.75

func (n *Number) Add(x Number)

func (Number) Less added in v0.2.75

func (n Number) Less(x Number) bool

func (Number) String added in v0.2.75

func (n Number) String() string

type Recording added in v0.2.75

type Recording struct {
	Recording *card.Recording
	// contains filtered or unexported fields
}

func NewRecording added in v0.2.75

func NewRecording(ctx context.Context, rec *card.Recording) (*Recording, error)

func (*Recording) NumRounds added in v0.2.75

func (r *Recording) NumRounds() int

func (*Recording) Round added in v0.2.75

func (r *Recording) Round(i uint64) (*State, *card.TurnData)

func (*Recording) RoundProcessed added in v0.2.76

func (r *Recording) RoundProcessed(i uint64) bool

type Side added in v0.2.75

type Side struct {
	HP     Number
	TP     Number
	ATK    Number
	DEF    Number
	RawATK Number
	RawDEF Number

	HealMulP int64
	HealMulN int64
	HealP    Number
	HealN    Number

	Hand    []HandCard
	Deck    []*Card
	Discard []*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

	// 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.

Directories

Path Synopsis
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.

Jump to

Keyboard shortcuts

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