Documentation ¶
Index ¶
- type Communication
- func (c Communication) StaticData(a app.App, plugins interface{}) interface{}
- func (c Communication) UpdateBaseConfig(raw []byte) server.Error
- func (c Communication) UpdateGroup(raw []byte, g Group) server.Error
- func (c Communication) UpdateGroupConfig(raw []byte, g Group) server.Error
- func (c Communication) UpdateHero(raw []byte, h groups.Hero) server.Error
- func (c Communication) UpdateScene(raw []byte, g Group, s Scene) server.Error
- func (c Communication) UpdateSceneConfig(raw []byte, s Scene) server.Error
- func (c Communication) UpdateSystem(raw []byte, s System) server.Error
- func (c Communication) UpdateSystemConfig(raw []byte, s System) server.Error
- func (c Communication) ViewAll(app app.App) shared.Data
- func (c Communication) ViewBaseConfig() interface{}
- func (c Communication) ViewGroupConfig(g Group) interface{}
- func (c Communication) ViewGroups() interface{}
- func (c Communication) ViewHeroes(hl groups.HeroList) interface{}
- func (c Communication) ViewSceneConfig(s Scene) interface{}
- func (c Communication) ViewSceneState(a app.App) []json.RawMessage
- func (c Communication) ViewScenes(g Group) interface{}
- func (c Communication) ViewSystemConfig(s System) (interface{}, server.Error)
- func (c Communication) ViewSystems() interface{}
- type Data
- func (d *Data) Group(index int) Group
- func (d *Data) GroupByID(id string) (index int, value Group)
- func (d *Data) LoadPersisted(owner app.App) (Persistence, Communication)
- func (d *Data) MergeConfig(moduleIndex shared.ModuleIndex, systemIndex int, groupIndex int, ...) interface{}
- func (d *Data) NumGroups() int
- func (d *Data) NumPluginSystems() int
- func (d *Data) NumSystems() int
- func (d *Data) System(index int) System
- func (d *Data) SystemByID(id string) (index int, value System)
- type Group
- type Persistence
- func (p Persistence) CreateGroup(name string, tmpl *app.GroupTemplate, sceneTmpls []app.SceneTemplate) error
- func (p Persistence) CreateHero(g Group, heroes groups.HeroList, name string, description string) error
- func (p Persistence) CreateScene(g Group, name string, tmpl *app.SceneTemplate) error
- func (p Persistence) CreateSystem(name string) server.Error
- func (p Persistence) DeleteGroup(index int)
- func (p Persistence) DeleteHero(g Group, heroes groups.HeroList, index int) error
- func (p Persistence) DeleteScene(g Group, index int) error
- func (p Persistence) DeleteSystem(index int) server.Error
- func (p Persistence) LoadState(g Group, path string) (*State, error)
- func (p Persistence) WriteBase() error
- func (p Persistence) WriteGroup(g Group) error
- func (p Persistence) WriteHero(g Group, h groups.Hero) error
- func (p Persistence) WriteScene(g Group, s Scene) error
- func (p Persistence) WriteState()
- func (p Persistence) WriteSystem(s System) error
- type Scene
- type State
- type System
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 ¶
UpdateHero updates a hero's name and description form a given JSON input.
func (Communication) UpdateScene ¶
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 ¶
Group returns the group at the given index, which must be between 0 (included) and NumGroups() (excluded).
func (*Data) GroupByID ¶
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) NumPluginSystems ¶
NumPluginSystems returns the number of systems required by plugins. these systems are always in front of the systems list.
func (*Data) NumSystems ¶
NumSystems returns the number of available systems.
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 ¶
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 ¶
ActiveScene returns the index of the currently active scene
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 ¶
StateOfScene returns the module state for the given module in the given scene