game

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 37 Imported by: 0

README

Game

This is the core implementation of end_of_eden. This doesn't contain any ui code, as the base game logic and ui is fully seperated in this project.

Session

The Session type is the core of a running game session. It exposes a multitude of methods that are able to mutate the game state. By only exposing methods, calling them should mutate the session from one valid game state to another valid game state. The session will (with a few exceptions) only return copies of data and no pointer so that the consumer can't mutate the state without going through the right method call.

At the moment access to a Session is expected to be single-threaded!

session := game.NewSession(/* options */)

// interact with the session

Types

  • Artifact: Base definition for an artifact
  • Card: Base definition for a card
  • StatusEffect: Base definition for a status effect
  • Event: Base definition for an event
  • Enemy: Base definition for an enemy
  • StoryTeller: Base definition for an story teller
  • ArtifactInstance: Instance of an artifact that is owned by an Actor and references its base definition via the TypeID
  • CardInstance: Instance of a card that is owned by an Actor and references its base definition via the TypeID
  • StatusEffectInstance: Instance of a status effect that is owned by an Actor and references its base definition via the TypeID
  • Actor: Instance of either the player or an enemy. If it's an enemy the TypeID references its base definition

Checkpointing

Although the game code doesn't contain any ui there is a mechanism that helps ui and animations to react to events in the game. It is possible to create checkpoints of the game state, execute one or more operations that alter the game state and then get a diff of what happened.

In case we want to see if the enemy turn resulted in damage to the player we could use checkpoints:

// Store state checkpoint before operation
before := session.MarkState()

// Finish the player turn, which means that enemies are allowed to act
session.FinishPlayerTurn()

// Check if any damage was triggered
damages := before.DiffEvent(m.Session, game.StateEventDamage)
for i := range damages {
	// Do something with the damage data -> queue animation, play audio
}

This also makes it really easy to keep track of everything that happened in a fight, so that a re-cap screen can be shown. We just need to store the state at the beginning of the fight and diff it when it ends.

Documentation

Index

Constants

View Source
const (
	CallbackOnDamage        = "OnDamage"
	CallbackOnDamageCalc    = "OnDamageCalc"
	CallbackOnHealCalc      = "OnHealCalc"
	CallbackOnCast          = "OnCast"
	CallbackOnInit          = "OnInit"
	CallbackOnPickUp        = "OnPickUp"
	CallbackOnTurn          = "OnTurn"
	CallbackOnPlayerTurn    = "OnPlayerTurn"
	CallbackOnStatusAdd     = "OnStatusAdd"
	CallbackOnStatusStack   = "OnStatusStack"
	CallbackOnStatusRemove  = "OnStatusRemove"
	CallbackOnRemove        = "OnRemove"
	CallbackOnActorDie      = "OnActorDie"
	CallbackOnMerchantEnter = "OnMerchantEnter"
)
View Source
const (
	StateEventDeath  = StateEvent("Death")
	StateEventDamage = StateEvent("Damage")
	StateEventHeal   = StateEvent("Heal")
	StateEventMoney  = StateEvent("Money")
)
View Source
const (
	LogTypeInfo    = LogType("INFO")
	LogTypeWarning = LogType("WARNING")
	LogTypeDanger  = LogType("DANGER")
	LogTypeSuccess = LogType("SUCCESS")
)
View Source
const (
	GameStateFight    = GameState("FIGHT")
	GameStateMerchant = GameState("MERCHANT")
	GameStateEvent    = GameState("EVENT")
	GameStateRandom   = GameState("RANDOM")
	GameStateGameOver = GameState("GAME_OVER")
)
View Source
const (
	DefaultUpgradeCost = 65
	DefaultRemoveCost  = 50
	PointsPerRound     = 3
	DrawSize           = 3
)
View Source
const (
	DecayAll  = DecayBehaviour("DecayAll")
	DecayOne  = DecayBehaviour("DecayOne")
	DecayNone = DecayBehaviour("DecayNone")
)
View Source
const PlayerActorID = "PLAYER"

Variables

This section is empty.

Functions

func ExposeDebug

func ExposeDebug(port int, session *Session, l *lua.LState, log *log.Logger) func() error

func NewGuid

func NewGuid(tags ...string) string

func SessionAdapter

func SessionAdapter(session *Session) (*lua.LState, *ludoc.Docs)

SessionAdapter creates a lua vm that is bound to the session in the given Session.

func WithDebugEnabled

func WithDebugEnabled(port int) func(s *Session)

WithDebugEnabled enables the lua debugging. With lua debugging a server will be started on the given bind port. This exposes the /ws route to connect over websocket to. In essence, it exposes REPL access to the internal lua state which is helpful to debug problems. You can use the debug_r function to send data back to the websocket.

Tip: Use https://github.com/websockets/wscat to connect and talk with it.

func WithLogging

func WithLogging(logger *log.Logger) func(s *Session)

WithLogging sets the internal logger.

func WithMods

func WithMods(mods []string) func(s *Session)

func WithOnLuaError

func WithOnLuaError(fn func(file string, line int, callback string, typeId string, err error)) func(s *Session)

Types

type Actor

type Actor struct {
	GUID          string `lua:"guid"`
	TypeID        string
	Name          string
	Description   string
	HP            int
	MaxHP         int
	Gold          int
	Artifacts     *StringSet
	Cards         *StringSet
	StatusEffects *StringSet
}

Actor represents a player or enemy.

func NewActor

func NewActor(ID string) Actor

func (Actor) Clone

func (a Actor) Clone() Actor

func (Actor) IsNone

func (a Actor) IsNone() bool

func (Actor) Sanitize

func (a Actor) Sanitize() Actor

type Artifact

type Artifact struct {
	ID          string
	Name        string
	Description string
	Order       int
	Price       int
	Callbacks   map[string]luhelp.OwnedCallback
}

type ArtifactInstance

type ArtifactInstance struct {
	TypeID string
	GUID   string
	Owner  string
}

type Card

type Card struct {
	ID          string
	Name        string
	Description string
	State       luhelp.OwnedCallback
	Color       string
	PointCost   int
	MaxLevel    int
	DoesExhaust bool
	NeedTarget  bool
	Price       int
	Callbacks   map[string]luhelp.OwnedCallback
}

Card represents a playable card definition.

type CardInstance

type CardInstance struct {
	TypeID string
	GUID   string
	Level  int
	Owner  string
}

CardInstance represents an instance of a card owned by some actor.

func (CardInstance) IsNone

func (c CardInstance) IsNone() bool

type Context

type Context map[string]any

func CreateContext

func CreateContext(args ...any) Context

type DecayBehaviour

type DecayBehaviour string

type Enemy

type Enemy struct {
	ID          string
	Name        string
	Description string
	InitialHP   int
	MaxHP       int
	Look        string
	Color       string
	Intend      luhelp.OwnedCallback
	Callbacks   map[string]luhelp.OwnedCallback
}

Enemy represents a definition of a enemy that can be linked from a Actor.

type Event

type Event struct {
	ID          string
	Name        string
	Description string
	Choices     []EventChoice
	OnEnter     luhelp.OwnedCallback
	OnEnd       luhelp.OwnedCallback
}

Event represents a encounter-able event.

func (Event) IsNone

func (e Event) IsNone() bool

type EventChoice

type EventChoice struct {
	Description   string
	DescriptionFn luhelp.OwnedCallback
	Callback      luhelp.OwnedCallback
}

EventChoice represents a possible choice in the Event.

type FightState

type FightState struct {
	Round         int
	Description   string
	CurrentPoints int
	Deck          []string
	Hand          []string
	Used          []string
	Exhausted     []string
}

FightState represents the current state of the fight in regard to the deck of the player.

type GameState

type GameState string

type LogEntry

type LogEntry struct {
	Time    time.Time
	Type    LogType
	Message string
}

type LogType

type LogType string

type LuaError

type LuaError struct {
	File     string
	Line     int
	Callback string
	Type     string
	Err      error
}

type MerchantState

type MerchantState struct {
	Face      string
	Text      string
	Cards     []string
	Artifacts []string
}

type Mod

type Mod struct {
	Name        string `json:"name"`
	Author      string `json:"author"`
	Description string `json:"description"`
	Version     string `json:"version"`
	URL         string `json:"url"`
}

func ModDescription

func ModDescription(folder string) (Mod, error)

type ResourcesManager

type ResourcesManager struct {
	Artifacts     map[string]*Artifact
	Cards         map[string]*Card
	Events        map[string]*Event
	Enemies       map[string]*Enemy
	StatusEffects map[string]*StatusEffect
	StoryTeller   map[string]*StoryTeller
	// contains filtered or unexported fields
}

ResourcesManager can load Artifacts, Cards, Events, Enemy and StoryTeller data from lua. The manager will walk the ./scripts directory and evaluate all found .lua files.

func NewResourcesManager

func NewResourcesManager(state *lua.LState, docs *ludoc.Docs, logger *log.Logger) *ResourcesManager

type SavedState

type SavedState struct {
	State            GameState
	Actors           map[string]Actor
	Instances        map[string]any
	StagesCleared    int
	CurrentEvent     string
	CurrentFight     FightState
	Merchant         MerchantState
	EventHistory     []string
	StateCheckpoints []StateCheckpoint
	CtxData          map[string]any
	LoadedMods       []string
}

SavedState represents a save file that don't contain any pointer so the lua runtime or other pointer.

type Session

type Session struct {
	Logs []LogEntry
	// contains filtered or unexported fields
}

Session represents the state inside a game session.

func NewSession

func NewSession(options ...func(s *Session)) *Session

NewSession creates a new game session.

func (*Session) ActiveTeller

func (s *Session) ActiveTeller() *StoryTeller

ActiveTeller returns the active storyteller. The storyteller is responsible for deciding what enemies or events the player will encounter next.

func (*Session) ActorAddHP

func (s *Session) ActorAddHP(id string, val int)

func (*Session) ActorAddMaxHP

func (s *Session) ActorAddMaxHP(id string, val int)

func (*Session) AddActor

func (s *Session) AddActor(actor Actor)

func (*Session) AddActorFromEnemy

func (s *Session) AddActorFromEnemy(id string) string

func (*Session) AddMerchantArtifact

func (s *Session) AddMerchantArtifact()

AddMerchantArtifact adds another artifact to the wares of the merchant.

func (*Session) AddMerchantCard

func (s *Session) AddMerchantCard()

AddMerchantCard adds another card to the wares of the merchant.

func (*Session) AddStatusEffectStacks

func (s *Session) AddStatusEffectStacks(guid string, stacks int)

AddStatusEffectStacks increases the stacks of a certain status effect by guid.

func (*Session) BuyRemoveCard

func (s *Session) BuyRemoveCard(guid string) bool

func (*Session) BuyUpgradeCard

func (s *Session) BuyUpgradeCard(guid string) bool

func (*Session) CastCard

func (s *Session) CastCard(guid string, target string) bool

func (*Session) CleanUpFight

func (s *Session) CleanUpFight()

CleanUpFight resets the fight state.

func (*Session) Close

func (s *Session) Close()

Close closes the internal lua state and everything else.

func (*Session) DealDamage

func (s *Session) DealDamage(source string, target string, damage int, flat bool) int

func (*Session) DealDamageMulti

func (s *Session) DealDamageMulti(source string, targets []string, damage int, flat bool) []int

func (*Session) EnemyTurn

func (s *Session) EnemyTurn()

func (*Session) Fetch

func (s *Session) Fetch(key string) any

func (*Session) FinishEvent

func (s *Session) FinishEvent(choice int)

FinishEvent finishes an event with the given choice. If the game state is not in the EVENT state this does nothing.

func (*Session) FinishFight

func (s *Session) FinishFight() bool

FinishFight tries to finish the fight. This will return true if the fight is really over.

func (*Session) FinishPlayerTurn

func (s *Session) FinishPlayerTurn()

FinishPlayerTurn signals that the player is done with its turn. All enemies act now, status effects are evaluated, if the fight is over is checked and if not this will advance to the next round and draw cards for the player.

func (*Session) GetActor

func (s *Session) GetActor(id string) Actor

func (*Session) GetActorIntend

func (s *Session) GetActorIntend(guid string) string

func (*Session) GetActorStatusEffects

func (s *Session) GetActorStatusEffects(guid string) []string

GetActorStatusEffects returns the guids of all the status effects a certain actor owns.

func (*Session) GetActors

func (s *Session) GetActors() []string

func (*Session) GetArtifact

func (s *Session) GetArtifact(guid string) (*Artifact, ArtifactInstance)

GetArtifact returns an artifact, and instance by guid or type id. If a type id is given only the Artifact will be returned.

func (*Session) GetArtifactOrder

func (s *Session) GetArtifactOrder(guid string) int

GetArtifactOrder returns the order value of a certain artifact by guid.

func (*Session) GetArtifacts

func (s *Session) GetArtifacts(owner string) []string

GetArtifacts returns all artifacts owned by a actor.

func (*Session) GetCard

func (s *Session) GetCard(guid string) (*Card, CardInstance)

func (*Session) GetCardState

func (s *Session) GetCardState(guid string) string

func (*Session) GetCards

func (s *Session) GetCards(owner string) []string

func (*Session) GetEnemy

func (s *Session) GetEnemy(typeId string) *Enemy

func (*Session) GetEvent

func (s *Session) GetEvent() *Event

GetEvent returns the event definition of the current event. Will be nil if no event is present. It is not allowed to change the Event data, as this points to the event data created in lua!

func (*Session) GetEventChoiceDescription

func (s *Session) GetEventChoiceDescription(i int) string

func (*Session) GetEventHistory

func (s *Session) GetEventHistory() []string

GetEventHistory returns the ordered list of all events encountered so far.

func (*Session) GetFight

func (s *Session) GetFight() FightState

GetFight returns the fight state. This will return a fight state even if no fight is active at the moment.

func (*Session) GetFightRound

func (s *Session) GetFightRound() int

GetFightRound returns the current round of the fight.

func (*Session) GetFormerState

func (s *Session) GetFormerState(index int) *Session

GetFormerState iterates backwards over the states, so index == -1 means the last state and so on.

func (*Session) GetGameState

func (s *Session) GetGameState() GameState

GetGameState returns the current game state.

func (*Session) GetInstance

func (s *Session) GetInstance(guid string) any

GetInstance returns an instance by guid. An instance is a CardInstance or ArtifactInstance.

func (*Session) GetInstances

func (s *Session) GetInstances() []string

func (*Session) GetLoadedMods

func (s *Session) GetLoadedMods() []string

func (*Session) GetMerchant

func (s *Session) GetMerchant() MerchantState

GetMerchant return the merchant state.

func (*Session) GetMerchantGoldMax

func (s *Session) GetMerchantGoldMax() int

GetMerchantGoldMax returns what the max cost of a artifact or card is that the merchant might offer.

func (*Session) GetOpponentByIndex

func (s *Session) GetOpponentByIndex(viewpoint string, i int) Actor

func (*Session) GetOpponentCount

func (s *Session) GetOpponentCount(viewpoint string) int

func (*Session) GetOpponentGUIDs

func (s *Session) GetOpponentGUIDs(viewpoint string) []string

func (*Session) GetOpponents

func (s *Session) GetOpponents(viewpoint string) []Actor

func (*Session) GetPlayer

func (s *Session) GetPlayer() Actor

func (*Session) GetRandomArtifact

func (s *Session) GetRandomArtifact(maxGold int) string

GetRandomArtifact returns the type id of a random artifact with a price lower than the given value.

func (*Session) GetRandomArtifactType

func (s *Session) GetRandomArtifactType(maxPrice int) string

GetRandomArtifactType returns a random artifact type with a given max price.

func (*Session) GetRandomCard

func (s *Session) GetRandomCard(maxGold int) string

GetRandomCard returns the type id of a random card with a price lower than the given value.

func (*Session) GetResources

func (s *Session) GetResources() *ResourcesManager

func (*Session) GetStagesCleared

func (s *Session) GetStagesCleared() int

GetStagesCleared returns the amount of stages cleared so far. Each fight represent a stage.

func (*Session) GetStatusEffect

func (s *Session) GetStatusEffect(guid string) *StatusEffect

GetStatusEffect returns status effect by guid.

func (*Session) GetStatusEffectInstance

func (s *Session) GetStatusEffectInstance(guid string) StatusEffectInstance

GetStatusEffectInstance returns status effect instance by guid.

func (*Session) GetStatusEffectOrder

func (s *Session) GetStatusEffectOrder(guid string) int

GetStatusEffectOrder returns the order value of a status effect by guid.

func (*Session) GetStatusEffectState

func (s *Session) GetStatusEffectState(guid string) string

GetStatusEffectState returns the rendered state of the status effect.

func (*Session) GiveArtifact

func (s *Session) GiveArtifact(typeId string, owner string) string

GiveArtifact gives an artifact to an actor.

func (*Session) GiveCard

func (s *Session) GiveCard(typeId string, owner string) string

func (*Session) GivePlayerGold

func (s *Session) GivePlayerGold(amount int)

func (*Session) GiveStatusEffect

func (s *Session) GiveStatusEffect(typeId string, owner string, stacks int) string

GiveStatusEffect gives the owner a status effect of a certain type. Status effects are singleton per actor, so if the actor already has the status effect the stacks will be increased.

func (*Session) GobDecode

func (s *Session) GobDecode(data []byte) error

func (*Session) GobEncode

func (s *Session) GobEncode() ([]byte, error)

func (*Session) HadEvent

func (s *Session) HadEvent(id string) bool

HadEvent checks if the given event already happened in this run.

func (*Session) HadEvents

func (s *Session) HadEvents(ids []string) bool

HadEvents checks if the given events already happened in this run.

func (*Session) HadEventsAny

func (s *Session) HadEventsAny(ids []string) bool

HadEventsAny checks if at least one of the given events already happened in this run.

func (*Session) Heal

func (s *Session) Heal(source string, target string, heal int, flat bool) int

func (*Session) LeaveMerchant

func (s *Session) LeaveMerchant()

LeaveMerchant finishes the merchant state and lets the storyteller decide what to do next.

func (*Session) LetTellerDecide

func (s *Session) LetTellerDecide()

LetTellerDecide lets the currently active storyteller decide what the next game state will be.

func (*Session) LoadSavedState

func (s *Session) LoadSavedState(save SavedState)

LoadSavedState applies a saved state to the session. This will overwrite all game related data, but not the lua state, logging etc. This also means that for a save file to work the same lua scripts should be loaded or the state could be corrupted.

func (*Session) Log

func (s *Session) Log(t LogType, msg string)

func (*Session) LuaDocs

func (s *Session) LuaDocs() *ludoc.Docs

func (*Session) LuaErrors

func (s *Session) LuaErrors() chan LuaError

func (*Session) MarkState

func (s *Session) MarkState() StateCheckpointMarker

MarkState creates a checkpoint of the session state that can be used to diff and see what happened between two points in time.

func (*Session) PlayerBuyArtifact

func (s *Session) PlayerBuyArtifact(t string) bool

PlayerBuyArtifact buys the artifact with the given type id. The artifact needs to be in the wares of the merchant.

func (*Session) PlayerBuyCard

func (s *Session) PlayerBuyCard(t string) bool

PlayerBuyCard buys the card with the given type id. The card needs to be in the wares of the merchant.

func (*Session) PlayerCastHand

func (s *Session) PlayerCastHand(i int, target string) error

func (*Session) PlayerDrawCard

func (s *Session) PlayerDrawCard(amount int)

func (*Session) PlayerGiveActionPoints

func (s *Session) PlayerGiveActionPoints(amount int)

func (*Session) PushState

func (s *Session) PushState(events map[StateEvent]any)

PushState pushes a new state to the session. New states are relevant information like damage done, money received, actor death etc.

func (*Session) RemoveActor

func (s *Session) RemoveActor(id string)

func (*Session) RemoveAllStatusEffects

func (s *Session) RemoveAllStatusEffects()

RemoveAllStatusEffects clears all present status effects.

func (*Session) RemoveArtifact

func (s *Session) RemoveArtifact(guid string)

RemoveArtifact removes a artifact by guid.

func (*Session) RemoveCard

func (s *Session) RemoveCard(guid string)

func (*Session) RemoveNonPlayer

func (s *Session) RemoveNonPlayer()

func (*Session) RemoveStatusEffect

func (s *Session) RemoveStatusEffect(guid string)

RemoveStatusEffect removes a status effect by guid.

func (*Session) SetEvent

func (s *Session) SetEvent(id string)

SetEvent changes the active event, but won't set the game state to EVENT. So this can be used to set the next event even before a fight or merchant interaction is over.

func (*Session) SetFightDescription

func (s *Session) SetFightDescription(description string)

SetFightDescription sets the description of the fight.

func (*Session) SetGameState

func (s *Session) SetGameState(state GameState)

SetGameState sets the game state and applies all needed setups for the new state to be valid.

func (*Session) SetOnLuaError

func (s *Session) SetOnLuaError(fn func(file string, line int, callback string, typeId string, err error))

func (*Session) SetStatusEffectStacks

func (s *Session) SetStatusEffectStacks(guid string, stacks int)

SetStatusEffectStacks sets the stacks of a certain status effect by guid.

func (*Session) SetupFight

func (s *Session) SetupFight()

SetupFight setups the fight state, which means removing all leftover status effects, cleaning the state drawing the initial hand size and trigger the first wave of OnPlayerTurn callbacks.

Additionally, this will create a save file as this is a clean state to save.

func (*Session) SetupMerchant

func (s *Session) SetupMerchant()

SetupMerchant sets up the merchant, which means generating a new face, text and initial wares.

func (*Session) Store

func (s *Session) Store(key string, value any)

func (*Session) ToSVG

func (s *Session) ToSVG() ([]byte, string, error)

ToSVG creates an SVG representation from the internal state. The returned string is the d2 representation of the SVG (https://d2lang.com/).

func (*Session) ToSavedState

func (s *Session) ToSavedState() SavedState

ToSavedState creates a saved state of the session that can be serialized with Gob.

func (*Session) TraverseArtifactsStatus

func (s *Session) TraverseArtifactsStatus(guids []string, artifact func(instance ArtifactInstance, artifact *Artifact), status func(instance StatusEffectInstance, statusEffect *StatusEffect))

func (*Session) TriggerOnActorDie

func (s *Session) TriggerOnActorDie(guids []string, source string, target string, damage int)

func (*Session) TriggerOnDamage

func (s *Session) TriggerOnDamage(guids []string, source string, target string, damage int)

func (*Session) TriggerOnDamageCalc

func (s *Session) TriggerOnDamageCalc(guids []string, source string, target string, damage int) int

func (*Session) TriggerOnPlayerTurn

func (s *Session) TriggerOnPlayerTurn()

func (*Session) UpdateActor

func (s *Session) UpdateActor(id string, update func(actor *Actor) bool)

func (*Session) UpdatePlayer

func (s *Session) UpdatePlayer(update func(actor *Actor) bool)

func (*Session) UpgradeCard

func (s *Session) UpgradeCard(guid string) bool

func (*Session) UpgradeRandomCard

func (s *Session) UpgradeRandomCard(owner string) bool

type StateCheckpoint

type StateCheckpoint struct {
	Session *Session

	// Events describe the events that
	Events map[StateEvent]any
}

StateCheckpoint saves the state of a session at a certain point. This can be used to retroactively check what happened between certain actions.

type StateCheckpointMarker

type StateCheckpointMarker struct {
	// contains filtered or unexported fields
}

StateCheckpointMarker is a saved state of a checkpoint log.

func (StateCheckpointMarker) Diff

func (sm StateCheckpointMarker) Diff(session *Session) []StateCheckpoint

Diff returns the new states that happened between the marker and a new session.

func (StateCheckpointMarker) DiffEvent

func (sm StateCheckpointMarker) DiffEvent(session *Session, event StateEvent) []StateCheckpoint

DiffEvent returns the new states that happened between the marker and a new session that contain a certain event.

type StateEvent

type StateEvent string

type StateEventDamageData

type StateEventDamageData struct {
	Source string
	Target string
	Damage int
}

type StateEventDeathData

type StateEventDeathData struct {
	Source string
	Target string
	Damage int
}

type StateEventHealData

type StateEventHealData struct {
	Target string
	Damage int
}

type StateEventMoneyData

type StateEventMoneyData struct {
	Target string
	Money  int
}

type StatusEffect

type StatusEffect struct {
	ID          string
	Name        string
	Description string
	State       luhelp.OwnedCallback
	Look        string
	Foreground  string
	Order       int
	CanStack    bool
	Decay       DecayBehaviour
	Rounds      int
	Callbacks   map[string]luhelp.OwnedCallback
}

type StatusEffectInstance

type StatusEffectInstance struct {
	GUID       string
	TypeID     string
	Owner      string
	Stacks     int
	RoundsLeft int
}

type StoryTeller

type StoryTeller struct {
	ID     string
	Active luhelp.OwnedCallback
	Decide luhelp.OwnedCallback
}

type StringSet

type StringSet struct {
	// contains filtered or unexported fields
}

StringSet represents a string set that can be serialized by Gob.

Note: As the GobDecode needs to overwrite its receiver we need to have the map behind a struct pointer.

func NewStringSet

func NewStringSet() *StringSet

func (*StringSet) Add

func (s *StringSet) Add(val string)

func (*StringSet) Append

func (s *StringSet) Append(vals ...string)

func (*StringSet) Clear

func (s *StringSet) Clear()

func (*StringSet) Clone

func (s *StringSet) Clone() *StringSet

func (*StringSet) GobDecode

func (s *StringSet) GobDecode(data []byte) error

func (*StringSet) GobEncode

func (s *StringSet) GobEncode() ([]byte, error)

func (*StringSet) Has

func (s *StringSet) Has(val string) bool

func (*StringSet) Remove

func (s *StringSet) Remove(val string)

func (*StringSet) ToSlice

func (s *StringSet) ToSlice() []string

Jump to

Keyboard shortcuts

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