Versions in this module Expand all Collapse all v0 v0.5.1 Sep 29, 2024 v0.5.0 Apr 16, 2023 Changes in this version + var WarningUncoperativeCards = &Warning type Message + func ErrorMessage(e error) Message v0.4.0 Apr 16, 2023 Changes in this version + const CardEnactable + const DebugActionEnactable + const DebugDetail + const DebugFine + const DebugInfo + const DebugSuperfine + const DebugWarning + const HideWarnings + const InvalidEnactable + const NotDebugging + const NothingEnactable + const PermanentActionEnactable + var ErrNotDebugging = errors.New("this is a debug-only feature and you're not in debug mode") + func EnsureCapacity(slice []T, req int) []T + func RefundAction() func(c Card[C], p *Player[C], option CardOption[C]) error type Card + func ActionCounterDebugCard() Card[C] + func DebugModeCard() Card[C] type CardOption + func OnlyDiscardFree(msg Message) []CardOption[C] + type DeckDebugger struct + func (DeckDebugger[C]) Drawn(p *Player[C]) bool + func (DeckDebugger[C]) EventText(p *Player[C]) (Message, error) + func (DeckDebugger[C]) Options(p *Player[C]) ([]CardOption[C], error) + func (DeckDebugger[C]) Then(p *Player[C], o CardOption[C]) error + func (DeckDebugger[C]) Title(p *Player[C]) Message + func (DeckDebugger[C]) Urgent(p *Player[C]) bool + type EnactableType int + type PanelCard struct + AfterOption func(c Card[C], p *Player[C], option CardOption[C]) error + CardOptions []CardOption[C] + IsUrgent bool + Panel InfoPanel[C] + func (c *PanelCard[C]) Drawn(_ *Player[C]) bool + func (c *PanelCard[C]) EventText(p *Player[C]) (Message, error) + func (c *PanelCard[C]) Options(_ *Player[C]) ([]CardOption[C], error) + func (c *PanelCard[C]) Then(p *Player[C], option CardOption[C]) error + func (c *PanelCard[C]) Title(p *Player[C]) Message + func (c *PanelCard[C]) Urgent(_ *Player[C]) bool type Player + DebugActions []Card[C] + func (p *Player[C]) EnactDebugActionUnchecked(actionIdx, choiceIdx int) (Message, error) + type RuleDumper struct + func (RuleDumper[C]) Info(p *Player[C]) ([]Message, error) + func (RuleDumper[C]) Title(p *Player[C]) Message + type Titled interface + Title func(*Player[C]) Message v0.3.0 Apr 4, 2023 v0.2.1 Apr 4, 2023 v0.2.0 Apr 4, 2023 Changes in this version + type StatLiteral struct + IsVisible bool + Name string + Value string + func EmitHiddenStat(name string, v any) *StatLiteral + func EmitStat(name string, v any) *StatLiteral + func HiddentStatf(name string, f string, args ...any) *StatLiteral + func RoundHiddenStat(name string, val N, decimals int) *StatLiteral + func RoundStat(name string, val N, decimals int) *StatLiteral + func Statf(name string, f string, args ...any) *StatLiteral + func (s *StatLiteral) StatName() string + func (s *StatLiteral) String() string + func (s *StatLiteral) Visible() bool v0.1.3 Apr 3, 2023 v0.1.2 Apr 3, 2023 v0.1.1 Apr 3, 2023 Changes in this version + const BottomOfDeck + const GameActive + const GameCrashed + const GameLost + const GameStalled + const GameUninitialized + const GameWon + var AnyWarning = &Warning + var ChapterBreak = &SpecialMessage + var ErrAlreadyRunning = errors.New("cannot run a turn while running a turn") + var ErrDeleteRule = errors.New("delete this rule") + var ErrHaltDelete = fmt.Errorf("%w; %w", ErrHaltTurn, ErrDeleteRule) + var ErrHaltTurn = errors.New("turn halted") + var ErrInvalidCard = errors.New("invalid card specified") + var ErrInvalidChoice = errors.New("invalid choice specified") + var ErrNoActions = errors.New("no actions remaining") + var ErrNotUnique = errors.New("not unique") + var ErrNotUrgent = errors.New("action not urgent when urgent card is available") + var ErrUncooperativeCards = errors.New("a milion cards refused to join the hand") + var ErrorNoCards = errors.New("totally out of cards") + var SectionBreak = &SpecialMessage + var WarningBackwardsRange = Warningf("low end of range was above high end of range, flipping it") + var WarningBottomClamped = Warningf("target below bottom of deck moved to bottom") + var WarningRecoverableBug = Warningf("cardsim library has a bug, but can keep going") + var WarningStalemate = errors.New("no actions can be taken") + var WarningTooFewCards = Warningf("too few cards") + var WarningTopClamped = Warningf("target above top of deck moved to top") + func DeleteFrom(slice []T, loc int) []T + func DeleteNFrom(slice []T, loc, n int) []T + func InsertInto(slice []T, loc int, elements ...T) []T + func IsSeriousError(e error) bool + func IsSpecialMessage(m Message, s *SpecialMessage) bool + func RunSimpleTerminalUI(p *Player[C]) error + func ShuffleAll(slice []T, r *rand.Rand) + func ShufflePart(slice []T, r *rand.Rand, loc, n int) + func SortStats(ss []Stat) + func Strip(slice []T, removeWhen func(idx int, t T) bool) []T + func VisibleOrDebug(p *Player[C], s Stat) bool + type BasicCard struct + AfterOption func(c Card[C], p *Player[C], option CardOption[C]) error + CardOptions []CardOption[C] + CardText Message + CardTitle Message + IsUrgent bool + func (b *BasicCard[C]) Drawn(_ *Player[C]) bool + func (b *BasicCard[C]) EventText(_ *Player[C]) (Message, error) + func (b *BasicCard[C]) Options(_ *Player[C]) ([]CardOption[C], error) + func (b *BasicCard[C]) Then(p *Player[C], option CardOption[C]) error + func (b *BasicCard[C]) Title(_ *Player[C]) Message + func (b *BasicCard[C]) Urgent(_ *Player[C]) bool + type BasicOption struct + Effect func(*Player[C]) error + Output Message + Text Message + func (b *BasicOption[C]) Enabled(p *Player[C]) bool + func (b *BasicOption[C]) Enact(p *Player[C]) (Message, error) + func (b *BasicOption[C]) OptionText(p *Player[C]) (Message, error) + type BasicStatsPanel struct + Filter StatFilter[C] + Intro Message + Name Message + func (b *BasicStatsPanel[C]) Info(p *Player[C]) ([]Message, error) + func (b *BasicStatsPanel[C]) Title(p *Player[C]) Message + type Card interface + Drawn func(p *Player[C]) bool + EventText func(p *Player[C]) (Message, error) + Options func(p *Player[C]) ([]CardOption[C], error) + Then func(p *Player[C], option CardOption[C]) error + Title func(p *Player[C]) Message + Urgent func(p *Player[C]) bool + type CardOption interface + Enabled func(p *Player[C]) bool + Enact func(p *Player[C]) (Message, error) + OptionText func(p *Player[C]) (Message, error) + func OptionFunc(text Message, f func(*Player[C]) (Message, error)) CardOption[C] + type Deck struct + func (d *Deck[C]) Draw() Card[C] + func (d *Deck[C]) DrawN(n int) ([]Card[C], error) + func (d *Deck[C]) Insert(idx int, card ...Card[C]) error + func (d *Deck[C]) InsertRandom(card Card[C]) error + func (d *Deck[C]) InsertRandomBottom(frac float64, card Card[C]) error + func (d *Deck[C]) InsertRandomRange(loFrac, hiFrac float64, card Card[C]) error + func (d *Deck[C]) InsertRandomTop(frac float64, card Card[C]) error + func (d *Deck[C]) Len() int + func (d *Deck[C]) Shuffle() error + func (d *Deck[C]) ShuffleBottom(frac float64) error + func (d *Deck[C]) ShufflePart(loc, n int) error + func (d *Deck[C]) ShuffleRange(loFrac, hiFrac float64) error + func (d *Deck[C]) ShuffleTop(frac float64) error + func (d *Deck[C]) Strip(shouldRemove func(idx int, c Card[C]) bool) int + type ErrorCollector struct + Errs []error + func (ec *ErrorCollector) Add(e error) + func (ec *ErrorCollector) Emit() error + func (ec *ErrorCollector) HasFailure() bool + func (ec *ErrorCollector) IsEmpty() bool + type Failure struct + func (f Failure) As(target any) bool + func (f Failure) Error() string + func (f Failure) Is(target error) bool + func (f Failure) Unwrap() error + type GameState int + func (g GameState) Over() bool + type InfoPanel interface + Info func(p *Player[C]) ([]Message, error) + Title func(p *Player[C]) Message + type Invisible struct + Name string + Value T + func (Invisible[T]) Visible() bool + func (i Invisible[T]) StatName() string + func (i Invisible[T]) String() string + type Message interface + func MsgStr(s string) Message + func Msgf(f string, args ...any) Message + type MultiMessage []Message + func (m MultiMessage) String() string + type Player struct + ActionsPerTurn int + ActionsRemaining int + DebugLevel int + Deck *Deck[C] + Hand []Card[C] + HandLimit int + InfoPanels []InfoPanel[C] + Name string + PermanentActions []Card[C] + Prompt InfoPanel[C] + Rand *rand.Rand + Rules *RuleCollection[C] + State GameState + Stats C + TemporaryMessages []Message + TemporaryPanels []InfoPanel[C] + TurnNumber int + func InitPlayer(stats C) *Player[C] + func (p *Player[C]) CanAct() bool + func (p *Player[C]) ChapterBreak() + func (p *Player[C]) Debug(minLevel int, msg Message) + func (p *Player[C]) Draw() error + func (p *Player[C]) Emit(msg Message) + func (p *Player[C]) EnactCard(cardIdx, choiceIdx int) (Message, error) + func (p *Player[C]) EnactCardUnchecked(cardIdx, choiceIdx int) (Message, error) + func (p *Player[C]) EnactPermanentAction(actionIdx, choiceIdx int) (Message, error) + func (p *Player[C]) EnactPermanentActionUnchecked(actionIdx, choiceIdx int) (Message, error) + func (p *Player[C]) FillHand() error + func (p *Player[C]) HasUrgentCards() bool + func (p *Player[C]) ReportError(e error) + func (p *Player[C]) SectionBreak() + func (p *Player[C]) Simulate() error + func (p *Player[C]) StartNextTurn() error + type Rule interface + Enact func(*Player[C]) error + Label func() string + Step func() int + type RuleCollection struct + func NewRuleCollection() *RuleCollection[C] + func (r *RuleCollection[C]) Insert(rule Rule[C]) RuleID + func (r *RuleCollection[C]) RemoveAllLabel(label string) int + func (r *RuleCollection[C]) RemoveAllStep(step int) int + func (r *RuleCollection[C]) RemoveID(id RuleID) bool + func (r *RuleCollection[C]) RemoveUniqueLabel(label string) (bool, error) + func (r *RuleCollection[C]) RemoveUniqueStep(step int) (bool, error) + func (r *RuleCollection[C]) Run(p *Player[C]) error + type RuleFunc struct + F func(*Player[C]) error + Name string + Seq int + func (r *RuleFunc[C]) Enact(p *Player[C]) error + func (r *RuleFunc[C]) Label() string + func (r *RuleFunc[C]) Step() int + type RuleID uint64 + type SpecialMessage struct + func (s *SpecialMessage) String() string + type Stat interface + StatName func() string + String func() string + Visible func() bool + func ExtractStats(x any) []Stat + func InvisibleStatFunc(name string, f func() T) Stat + func StatFunc(name string, f func() T) Stat + type StatFilter func(p *Player[C], s Stat) bool + func All(ff ...StatFilter[C]) StatFilter[C] + func Any(ff ...StatFilter[C]) StatFilter[C] + func StatsNamed(names ...string) StatFilter[C] + func VisibleOrDebugStatsNamed(names ...string) StatFilter[C] + type StatsCollection interface + Stats func() []Stat + type Stored struct + Name string + Value T + func (Stored[T]) Visible() bool + func (s Stored[T]) StatName() string + func (s Stored[T]) String() string + type Warning struct + E error + func Warningf(f string, args ...any) *Warning + func (*Warning) Is(target error) bool + func (w *Warning) Error() string + func (w *Warning) Unwrap() error