data

package
v0.1.1-0...-1ecdc53 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Communication

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

Communication implements (de)serialization of data for communication to the client via HTTP/JSON

func (Communication) StaticData

func (c Communication) StaticData(a app.App, plugins interface{}) interface{}

StaticData returns a serializable view of all static data (i.e. data that will never change during the execution of PnPScreen)

func (Communication) UpdateBaseConfig

func (c Communication) UpdateBaseConfig(raw []byte) server.Error

UpdateBaseConfig parses the given config as JSON and updates the config data

func (Communication) UpdateGroup

func (c Communication) UpdateGroup(raw []byte, g Group) server.Error

UpdateGroup updates a group's name and linked system from a given JSON input.

func (Communication) UpdateGroupConfig

func (c Communication) UpdateGroupConfig(raw []byte, g Group) server.Error

UpdateGroupConfig parses the given config as JSON and updates the internal config

func (Communication) UpdateHero

func (c Communication) UpdateHero(raw []byte, h groups.Hero) server.Error

UpdateHero updates a hero's name and description form a given JSON input.

func (Communication) UpdateScene

func (c Communication) UpdateScene(raw []byte, g Group, s Scene) server.Error

UpdateScene updates a scene's name

func (Communication) UpdateSceneConfig

func (c Communication) UpdateSceneConfig(raw []byte, s Scene) server.Error

UpdateSceneConfig parses the given JSON input and updates the scene's config

func (Communication) UpdateSystem

func (c Communication) UpdateSystem(raw []byte, s System) server.Error

UpdateSystem updates a system's name from a given JSON input.

func (Communication) UpdateSystemConfig

func (c Communication) UpdateSystemConfig(raw []byte, s System) server.Error

UpdateSystemConfig parses the given config as JSON and updates the internal config

func (Communication) ViewAll

func (c Communication) ViewAll(app app.App) shared.Data

ViewAll returns a serializable view of all data items that are not part of the state (systems, groups, scenes, heroes).

func (Communication) ViewBaseConfig

func (c Communication) ViewBaseConfig() interface{}

ViewBaseConfig returns a serializable view of the base configuration.

func (Communication) ViewGroupConfig

func (c Communication) ViewGroupConfig(g Group) interface{}

ViewGroupConfig returns a serializable view of the config of the given group

func (Communication) ViewGroups

func (c Communication) ViewGroups() interface{}

ViewGroups returns a serializable view of all groups, as it would be contained in Datasets.

func (Communication) ViewHeroes

func (c Communication) ViewHeroes(hl groups.HeroList) interface{}

ViewHeroes returns a serializable view of all heroes, as it would be contained in Datasets

func (Communication) ViewSceneConfig

func (c Communication) ViewSceneConfig(s Scene) interface{}

ViewSceneConfig returns a serializable view of the config of the given scene.

func (Communication) ViewSceneState

func (c Communication) ViewSceneState(a app.App) []json.RawMessage

ViewSceneState returns the current scene's serialized state

func (Communication) ViewScenes

func (c Communication) ViewScenes(g Group) interface{}

ViewScenes returns a serializable view of all scenes, as it would be contained in ViewAll.

func (Communication) ViewSystemConfig

func (c Communication) ViewSystemConfig(s System) (interface{},
	server.Error)

ViewSystemConfig returns a serializable view the config of the given system

func (Communication) ViewSystems

func (c Communication) ViewSystems() interface{}

ViewSystems returns a serializable view of all systems configs, as it would be contained in ViewAll.

type Data

type Data struct {
	State
	// contains filtered or unexported fields
}

Data contains all non-transient data currently loaded by PnpScreen

func (*Data) Group

func (d *Data) Group(index int) Group

Group returns the group at the given index, which must be between 0 (included) and NumGroups() (excluded).

func (*Data) GroupByID

func (d *Data) GroupByID(id string) (index int, value Group)

GroupByID returns the group with the given id, or nil if no such group exists.

func (*Data) LoadPersisted

func (d *Data) LoadPersisted(owner app.App) (Persistence, Communication)

LoadPersisted loads all config.yaml files and parses them according to the module's config types. Returns a Persistence value linked to the config that can be used to persist data into the file system, and a Communication value that (de)serializes data for client communication.

All errors are logged and erratic files ignored. You must call LoadPersisted before doing anything with a Config value.

func (*Data) MergeConfig

func (d *Data) MergeConfig(moduleIndex shared.ModuleIndex,
	systemIndex int, groupIndex int, sceneIndex int) interface{}

MergeConfig merges the item's default configuration with the values configured in its base config and the current system, group and scene config. It returns the resulting configuration.

systemIndex may be -1 (for groups without a defined system), groupIndex and sceneIndex may not.

func (*Data) NumGroups

func (d *Data) NumGroups() int

NumGroups returns the number of available groups.

func (*Data) NumPluginSystems

func (d *Data) NumPluginSystems() int

NumPluginSystems returns the number of systems required by plugins. these systems are always in front of the systems list.

func (*Data) NumSystems

func (d *Data) NumSystems() int

NumSystems returns the number of available systems.

func (*Data) System

func (d *Data) System(index int) System

System returns the system at the given index, which must be between 0 (included) and NumSystems() (excluded).

func (*Data) SystemByID

func (d *Data) SystemByID(id string) (index int, value System)

SystemByID returns the system with the given id, or nil if no such system exists.

type Group

type Group interface {
	groups.Group
	Name() string
	ID() string
	SystemIndex() int
	NumScenes() int
	Scene(index int) Scene
	SceneByID(id string) (index int, s Scene)
}

Group describes a Pen & Paper group / party

type Persistence

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

Persistence implements writing data to and loading data from the file system

func (Persistence) CreateGroup

func (p Persistence) CreateGroup(
	name string, tmpl *app.GroupTemplate, sceneTmpls []app.SceneTemplate) error

CreateGroup creates a new group with the given name, creating an alphanumeric ID from the name. It appends the group to the list of groups. The group's initial configuration is given via a GroupTemplate, which must not be nil.

func (Persistence) CreateHero

func (p Persistence) CreateHero(g Group, heroes groups.HeroList,
	name string, description string) error

CreateHero creates a new hero in the given group with the given name and description. It takes the heroes as separate parameter even though they are contained in the group, to ensure the caller locked the hero list.

func (Persistence) CreateScene

func (p Persistence) CreateScene(g Group, name string, tmpl *app.SceneTemplate) error

CreateScene creates a new scene from the given template in the given group.

func (Persistence) CreateSystem

func (p Persistence) CreateSystem(name string) server.Error

CreateSystem creates a new system with the given name.

func (Persistence) DeleteGroup

func (p Persistence) DeleteGroup(index int)

DeleteGroup deletes the group with the given ID.

func (Persistence) DeleteHero

func (p Persistence) DeleteHero(g Group, heroes groups.HeroList, index int) error

DeleteHero deletes the hero with the given index from the given group.

func (Persistence) DeleteScene

func (p Persistence) DeleteScene(g Group, index int) error

DeleteScene deletes the scene with the given id from the given group.

func (Persistence) DeleteSystem

func (p Persistence) DeleteSystem(index int) server.Error

DeleteSystem deletes the system with the given ID.

Groups linked to this system will have that link removed.

func (Persistence) LoadState

func (p Persistence) LoadState(g Group, path string) (*State, error)

LoadState loads the given YAML input into a State object and stores that into the linked data object.

func (Persistence) WriteBase

func (p Persistence) WriteBase() error

WriteBase writes the current base configuration to the file system.

func (Persistence) WriteGroup

func (p Persistence) WriteGroup(g Group) error

WriteGroup writes the group config to the file system.

func (Persistence) WriteHero

func (p Persistence) WriteHero(g Group, h groups.Hero) error

WriteHero writes the given hero of the given group to the file system

func (Persistence) WriteScene

func (p Persistence) WriteScene(g Group, s Scene) error

WriteScene writes the given scene of the given group to the file system.

func (Persistence) WriteState

func (p Persistence) WriteState()

WriteState writes the group state to its YAML file. The actual writing operation is done asynchronous.

func (Persistence) WriteSystem

func (p Persistence) WriteSystem(s System) error

WriteSystem writes the given system to the file system.

type Scene

type Scene interface {
	Name() string
	ID() string
	UsesModule(moduleIndex shared.ModuleIndex) bool
}

Scene describes a collection of modules that will be rendered together.

type State

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

State holds the complete state for the currently active group. whenever the current group changes, state must be reloaded from the state.yaml of the new group.

func (*State) ActiveScene

func (s *State) ActiveScene() int

ActiveScene returns the index of the currently active scene

func (*State) SetScene

func (s *State) SetScene(index int) server.Error

SetScene sets the scene index.

func (*State) StateOf

func (s *State) StateOf(moduleIndex shared.ModuleIndex) modules.State

StateOf returns the module state for the given module in the active scene

func (*State) StateOfScene

func (s *State) StateOfScene(
	sceneIndex int, moduleIndex shared.ModuleIndex) modules.State

StateOfScene returns the module state for the given module in the given scene

type System

type System interface {
	Name() string
	// ID returns the unique ID of this system.
	// This is the name of the system's data directory.
	ID() string
}

System describes a Pen & Paper system.

Jump to

Keyboard shortcuts

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