gurps

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MPL-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockLayoutReactionsKey            = "reactions"
	BlockLayoutConditionalModifiersKey = "conditional_modifiers"
	BlockLayoutMeleeKey                = "melee"
	BlockLayoutRangedKey               = "ranged"
	BlockLayoutTraitsKey               = "traits"
	BlockLayoutSkillsKey               = "skills"
	BlockLayoutSpellsKey               = "spells"
	BlockLayoutEquipmentKey            = "equipment"
	BlockLayoutOtherEquipmentKey       = "other_equipment"
	BlockLayoutNotesKey                = "notes"
)

Valid block layout keys

View Source
const (
	ConditionalModifierValueColumn = iota
	ConditionalModifierDescriptionColumn
)

Columns that can be used with the conditional modifier method .CellData()

View Source
const (
	EquipmentEquippedColumn = iota
	EquipmentQuantityColumn
	EquipmentDescriptionColumn
	EquipmentUsesColumn
	EquipmentMaxUsesColumn
	EquipmentTLColumn
	EquipmentLCColumn
	EquipmentCostColumn
	EquipmentExtendedCostColumn
	EquipmentWeightColumn
	EquipmentExtendedWeightColumn
	EquipmentTagsColumn
	EquipmentReferenceColumn
)

Columns that can be used with the equipment method .CellData()

View Source
const (
	EquipmentModifierEnabledColumn = iota
	EquipmentModifierDescriptionColumn
	EquipmentModifierTechLevelColumn
	EquipmentModifierCostColumn
	EquipmentModifierWeightColumn
	EquipmentModifierTagsColumn
	EquipmentModifierReferenceColumn
)

Columns that can be used with the equipment modifier method .CellData()

View Source
const (
	NoteTextColumn = iota
	NoteReferenceColumn
)

Columns that can be used with the note method .CellData()

View Source
const (
	PortraitHeight = 96
	PortraitWidth  = 3 * PortraitHeight / 4
)

Standard height and width for the portrait

View Source
const (
	SkillDescriptionColumn = iota
	SkillDifficultyColumn
	SkillTagsColumn
	SkillReferenceColumn
	SkillLevelColumn
	SkillRelativeLevelColumn
	SkillPointsColumn
)

Columns that can be used with the skill method .CellData()

View Source
const (
	SpellDescriptionColumn = iota
	SpellResistColumn
	SpellClassColumn
	SpellCollegeColumn
	SpellCastCostColumn
	SpellMaintainCostColumn
	SpellCastTimeColumn
	SpellDurationColumn
	SpellDifficultyColumn
	SpellTagsColumn
	SpellReferenceColumn
	SpellLevelColumn
	SpellRelativeLevelColumn
	SpellPointsColumn
	SpellDescriptionForPageColumn
)

Columns that can be used with the spell method .CellData()

View Source
const (
	TraitDescriptionColumn = iota
	TraitPointsColumn
	TraitTagsColumn
	TraitReferenceColumn
)

Columns that can be used with the trait method .CellData()

View Source
const (
	TraitModifierEnabledColumn = iota
	TraitModifierDescriptionColumn
	TraitModifierCostColumn
	TraitModifierTagsColumn
	TraitModifierReferenceColumn
)

Columns that can be used with the trait modifier method .CellData()

View Source
const (
	WeaponDescriptionColumn = iota
	WeaponUsageColumn
	WeaponSLColumn
	WeaponParryColumn
	WeaponBlockColumn
	WeaponDamageColumn
	WeaponReachColumn
	WeaponSTColumn
	WeaponAccColumn
	WeaponRangeColumn
	WeaponRoFColumn
	WeaponShotsColumn
	WeaponBulkColumn
	WeaponRecoilColumn
)

Columns that can be used with the weapon method .CellData()

View Source
const ContainerKeyPostfix = "_container"

ContainerKeyPostfix is the key postfix used to identify containers.

View Source
const PageRefCellAlias = -10

PageRefCellAlias is used an alias to request the page reference cell, if any.

Variables

View Source
var (
	NoAdditionalModifiers = i18n.Text("No additional modifiers")
	IncludesModifiersFrom = i18n.Text("Includes modifiers from")
	PageRefTooltipText    = i18n.Text(`A reference to the book and page the item appears on e.g. B22 would refer to "Basic Set", page 22`)
)

String constants

View Source
var (
	// TechLevelInfo holds the general TL age list
	TechLevelInfo = i18n.Text(`TL0: Stone Age (Prehistory)
TL1: Bronze Age (3500 B.C.+)
TL2: Iron Age (1200 B.C.+)
TL3: Medieval (600 A.D.+)
TL4: Age of Sail (1450+)
TL5: Industrial Revolution (1730+)
TL6: Mechanized Age (1880+)
TL7: Nuclear Age (1940+)
TL8: Digital Age (1980+)
TL9: Microtech Age (2025+?)
TL10: Robotic Age (2070+?)
TL11: Age of Exotic Matter
TL12: Anything Goes`)

	// LegalityClassInfo holds the LC list
	LegalityClassInfo = i18n.Text(`LC0: Banned
LC1: Military
LC2: Restricted
LC3: Licensed
LC4: Open`)
)
View Source
var (
	// AllCellType holds all possible values.
	AllCellType = []CellType{
		Text,
		Tags,
		Toggle,
		PageRef,
	}
)
View Source
var (
	// AllSelfControlRollAdj holds all possible values.
	AllSelfControlRollAdj = []SelfControlRollAdj{
		NoCRAdj,
		ActionPenalty,
		ReactionPenalty,
		FrightCheckPenalty,
		FrightCheckBonus,
		MinorCostOfLivingIncrease,
		MajorCostOfLivingIncrease,
	}
)
View Source
var (
	// AllStudyType holds all possible values.
	AllStudyType = []StudyType{
		SelfStudyType,
		JobStudyType,
		TeacherStudyType,
		IntensiveStudyType,
	}
)
View Source
var (
	// AllTemplatePickerType holds all possible values.
	AllTemplatePickerType = []TemplatePickerType{
		NotApplicableTemplatePickerType,
		CountTemplatePickerType,
		PointsTemplatePickerType,
	}
)

ReservedIDs holds a list of IDs that are reserved for internal use.

View Source
var SettingsProvider interface {
	GeneralSettings() *settings.General
	SheetSettings() *SheetSettings
	Libraries() library.Libraries
}

SettingsProvider must be initialized prior to using this package. It provides access to settings to avoid circular references.

Functions

func AdjustTechLevel

func AdjustTechLevel(str string, delta fxp.Int) (s string, changed bool)

AdjustTechLevel returns a new string with the adjusted tech level.

func AdjustedPoints

func AdjustedPoints(entity *Entity, canLevel bool, basePoints, levels, pointsPerLevel fxp.Int, cr trait.SelfControlRoll, modifiers []*TraitModifier, roundCostDown bool) fxp.Int

AdjustedPoints returns the total points, taking levels and modifiers into account. 'entity' may be nil.

func AdjustedPointsForNonContainerSkillOrTechnique

func AdjustedPointsForNonContainerSkillOrTechnique(entity *Entity, points fxp.Int, name, specialization string, tags []string, tooltip *xio.ByteBuffer) fxp.Int

AdjustedPointsForNonContainerSkillOrTechnique returns the points, adjusted for any bonuses.

func AdjustedPointsForNonContainerSpell

func AdjustedPointsForNonContainerSpell(entity *Entity, points fxp.Int, name, powerSource string, colleges, tags []string, tooltip *xio.ByteBuffer) fxp.Int

AdjustedPointsForNonContainerSpell returns the points, adjusted for any bonuses.

func AttributeChoices

func AttributeChoices(entity *Entity, prefix string, flags AttributeFlags, currentKey string) (choices []*AttributeChoice, current *AttributeChoice)

AttributeChoices collects the available choices for attributes for the given entity, or nil.

func AttributeIDFor

func AttributeIDFor(entity *Entity, preferred string) string

AttributeIDFor looks up the preferred ID and if it cannot be found, falls back to a default. 'entity' may be nil.

func CalculateRitualMagicSpellLevel

func CalculateRitualMagicSpellLevel(entity *Entity, name, powerSource, ritualSkillName string, ritualPrereqCount int, colleges, tags []string, difficulty AttributeDifficulty, points fxp.Int) skill.Level

CalculateRitualMagicSpellLevel returns the calculated spell level.

func CalculateSkillLevel

func CalculateSkillLevel(entity *Entity, name, specialization string, tags []string, def *SkillDefault, difficulty AttributeDifficulty, points, encumbrancePenaltyMultiplier fxp.Int) skill.Level

CalculateSkillLevel returns the calculated level for a skill.

func CalculateSpellLevel

func CalculateSpellLevel(entity *Entity, name, powerSource string, colleges, tags []string, difficulty AttributeDifficulty, pts fxp.Int) skill.Level

CalculateSpellLevel returns the calculated spell level.

func CalculateTechniqueLevel

func CalculateTechniqueLevel(entity *Entity, name, specialization string, tags []string, def *SkillDefault, difficulty skill.Difficulty, points fxp.Int, requirePoints bool, limitModifier *fxp.Int) skill.Level

CalculateTechniqueLevel returns the calculated level for a technique.

func CloneNodes

func CloneNodes[T NodeTypes](newEntity *Entity, newParent T, preserveID bool, nodes []Node[T]) []T

CloneNodes creates clones of the provided nodes.

func CombineTags

func CombineTags(tags []string) string

CombineTags combines multiple tags into a single string.

func CountThresholdOpMet

func CountThresholdOpMet(op attribute.ThresholdOp, attributes *Attributes) int

CountThresholdOpMet counts the number of times the given ThresholdOp is met.

func CreateFullKeySet

func CreateFullKeySet() map[string]bool

CreateFullKeySet creates a map that contains each of the possible block layout keys.

func DefaultAttributeIDFor

func DefaultAttributeIDFor(entity *Entity) string

DefaultAttributeIDFor returns the default attribute ID to use for the given Entity, which may be nil.

func ExtendedWeightAdjustedForModifiers

func ExtendedWeightAdjustedForModifiers(defUnits measure.WeightUnits, qty fxp.Int, baseWeight measure.Weight, modifiers []*EquipmentModifier, features feature.Features, children []*Equipment, forSkills, weightIgnoredForSkills bool) measure.Weight

ExtendedWeightAdjustedForModifiers calculates the extended weight.

func ExtractTags

func ExtractTags(tags string) []string

ExtractTags from a combined tags string.

func ExtractTechLevel

func ExtractTechLevel(str string) (techLevel fxp.Int, start, end int)

ExtractTechLevel extracts the first number it finds in the string and returns that as the tech level. The start and end (inclusive) indexes within the string where the number resided are returned, but will be -1 if the string didn't contain a resolvable number. The returned tech level will be clamped to the range 0 to 12.

func FormatRelativeSkill

func FormatRelativeSkill(entity *Entity, typ string, difficulty AttributeDifficulty, rsl fxp.Int) string

FormatRelativeSkill formats the relative skill for display.

func HasTag

func HasTag(tag string, tags []string) bool

HasTag returns true if 'tag' is present in 'tags'. This check both ignores case and can check for subsets that are colon-separated.

func HasText

func HasText(has bool) string

HasText returns the appropriate text for has.

func HitLocationChoices

func HitLocationChoices(entity *Entity, prefix, currentKey string) (choices []*HitLocationChoice, current *HitLocationChoice)

HitLocationChoices collects the available choices for hit locations for the given entity, or nil.

func InstallEvaluatorFunctions

func InstallEvaluatorFunctions(m map[string]eval.Function)

InstallEvaluatorFunctions installs additional functions for the evaluator.

func IsThresholdOpMet

func IsThresholdOpMet(op attribute.ThresholdOp, attributes *Attributes) bool

IsThresholdOpMet if the given ThresholdOp is met.

func ReplaceTechLevel

func ReplaceTechLevel(str string, value fxp.Int) string

ReplaceTechLevel replaces the tech level (as found by a call to ExtractTechLevel) with a new value.

func ResolveAttributeName

func ResolveAttributeName(entity *Entity, attribute string) string

ResolveAttributeName returns the name of the attribute, if possible.

func ResolveStudyHours added in v5.3.0

func ResolveStudyHours(study []*Study) fxp.Int

ResolveStudyHours returns the resolved total study hours.

func SaveEquipment

func SaveEquipment(equipment []*Equipment, filePath string) error

SaveEquipment writes the Equipment list to the file as JSON.

func SaveEquipmentModifiers

func SaveEquipmentModifiers(modifiers []*EquipmentModifier, filePath string) error

SaveEquipmentModifiers writes the EquipmentModifier list to the file as JSON.

func SaveNotes

func SaveNotes(notes []*Note, filePath string) error

SaveNotes writes the Note list to the file as JSON.

func SaveSkills

func SaveSkills(skills []*Skill, filePath string) error

SaveSkills writes the Skill list to the file as JSON.

func SaveSpells

func SaveSpells(spells []*Spell, filePath string) error

SaveSpells writes the Spell list to the file as JSON.

func SaveTraitModifiers

func SaveTraitModifiers(modifiers []*TraitModifier, filePath string) error

SaveTraitModifiers writes the TraitModifier list to the file as JSON.

func SaveTraits

func SaveTraits(traits []*Trait, filePath string) error

SaveTraits writes the Trait list to the file as JSON.

func StudyHoursProgressText added in v5.3.0

func StudyHoursProgressText(hours fxp.Int) string

StudyHoursProgressText returns the progress text or an empty string.

func Traverse

func Traverse[T NodeTypes](f func(T) bool, onlyEnabled, excludeContainers bool, in ...T)

Traverse calls the function 'f' for each node and its children in the input list, recursively. Return true from the function to abort early. If excludeContainers is true, then nodes that are containers will not be passed to 'f', although their children will still be processed as usual.

func ValueAdjustedForModifiers

func ValueAdjustedForModifiers(value fxp.Int, modifiers []*EquipmentModifier) fxp.Int

ValueAdjustedForModifiers returns the value after adjusting it for a set of modifiers.

func WeightAdjustedForModifiers

func WeightAdjustedForModifiers(weight measure.Weight, modifiers []*EquipmentModifier, defUnits measure.WeightUnits) measure.Weight

WeightAdjustedForModifiers returns the weight after adjusting it for a set of modifiers.

Types

type Attribute

type Attribute struct {
	AttributeData
	Entity        *Entity `json:"-"`
	Bonus         fxp.Int `json:"-"`
	CostReduction fxp.Int `json:"-"`
	Order         int     `json:"-"`
}

Attribute holds the current state of an AttributeDef.

func NewAttribute

func NewAttribute(entity *Entity, attrID string, order int) *Attribute

NewAttribute creates a new Attribute.

func (*Attribute) AttributeDef

func (a *Attribute) AttributeDef() *AttributeDef

AttributeDef looks up the AttributeDef this Attribute references from the Entity. May return nil.

func (*Attribute) Clone

func (a *Attribute) Clone(entity *Entity) *Attribute

Clone a copy of this.

func (*Attribute) Current

func (a *Attribute) Current() fxp.Int

Current returns the current value. Same as .Maximum() if not a pool.

func (*Attribute) CurrentThreshold

func (a *Attribute) CurrentThreshold() *PoolThreshold

CurrentThreshold return the current PoolThreshold, if any.

func (*Attribute) ID

func (a *Attribute) ID() string

ID returns the ID.

func (*Attribute) MarshalJSON

func (a *Attribute) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Attribute) Maximum

func (a *Attribute) Maximum() fxp.Int

Maximum returns the maximum value of a pool or the adjusted attribute value for other types.

func (*Attribute) PointCost

func (a *Attribute) PointCost() fxp.Int

PointCost returns the number of points spent on this Attribute.

func (*Attribute) SetID

func (a *Attribute) SetID(value string)

SetID sets the ID, sanitizing it in the process (i.e. it may be changed from what you set -- read it back if you want to be sure of what it gets set to.

func (*Attribute) SetMaximum

func (a *Attribute) SetMaximum(value fxp.Int)

SetMaximum sets the maximum value.

func (*Attribute) UnmarshalJSON

func (a *Attribute) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type AttributeChoice

type AttributeChoice struct {
	Key   string
	Title string
}

AttributeChoice holds a single attribute choice.

func (*AttributeChoice) String

func (c *AttributeChoice) String() string

type AttributeData

type AttributeData struct {
	AttrID     string  `json:"attr_id"`
	Adjustment fxp.Int `json:"adj"`
	Damage     fxp.Int `json:"damage,omitempty"`
}

AttributeData holds the Attribute data that is written to disk.

type AttributeDef

type AttributeDef struct {
	AttributeDefData
	Order     int
	KeyPrefix string
}

AttributeDef holds the definition of an attribute.

func (*AttributeDef) BaseValue

func (a *AttributeDef) BaseValue(resolver eval.VariableResolver) fxp.Int

BaseValue returns the resolved base value.

func (*AttributeDef) Clone

func (a *AttributeDef) Clone() *AttributeDef

Clone a copy of this.

func (*AttributeDef) CombinedName

func (a *AttributeDef) CombinedName() string

CombinedName returns the combined FullName and Name, as appropriate.

func (*AttributeDef) ComputeCost

func (a *AttributeDef) ComputeCost(entity *Entity, value, costReduction fxp.Int, sizeModifier int) fxp.Int

ComputeCost returns the value adjusted for a cost reduction.

func (*AttributeDef) ID

func (a *AttributeDef) ID() string

ID returns the ID.

func (*AttributeDef) IsSeparator

func (a *AttributeDef) IsSeparator() bool

IsSeparator returns true if this is actually just a separator.

func (*AttributeDef) MarshalJSON

func (a *AttributeDef) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*AttributeDef) Pool

func (a *AttributeDef) Pool() bool

Pool returns true if the base value is a pool value.

func (*AttributeDef) Primary

func (a *AttributeDef) Primary() bool

Primary returns true if the base value is a non-derived value.

func (*AttributeDef) ResolveFullName

func (a *AttributeDef) ResolveFullName() string

ResolveFullName returns the full name, using the short name if full name is empty.

func (*AttributeDef) Secondary

func (a *AttributeDef) Secondary() bool

Secondary returns true if the base value is a derived value.

func (*AttributeDef) SetID

func (a *AttributeDef) SetID(value string)

SetID sets the ID, sanitizing it in the process (i.e. it may be changed from what you set -- read it back if you want to be sure of what it gets set to.

func (*AttributeDef) UnmarshalJSON

func (a *AttributeDef) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type AttributeDefData

type AttributeDefData struct {
	DefID               string           `json:"id"`
	Type                attribute.Type   `json:"type"`
	Name                string           `json:"name"`
	FullName            string           `json:"full_name,omitempty"`
	AttributeBase       string           `json:"attribute_base,omitempty"`
	CostPerPoint        fxp.Int          `json:"cost_per_point,omitempty"`
	CostAdjPercentPerSM fxp.Int          `json:"cost_adj_percent_per_sm,omitempty"`
	Thresholds          []*PoolThreshold `json:"thresholds,omitempty"`
}

AttributeDefData holds the data that will be serialized for the AttributeDef.

type AttributeDefs

type AttributeDefs struct {
	Set map[string]*AttributeDef
}

AttributeDefs holds a set of AttributeDef objects.

func AttributeDefsFor

func AttributeDefsFor(entity *Entity) *AttributeDefs

AttributeDefsFor returns the AttributeDefs for the given Entity, or the global settings if the Entity is nil.

func FactoryAttributeDefs

func FactoryAttributeDefs() *AttributeDefs

FactoryAttributeDefs returns the factory AttributeDef set.

func NewAttributeDefsFromFile

func NewAttributeDefsFromFile(fileSystem fs.FS, filePath string) (*AttributeDefs, error)

NewAttributeDefsFromFile loads an AttributeDef set from a file.

func (*AttributeDefs) CRC64

func (a *AttributeDefs) CRC64() uint64

CRC64 calculates a CRC-64 for this data.

func (*AttributeDefs) Clone

func (a *AttributeDefs) Clone() *AttributeDefs

Clone a copy of this.

func (*AttributeDefs) List

func (a *AttributeDefs) List(omitSeparators bool) []*AttributeDef

List returns the map of AttributeDef objects as an ordered list.

func (*AttributeDefs) MarshalJSON

func (a *AttributeDefs) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*AttributeDefs) ResetTargetKeyPrefixes

func (a *AttributeDefs) ResetTargetKeyPrefixes(prefixProvider func() string)

ResetTargetKeyPrefixes assigns new key prefixes for all data within these AttributeDefs.

func (*AttributeDefs) Save

func (a *AttributeDefs) Save(filePath string) error

Save writes the AttributeDefs to the file as JSON.

func (*AttributeDefs) UnmarshalJSON

func (a *AttributeDefs) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type AttributeDifficulty

type AttributeDifficulty struct {
	Attribute  string
	Difficulty skill.Difficulty
	// contains filtered or unexported fields
}

AttributeDifficulty holds an attribute ID and a difficulty.

func (*AttributeDifficulty) Description

func (a *AttributeDifficulty) Description(entity *Entity) string

Description returns a formatted description.

func (*AttributeDifficulty) Key

func (a *AttributeDifficulty) Key() string

Key returns the value that will be serialized.

func (*AttributeDifficulty) MarshalJSON

func (a *AttributeDifficulty) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*AttributeDifficulty) Normalize

func (a *AttributeDifficulty) Normalize(entity *Entity)

Normalize the data. Should be called after loading from disk or the user.

func (AttributeDifficulty) ShouldOmit

func (a AttributeDifficulty) ShouldOmit() bool

ShouldOmit implements json.Omitter.

func (*AttributeDifficulty) UnmarshalJSON

func (a *AttributeDifficulty) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type AttributeFlags

type AttributeFlags byte

AttributeFlags provides flags that can be set to extend the defined attribute choice list.

const (
	BlankFlag AttributeFlags = 1 << iota
	TenFlag
	SizeFlag
	DodgeFlag
	ParryFlag
	BlockFlag
	SkillFlag
)

Possible AttributeFlags.

type AttributePrereq

type AttributePrereq struct {
	Parent            *PrereqList      `json:"-"`
	Type              prereq.Type      `json:"type"`
	Has               bool             `json:"has"`
	CombinedWith      string           `json:"combined_with,omitempty"`
	QualifierCriteria criteria.Numeric `json:"qualifier,omitempty"`
	Which             string           `json:"which"`
}

AttributePrereq holds a prerequisite for an attribute.

func NewAttributePrereq

func NewAttributePrereq(entity *Entity) *AttributePrereq

NewAttributePrereq creates a new AttributePrereq. 'entity' may be nil.

func (*AttributePrereq) ApplyNameableKeys

func (a *AttributePrereq) ApplyNameableKeys(_ map[string]string)

ApplyNameableKeys implements Prereq.

func (*AttributePrereq) Clone

func (a *AttributePrereq) Clone(parent *PrereqList) Prereq

Clone implements Prereq.

func (*AttributePrereq) FillWithNameableKeys

func (a *AttributePrereq) FillWithNameableKeys(_ map[string]string)

FillWithNameableKeys implements Prereq.

func (*AttributePrereq) ParentList

func (a *AttributePrereq) ParentList() *PrereqList

ParentList implements Prereq.

func (*AttributePrereq) PrereqType

func (a *AttributePrereq) PrereqType() prereq.Type

PrereqType implements Prereq.

func (*AttributePrereq) Satisfied

func (a *AttributePrereq) Satisfied(entity *Entity, _ any, tooltip *xio.ByteBuffer, prefix string) bool

Satisfied implements Prereq.

type Attributes

type Attributes struct {
	Set map[string]*Attribute
}

Attributes holds a set of Attribute objects.

func NewAttributes

func NewAttributes(entity *Entity) *Attributes

NewAttributes creates a new Attributes.

func (*Attributes) CRC64

func (a *Attributes) CRC64() uint64

CRC64 calculates a CRC-64 for this data.

func (*Attributes) Clone

func (a *Attributes) Clone(entity *Entity) *Attributes

Clone a copy of this.

func (*Attributes) Cost

func (a *Attributes) Cost(attrID string) fxp.Int

Cost returns the points spent for the specified Attribute.

func (*Attributes) Current

func (a *Attributes) Current(attrID string) fxp.Int

Current resolves the given attribute ID to its current value, or fxp.Min.

func (*Attributes) List

func (a *Attributes) List() []*Attribute

List returns the map of Attribute objects as an ordered list.

func (*Attributes) MarshalJSON

func (a *Attributes) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Attributes) Maximum

func (a *Attributes) Maximum(attrID string) fxp.Int

Maximum resolves the given attribute ID to its maximum value, or fxp.Min.

func (*Attributes) PoolThreshold

func (a *Attributes) PoolThreshold(attrID, state string) fxp.Int

PoolThreshold resolves the given attribute ID and state to the value for its pool threshold, or fxp.Min.

func (*Attributes) UnmarshalJSON

func (a *Attributes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type BlockLayout

type BlockLayout struct {
	Layout []string
}

BlockLayout holds the sheet's block layout.

func NewBlockLayout

func NewBlockLayout() *BlockLayout

NewBlockLayout creates a new default BlockLayout.

func NewBlockLayoutFromString

func NewBlockLayoutFromString(str string) (blockLayout *BlockLayout, inputWasValid bool)

NewBlockLayoutFromString creates a new BlockLayout from an input string.

func (*BlockLayout) ByRow

func (b *BlockLayout) ByRow() [][]string

ByRow breaks the layout down into rows.

func (*BlockLayout) Clone

func (b *BlockLayout) Clone() *BlockLayout

Clone this data.

func (*BlockLayout) EnsureValidity

func (b *BlockLayout) EnsureValidity()

EnsureValidity checks the current settings for validity and if they aren't valid, makes them so.

func (*BlockLayout) HTMLGridTemplate

func (b *BlockLayout) HTMLGridTemplate() string

HTMLGridTemplate returns the text for the HTML grid layout.

func (*BlockLayout) MarshalJSON

func (b *BlockLayout) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*BlockLayout) Reset

func (b *BlockLayout) Reset()

Reset returns the BlockLayout to factory settings.

func (*BlockLayout) String

func (b *BlockLayout) String() string

func (*BlockLayout) UnmarshalJSON

func (b *BlockLayout) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Body

type Body struct {
	Name      string         `json:"name,omitempty"`
	Roll      *dice.Dice     `json:"roll"`
	Locations []*HitLocation `json:"locations,omitempty"`
	KeyPrefix string         `json:"-"`
	// contains filtered or unexported fields
}

Body holds a set of hit locations.

func BodyFor

func BodyFor(entity *Entity) *Body

BodyFor returns the Body for the given Entity, or the global settings if the Entity is nil.

func FactoryBody

func FactoryBody() *Body

FactoryBody returns a new copy of the default factory Body.

func NewBodyFromFile

func NewBodyFromFile(fileSystem fs.FS, filePath string) (*Body, error)

NewBodyFromFile loads a Body from a file.

func (*Body) AddLocation

func (b *Body) AddLocation(loc *HitLocation)

AddLocation adds a HitLocation to the end of list.

func (*Body) CRC64

func (b *Body) CRC64() uint64

CRC64 calculates a CRC-64 for this data.

func (*Body) Clone

func (b *Body) Clone(entity *Entity, owningLocation *HitLocation) *Body

Clone a copy of this.

func (*Body) LookupLocationByID

func (b *Body) LookupLocationByID(entity *Entity, idStr string) *HitLocation

LookupLocationByID returns the HitLocation that matches the given ID.

func (*Body) OwningLocation

func (b *Body) OwningLocation() *HitLocation

OwningLocation returns the owning hit location, or nil if this is the top-level body.

func (*Body) RemoveLocation

func (b *Body) RemoveLocation(loc *HitLocation)

RemoveLocation removes a HitLocation.

func (*Body) ResetTargetKeyPrefixes

func (b *Body) ResetTargetKeyPrefixes(prefixProvider func() string)

ResetTargetKeyPrefixes assigns new key prefixes for all data within this Body.

func (*Body) Rewrap

func (b *Body) Rewrap()

Rewrap the description field. Should only be called for older data (prior to noNeedForRewrapVersion)

func (*Body) Save

func (b *Body) Save(filePath string) error

Save writes the Body to the file as JSON.

func (*Body) SetOwningLocation

func (b *Body) SetOwningLocation(loc *HitLocation)

SetOwningLocation sets the owning HitLocation.

func (*Body) UniqueHitLocations

func (b *Body) UniqueHitLocations(entity *Entity) []*HitLocation

UniqueHitLocations returns the list of unique hit locations.

func (*Body) Update

func (b *Body) Update(entity *Entity)

Update the role ranges and populate the lookup map.

type CellData

type CellData struct {
	Type              CellType
	Disabled          bool
	Dim               bool
	Checked           bool
	Alignment         unison.Alignment
	Primary           string
	Secondary         string
	Tooltip           string
	UnsatisfiedReason string
	TemplateInfo      string
}

CellData holds data for creating a cell's visual representation.

func (*CellData) ForSort

func (c *CellData) ForSort() string

ForSort returns a string that can be used to sort or search against for this data.

type CellType

type CellType byte

CellType holds the type of table cell.

const (
	Text CellType = iota
	Tags
	Toggle
	PageRef
	LastCellType = PageRef
)

Possible values.

func ExtractCellType

func ExtractCellType(str string) CellType

ExtractCellType extracts the value from a string.

func (CellType) EnsureValid

func (enum CellType) EnsureValid() CellType

EnsureValid ensures this is of a known value.

func (CellType) Key

func (enum CellType) Key() string

Key returns the key used in serialization.

func (CellType) MarshalText

func (enum CellType) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (CellType) String

func (enum CellType) String() string

String implements fmt.Stringer.

func (*CellType) UnmarshalText

func (enum *CellType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type CollegeList

type CollegeList []string

CollegeList holds a list of college names. This exists solely due to legacy file formats that stored this as a single string with ' or ' or '/' separating the colleges. We need to be able to load both types.

func (*CollegeList) UnmarshalJSON

func (c *CollegeList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ConditionalModifier

type ConditionalModifier struct {
	ID      uuid.UUID
	From    string
	Amounts []fxp.Int
	Sources []string
}

ConditionalModifier holds data for a reaction or conditional modifier.

func NewReaction

func NewReaction(source, from string, amt fxp.Int) *ConditionalModifier

NewReaction creates a new ConditionalModifier.

func (*ConditionalModifier) Add

func (m *ConditionalModifier) Add(source string, amt fxp.Int)

Add another source.

func (*ConditionalModifier) ApplyNameableKeys

func (m *ConditionalModifier) ApplyNameableKeys(_ map[string]string)

ApplyNameableKeys replaces any nameable keys found with the corresponding values in the provided map.

func (*ConditionalModifier) CellData

func (m *ConditionalModifier) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*ConditionalModifier) Clone

Clone implements Node.

func (*ConditionalModifier) Container

func (m *ConditionalModifier) Container() bool

Container returns true if this is a container.

func (*ConditionalModifier) Enabled

func (m *ConditionalModifier) Enabled() bool

Enabled returns true if this node is enabled.

func (*ConditionalModifier) FillWithNameableKeys

func (m *ConditionalModifier) FillWithNameableKeys(_ map[string]string)

FillWithNameableKeys adds any nameable keys found to the provided map.

func (*ConditionalModifier) HasChildren

func (m *ConditionalModifier) HasChildren() bool

HasChildren returns true if this node has children.

func (*ConditionalModifier) Kind

func (m *ConditionalModifier) Kind() string

Kind returns the kind of data.

func (*ConditionalModifier) Less

Less returns true if this should be sorted above the other.

func (*ConditionalModifier) NodeChildren

func (m *ConditionalModifier) NodeChildren() []*ConditionalModifier

NodeChildren returns the children of this node, if any.

func (*ConditionalModifier) Open

func (m *ConditionalModifier) Open() bool

Open returns true if this node is currently open.

func (*ConditionalModifier) OwningEntity

func (m *ConditionalModifier) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*ConditionalModifier) Parent

Parent returns the parent.

func (*ConditionalModifier) SetChildren

func (m *ConditionalModifier) SetChildren(_ []*ConditionalModifier)

SetChildren sets the children of this node.

func (*ConditionalModifier) SetOpen

func (m *ConditionalModifier) SetOpen(_ bool)

SetOpen sets the current open state for this node.

func (*ConditionalModifier) SetOwningEntity

func (m *ConditionalModifier) SetOwningEntity(_ *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*ConditionalModifier) SetParent

func (m *ConditionalModifier) SetParent(_ *ConditionalModifier)

SetParent sets the parent.

func (*ConditionalModifier) Total

func (m *ConditionalModifier) Total() fxp.Int

Total returns the total of all amounts.

func (*ConditionalModifier) UUID

func (m *ConditionalModifier) UUID() uuid.UUID

UUID returns the UUID of this data.

type ConditionalModifierListProvider

type ConditionalModifierListProvider interface {
	EntityProvider
	ConditionalModifiers() []*ConditionalModifier
}

ConditionalModifierListProvider defines the method needed to access the conditional modifier list data.

type ContainedQuantityPrereq

type ContainedQuantityPrereq struct {
	Parent            *PrereqList      `json:"-"`
	Type              prereq.Type      `json:"type"`
	Has               bool             `json:"has"`
	QualifierCriteria criteria.Numeric `json:"qualifier,omitempty"`
}

ContainedQuantityPrereq holds a prerequisite for an equipment contained quantity.

func NewContainedQuantityPrereq

func NewContainedQuantityPrereq() *ContainedQuantityPrereq

NewContainedQuantityPrereq creates a new ContainedQuantityPrereq.

func (*ContainedQuantityPrereq) ApplyNameableKeys

func (c *ContainedQuantityPrereq) ApplyNameableKeys(_ map[string]string)

ApplyNameableKeys implements Prereq.

func (*ContainedQuantityPrereq) Clone

func (c *ContainedQuantityPrereq) Clone(parent *PrereqList) Prereq

Clone implements Prereq.

func (*ContainedQuantityPrereq) FillWithNameableKeys

func (c *ContainedQuantityPrereq) FillWithNameableKeys(_ map[string]string)

FillWithNameableKeys implements Prereq.

func (*ContainedQuantityPrereq) ParentList

func (c *ContainedQuantityPrereq) ParentList() *PrereqList

ParentList implements Prereq.

func (*ContainedQuantityPrereq) PrereqType

func (c *ContainedQuantityPrereq) PrereqType() prereq.Type

PrereqType implements Prereq.

func (*ContainedQuantityPrereq) Satisfied

func (c *ContainedQuantityPrereq) Satisfied(_ *Entity, exclude any, tooltip *xio.ByteBuffer, prefix string) bool

Satisfied implements Prereq.

type ContainedWeightPrereq

type ContainedWeightPrereq struct {
	Parent         *PrereqList     `json:"-"`
	Type           prereq.Type     `json:"type"`
	Has            bool            `json:"has"`
	WeightCriteria criteria.Weight `json:"qualifier,omitempty"`
}

ContainedWeightPrereq holds a prerequisite for an equipment contained weight.

func NewContainedWeightPrereq

func NewContainedWeightPrereq(entity *Entity) *ContainedWeightPrereq

NewContainedWeightPrereq creates a new ContainedWeightPrereq.

func (*ContainedWeightPrereq) ApplyNameableKeys

func (c *ContainedWeightPrereq) ApplyNameableKeys(_ map[string]string)

ApplyNameableKeys implements Prereq.

func (*ContainedWeightPrereq) Clone

func (c *ContainedWeightPrereq) Clone(parent *PrereqList) Prereq

Clone implements Prereq.

func (*ContainedWeightPrereq) FillWithNameableKeys

func (c *ContainedWeightPrereq) FillWithNameableKeys(_ map[string]string)

FillWithNameableKeys implements Prereq.

func (*ContainedWeightPrereq) ParentList

func (c *ContainedWeightPrereq) ParentList() *PrereqList

ParentList implements Prereq.

func (*ContainedWeightPrereq) PrereqType

func (c *ContainedWeightPrereq) PrereqType() prereq.Type

PrereqType implements Prereq.

func (*ContainedWeightPrereq) Satisfied

func (c *ContainedWeightPrereq) Satisfied(entity *Entity, exclude any, tooltip *xio.ByteBuffer, prefix string) bool

Satisfied implements Prereq.

type ContainerBase

type ContainerBase[T NodeTypes] struct {
	ID       uuid.UUID `json:"id"`
	Type     string    `json:"type"`
	IsOpen   bool      `json:"open,omitempty"`     // Container only
	Children []T       `json:"children,omitempty"` // Container only
	// contains filtered or unexported fields
}

ContainerBase holds the type and ID of the data.

func (*ContainerBase[T]) Container

func (c *ContainerBase[T]) Container() bool

Container returns true if this is a container.

func (*ContainerBase[T]) HasChildren

func (c *ContainerBase[T]) HasChildren() bool

HasChildren returns true if this node has children.

func (*ContainerBase[T]) NodeChildren

func (c *ContainerBase[T]) NodeChildren() []T

NodeChildren returns the children of this node, if any.

func (*ContainerBase[T]) Open

func (c *ContainerBase[T]) Open() bool

Open returns true if this node is currently open.

func (*ContainerBase[T]) Parent

func (c *ContainerBase[T]) Parent() T

Parent returns the parent.

func (*ContainerBase[T]) SetChildren

func (c *ContainerBase[T]) SetChildren(children []T)

SetChildren sets the children of this node.

func (*ContainerBase[T]) SetOpen

func (c *ContainerBase[T]) SetOpen(open bool)

SetOpen sets the current open state for this node.

func (*ContainerBase[T]) SetParent

func (c *ContainerBase[T]) SetParent(parent T)

SetParent sets the parent.

func (*ContainerBase[T]) UUID

func (c *ContainerBase[T]) UUID() uuid.UUID

UUID returns the UUID of this data.

type EditorData

type EditorData[T NodeTypes] interface {
	// CopyFrom copies the corresponding data from the node into this editor data.
	CopyFrom(T)
	// ApplyTo copes he editor data into the provided node.
	ApplyTo(T)
}

EditorData defines the methods required of editor data.

type Entity

type Entity struct {
	EntityData
	LiftingStrengthBonus  fxp.Int
	StrikingStrengthBonus fxp.Int
	ThrowingStrengthBonus fxp.Int
	DodgeBonus            fxp.Int
	ParryBonus            fxp.Int
	BlockBonus            fxp.Int
	// contains filtered or unexported fields
}

Entity holds the base information for various types of entities: PC, NPC, Creature, etc.

func NewEntity

func NewEntity(entityType datafile.Type) *Entity

NewEntity creates a new Entity.

func NewEntityFromFile

func NewEntityFromFile(fileSystem fs.FS, filePath string) (*Entity, error)

NewEntityFromFile loads an Entity from a file.

func (*Entity) AddDRBonusesFor

func (e *Entity) AddDRBonusesFor(featureID string, tooltip *xio.ByteBuffer, drMap map[string]int) map[string]int

AddDRBonusesFor locates any active DR bonuses and adds them to the map. If 'drMap' is nil, it will be created. The provided map (or the newly created one) will be returned.

func (*Entity) AddNamedWeaponBonusesFor added in v5.2.0

func (e *Entity) AddNamedWeaponBonusesFor(featureID, nameQualifier, usageQualifier string, tagsQualifier []string, dieCount int, levels fxp.Int, tooltip *xio.ByteBuffer, m map[*feature.WeaponBonus]bool) map[*feature.WeaponBonus]bool

AddNamedWeaponBonusesFor adds the bonuses for matching weapons that match to the map. If 'm' is nil, it will be created. The provided map (or the newly created one) will be returned.

func (*Entity) AddWeaponComparedBonusesFor added in v5.2.0

func (e *Entity) AddWeaponComparedBonusesFor(featureID, nameQualifier, specializationQualifier string, tagsQualifier []string, dieCount int, levels fxp.Int, tooltip *xio.ByteBuffer, m map[*feature.WeaponBonus]bool) map[*feature.WeaponBonus]bool

AddWeaponComparedBonusesFor adds the bonuses for matching weapons that match to the map. If 'm' is nil, it will be created. The provided map (or the newly created one) will be returned.

func (*Entity) Ancestry

func (e *Entity) Ancestry() *ancestry.Ancestry

Ancestry returns the current Ancestry.

func (*Entity) AttributePoints

func (e *Entity) AttributePoints() fxp.Int

AttributePoints returns the number of points spent on attributes.

func (*Entity) BaseSkill

func (e *Entity) BaseSkill(def *SkillDefault, requirePoints bool) *Skill

BaseSkill returns the best skill for the given default, or nil.

func (*Entity) BasicLift

func (e *Entity) BasicLift() measure.Weight

BasicLift returns the entity's Basic Lift.

func (*Entity) BestCollegeSpellBonus

func (e *Entity) BestCollegeSpellBonus(tags, colleges []string, tooltip *xio.ByteBuffer) fxp.Int

BestCollegeSpellBonus returns the best college spell bonus for a spell.

func (*Entity) BestSkillNamed

func (e *Entity) BestSkillNamed(name, specialization string, requirePoints bool, excludes map[string]bool) *Skill

BestSkillNamed returns the best skill that matches.

func (*Entity) BonusFor

func (e *Entity) BonusFor(featureID string, tooltip *xio.ByteBuffer) fxp.Int

BonusFor returns the total bonus for the given ID.

func (*Entity) CRC64

func (e *Entity) CRC64() uint64

CRC64 computes a CRC-64 value for the canonical disk format of the data. The ModifiedOn field is ignored for this calculation.

func (*Entity) CarriedEquipmentList

func (e *Entity) CarriedEquipmentList() []*Equipment

CarriedEquipmentList implements ListProvider

func (*Entity) CarryOnBack

func (e *Entity) CarryOnBack() measure.Weight

CarryOnBack returns the carry on back value.

func (*Entity) ConditionalModifiers

func (e *Entity) ConditionalModifiers() []*ConditionalModifier

ConditionalModifiers returns the current set of conditional modifiers.

func (*Entity) CostReductionFor

func (e *Entity) CostReductionFor(featureID string) fxp.Int

CostReductionFor returns the total cost reduction for the given ID.

func (*Entity) DiscardCaches added in v5.2.0

func (e *Entity) DiscardCaches()

DiscardCaches discards the internal caches.

func (*Entity) Dodge

func (e *Entity) Dodge(enc datafile.Encumbrance) int

Dodge returns the current Dodge value for the given Encumbrance.

func (*Entity) EncumbranceLevel

func (e *Entity) EncumbranceLevel(forSkills bool) datafile.Encumbrance

EncumbranceLevel returns the current Encumbrance level.

func (*Entity) Entity

func (e *Entity) Entity() *Entity

Entity implements EntityProvider.

func (*Entity) EquippedWeapons

func (e *Entity) EquippedWeapons(weaponType weapon.Type) []*Weapon

EquippedWeapons returns a sorted list of equipped weapons.

func (*Entity) MarshalJSON

func (e *Entity) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Entity) MaximumCarry

func (e *Entity) MaximumCarry(encumbrance datafile.Encumbrance) measure.Weight

MaximumCarry returns the maximum amount the Entity can carry for the specified encumbrance level.

func (*Entity) Move

func (e *Entity) Move(enc datafile.Encumbrance) int

Move returns the current Move value for the given Encumbrance.

func (*Entity) NamedWeaponBonusesFor added in v5.2.0

func (e *Entity) NamedWeaponBonusesFor(featureID, nameQualifier, usageQualifier string, tagsQualifier []string, dieCount int, levels fxp.Int, tooltip *xio.ByteBuffer) []*feature.WeaponBonus

NamedWeaponBonusesFor returns the bonuses for matching weapons.

func (*Entity) NamedWeaponSkillBonusesFor

func (e *Entity) NamedWeaponSkillBonusesFor(featureID, nameQualifier, usageQualifier string, tagsQualifier []string, tooltip *xio.ByteBuffer) []*feature.SkillBonus

NamedWeaponSkillBonusesFor returns the bonuses for matching weapons.

func (*Entity) NoteList

func (e *Entity) NoteList() []*Note

NoteList implements ListProvider

func (*Entity) OneHandedLift

func (e *Entity) OneHandedLift() measure.Weight

OneHandedLift returns the one-handed lift value.

func (*Entity) OtherEquipmentList

func (e *Entity) OtherEquipmentList() []*Equipment

OtherEquipmentList implements ListProvider

func (*Entity) PreservesUserDesc

func (e *Entity) PreservesUserDesc() bool

PreservesUserDesc returns true if the user description widget should be preserved when written to disk. Normally, only character sheets should return true for this.

func (*Entity) Reactions

func (e *Entity) Reactions() []*ConditionalModifier

Reactions returns the current set of reactions.

func (*Entity) Recalculate

func (e *Entity) Recalculate()

Recalculate the statistics.

func (*Entity) ResolveAttribute

func (e *Entity) ResolveAttribute(attrID string) *Attribute

ResolveAttribute resolves the given attribute ID to its Attribute, or nil.

func (*Entity) ResolveAttributeCurrent

func (e *Entity) ResolveAttributeCurrent(attrID string) fxp.Int

ResolveAttributeCurrent resolves the given attribute ID to its current value, or fxp.Min.

func (*Entity) ResolveAttributeDef

func (e *Entity) ResolveAttributeDef(attrID string) *AttributeDef

ResolveAttributeDef resolves the given attribute ID to its AttributeDef, or nil.

func (*Entity) ResolveAttributeName

func (e *Entity) ResolveAttributeName(attrID string) string

ResolveAttributeName resolves the given attribute ID to its name, or <unknown>.

func (*Entity) ResolveVariable

func (e *Entity) ResolveVariable(variableName string) string

ResolveVariable implements eval.VariableResolver.

func (*Entity) RunningShoveAndKnockOver

func (e *Entity) RunningShoveAndKnockOver() measure.Weight

RunningShoveAndKnockOver returns the running shove & knock over value.

func (*Entity) Save

func (e *Entity) Save(filePath string) error

Save the Entity to a file as JSON.

func (*Entity) SetCarriedEquipmentList

func (e *Entity) SetCarriedEquipmentList(list []*Equipment)

SetCarriedEquipmentList implements ListProvider

func (*Entity) SetNoteList

func (e *Entity) SetNoteList(list []*Note)

SetNoteList implements ListProvider

func (*Entity) SetOtherEquipmentList

func (e *Entity) SetOtherEquipmentList(list []*Equipment)

SetOtherEquipmentList implements ListProvider

func (*Entity) SetPointsRecord added in v5.3.0

func (e *Entity) SetPointsRecord(record []*PointsRecord)

SetPointsRecord sets a new points record list, adjusting the total points.

func (*Entity) SetSkillList

func (e *Entity) SetSkillList(list []*Skill)

SetSkillList implements ListProvider

func (*Entity) SetSpellList

func (e *Entity) SetSpellList(list []*Spell)

SetSpellList implements ListProvider

func (*Entity) SetTraitList

func (e *Entity) SetTraitList(list []*Trait)

SetTraitList implements ListProvider

func (*Entity) SetUnspentPoints

func (e *Entity) SetUnspentPoints(unspent fxp.Int)

SetUnspentPoints sets the number of unspent points.

func (*Entity) SetWeapons

func (e *Entity) SetWeapons(_ weapon.Type, _ []*Weapon)

SetWeapons implements WeaponListProvider.

func (*Entity) ShiftSlightly

func (e *Entity) ShiftSlightly() measure.Weight

ShiftSlightly returns the shift slightly value.

func (*Entity) ShoveAndKnockOver

func (e *Entity) ShoveAndKnockOver() measure.Weight

ShoveAndKnockOver returns the shove & knock over value.

func (*Entity) SkillComparedBonusFor

func (e *Entity) SkillComparedBonusFor(featureID, name, specialization string, tags []string, tooltip *xio.ByteBuffer) fxp.Int

SkillComparedBonusFor returns the total bonus for the matching skill bonuses.

func (*Entity) SkillList

func (e *Entity) SkillList() []*Skill

SkillList implements ListProvider

func (*Entity) SkillNamed

func (e *Entity) SkillNamed(name, specialization string, requirePoints bool, excludes map[string]bool) []*Skill

SkillNamed returns a list of skills that match.

func (*Entity) SkillPointComparedBonusFor

func (e *Entity) SkillPointComparedBonusFor(featureID, name, specialization string, tags []string, tooltip *xio.ByteBuffer) fxp.Int

SkillPointComparedBonusFor returns the total bonus for the matching skill point bonuses.

func (*Entity) SkillPoints

func (e *Entity) SkillPoints() fxp.Int

SkillPoints returns the number of points spent on skills.

func (*Entity) SpellBonusesFor

func (e *Entity) SpellBonusesFor(featureID, qualifier string, tags []string, tooltip *xio.ByteBuffer) fxp.Int

SpellBonusesFor returns the total bonuses for a spell.

func (*Entity) SpellComparedBonusFor

func (e *Entity) SpellComparedBonusFor(featureID, name string, tags []string, tooltip *xio.ByteBuffer) fxp.Int

SpellComparedBonusFor returns the total bonus for the matching spell bonuses.

func (*Entity) SpellList

func (e *Entity) SpellList() []*Spell

SpellList implements ListProvider

func (*Entity) SpellPointBonusesFor

func (e *Entity) SpellPointBonusesFor(featureID, qualifier string, tags []string, tooltip *xio.ByteBuffer) fxp.Int

SpellPointBonusesFor returns the total point bonus for the matching spell.

func (*Entity) SpellPointComparedBonusFor

func (e *Entity) SpellPointComparedBonusFor(featureID, qualifier string, tags []string, tooltip *xio.ByteBuffer) fxp.Int

SpellPointComparedBonusFor returns the total bonus for the matching spell point bonuses.

func (*Entity) SpellPoints

func (e *Entity) SpellPoints() fxp.Int

SpellPoints returns the number of points spent on spells.

func (*Entity) SpentPoints

func (e *Entity) SpentPoints() fxp.Int

SpentPoints returns the number of spent points.

func (*Entity) StrengthOrZero

func (e *Entity) StrengthOrZero() fxp.Int

StrengthOrZero returns the current ST value, or zero if no such attribute exists.

func (*Entity) Swing

func (e *Entity) Swing() *dice.Dice

Swing returns the swing value for the current strength.

func (*Entity) SwingFor

func (e *Entity) SwingFor(st int) *dice.Dice

SwingFor returns the swing value for the provided strength.

func (*Entity) Thrust

func (e *Entity) Thrust() *dice.Dice

Thrust returns the thrust value for the current strength.

func (*Entity) ThrustFor

func (e *Entity) ThrustFor(st int) *dice.Dice

ThrustFor returns the thrust value for the provided strength.

func (*Entity) TraitList

func (e *Entity) TraitList() []*Trait

TraitList implements ListProvider

func (*Entity) TraitPoints

func (e *Entity) TraitPoints() (ad, disad, race, quirk fxp.Int)

TraitPoints returns the number of points spent on traits.

func (*Entity) TwoHandedLift

func (e *Entity) TwoHandedLift() measure.Weight

TwoHandedLift returns the two-handed lift value.

func (*Entity) UnmarshalJSON

func (e *Entity) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Entity) UnspentPoints

func (e *Entity) UnspentPoints() fxp.Int

UnspentPoints returns the number of unspent points.

func (*Entity) UpdateSkills

func (e *Entity) UpdateSkills() bool

UpdateSkills updates the levels of all skills.

func (*Entity) UpdateSpells

func (e *Entity) UpdateSpells() bool

UpdateSpells updates the levels of all spells.

func (*Entity) WealthCarried

func (e *Entity) WealthCarried() fxp.Int

WealthCarried returns the current wealth being carried.

func (*Entity) WealthNotCarried

func (e *Entity) WealthNotCarried() fxp.Int

WealthNotCarried returns the current wealth not being carried.

func (*Entity) WeaponComparedBonusesFor added in v5.2.0

func (e *Entity) WeaponComparedBonusesFor(featureID, nameQualifier, specializationQualifier string, tagsQualifier []string, dieCount int, levels fxp.Int, tooltip *xio.ByteBuffer) []*feature.WeaponBonus

WeaponComparedBonusesFor returns the bonuses for matching weapons that match.

func (*Entity) WeaponOwner

func (e *Entity) WeaponOwner() WeaponOwner

WeaponOwner implements WeaponListProvider. In the case of an Entity, always returns nil, as entities rely on sub-components for their weapons and don't allow them to be created directly.

func (*Entity) Weapons

func (e *Entity) Weapons(weaponType weapon.Type) []*Weapon

Weapons implements WeaponListProvider.

func (*Entity) WeightCarried

func (e *Entity) WeightCarried(forSkills bool) measure.Weight

WeightCarried returns the carried weight.

type EntityData

type EntityData struct {
	Type             datafile.Type   `json:"type"`
	Version          int             `json:"version"`
	ID               uuid.UUID       `json:"id"`
	TotalPoints      fxp.Int         `json:"total_points"`
	PointsRecord     []*PointsRecord `json:"points_record,omitempty"`
	Profile          *Profile        `json:"profile,omitempty"`
	SheetSettings    *SheetSettings  `json:"settings,omitempty"`
	Attributes       *Attributes     `json:"attributes,omitempty"`
	Traits           []*Trait        `json:"traits,alt=advantages,omitempty"`
	Skills           []*Skill        `json:"skills,omitempty"`
	Spells           []*Spell        `json:"spells,omitempty"`
	CarriedEquipment []*Equipment    `json:"equipment,omitempty"`
	OtherEquipment   []*Equipment    `json:"other_equipment,omitempty"`
	Notes            []*Note         `json:"notes,omitempty"`
	CreatedOn        jio.Time        `json:"created_date"`
	ModifiedOn       jio.Time        `json:"modified_date"`
	ThirdParty       map[string]any  `json:"third_party,omitempty"`
}

EntityData holds the Entity data that is written to disk.

type EntityProvider

type EntityProvider interface {
	Entity() *Entity
}

EntityProvider provides a way to retrieve a (possibly nil) Entity.

type Equipment

type Equipment struct {
	EquipmentData
	Entity            *Entity
	UnsatisfiedReason string
}

Equipment holds a piece of equipment.

func NewEquipment

func NewEquipment(entity *Entity, parent *Equipment, container bool) *Equipment

NewEquipment creates a new Equipment.

func NewEquipmentFromFile

func NewEquipmentFromFile(fileSystem fs.FS, filePath string) ([]*Equipment, error)

NewEquipmentFromFile loads an Equipment list from a file.

func (*Equipment) ActiveModifierFor

func (e *Equipment) ActiveModifierFor(name string) *EquipmentModifier

ActiveModifierFor returns the first modifier that matches the name (case-insensitive).

func (*Equipment) AdjustedValue

func (e *Equipment) AdjustedValue() fxp.Int

AdjustedValue returns the value after adjustments for any modifiers. Does not include the value of children.

func (*Equipment) AdjustedWeight

func (e *Equipment) AdjustedWeight(forSkills bool, defUnits measure.WeightUnits) measure.Weight

AdjustedWeight returns the weight after adjustments for any modifiers. Does not include the weight of children.

func (*Equipment) ApplyNameableKeys

func (e *Equipment) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys replaces any nameable keys found with the corresponding values in the provided map.

func (*Equipment) CellData

func (e *Equipment) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*Equipment) Clone

func (e *Equipment) Clone(entity *Entity, parent *Equipment, preserveID bool) *Equipment

Clone implements Node.

func (*Equipment) Depth

func (e *Equipment) Depth() int

Depth returns the number of parents this node has.

func (*Equipment) Description

func (e *Equipment) Description() string

Description returns a description.

func (*Equipment) DisplayLegalityClass

func (e *Equipment) DisplayLegalityClass() string

DisplayLegalityClass returns a display version of the LegalityClass.

func (*Equipment) Enabled

func (e *Equipment) Enabled() bool

Enabled returns true if this node is enabled.

func (*Equipment) ExtendedValue

func (e *Equipment) ExtendedValue() fxp.Int

ExtendedValue returns the extended value.

func (*Equipment) ExtendedWeight

func (e *Equipment) ExtendedWeight(forSkills bool, defUnits measure.WeightUnits) measure.Weight

ExtendedWeight returns the extended weight.

func (*Equipment) FeatureList

func (e *Equipment) FeatureList() feature.Features

FeatureList returns the list of Features.

func (*Equipment) FillWithNameableKeys

func (e *Equipment) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys adds any nameable keys found to the provided map.

func (*Equipment) MarshalJSON

func (e *Equipment) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Equipment) ModifierNotes

func (e *Equipment) ModifierNotes() string

ModifierNotes returns the notes due to modifiers.

func (*Equipment) Notes

func (e *Equipment) Notes() string

Notes returns the local notes.

func (*Equipment) OwningEntity

func (e *Equipment) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*Equipment) RequiresTL

func (e *Equipment) RequiresTL() bool

RequiresTL implements TechLevelProvider.

func (*Equipment) SecondaryText

func (e *Equipment) SecondaryText(optionChecker func(display.Option) bool) string

SecondaryText returns the "secondary" text: the text display below the description.

func (*Equipment) SetOwningEntity

func (e *Equipment) SetOwningEntity(entity *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*Equipment) SetTL

func (e *Equipment) SetTL(tl string)

SetTL implements TechLevelProvider.

func (*Equipment) String

func (e *Equipment) String() string

String implements fmt.Stringer.

func (*Equipment) TL

func (e *Equipment) TL() string

TL implements TechLevelProvider.

func (*Equipment) TagList

func (e *Equipment) TagList() []string

TagList returns the list of tags.

func (*Equipment) UnmarshalJSON

func (e *Equipment) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type EquipmentData

type EquipmentData struct {
	ContainerBase[*Equipment]
	EquipmentEditData
}

EquipmentData holds the Equipment data that is written to disk.

func (*EquipmentData) ClearUnusedFieldsForType

func (d *EquipmentData) ClearUnusedFieldsForType()

ClearUnusedFieldsForType zeroes out the fields that are not applicable to this type (container vs not-container).

func (*EquipmentData) Kind

func (d *EquipmentData) Kind() string

Kind returns the kind of data.

type EquipmentEditData

type EquipmentEditData struct {
	Name                   string               `json:"description,omitempty"`
	PageRef                string               `json:"reference,omitempty"`
	LocalNotes             string               `json:"notes,omitempty"`
	VTTNotes               string               `json:"vtt_notes,omitempty"`
	TechLevel              string               `json:"tech_level,omitempty"`
	LegalityClass          string               `json:"legality_class,omitempty"`
	Tags                   []string             `json:"tags,omitempty"`
	Modifiers              []*EquipmentModifier `json:"modifiers,omitempty"`
	Quantity               fxp.Int              `json:"quantity,omitempty"`
	Value                  fxp.Int              `json:"value,omitempty"`
	Weight                 measure.Weight       `json:"weight,omitempty"`
	MaxUses                int                  `json:"max_uses,omitempty"`
	Uses                   int                  `json:"uses,omitempty"`
	Prereq                 *PrereqList          `json:"prereqs,omitempty"`
	Weapons                []*Weapon            `json:"weapons,omitempty"`
	Features               feature.Features     `json:"features,omitempty"`
	Equipped               bool                 `json:"equipped,omitempty"`
	WeightIgnoredForSkills bool                 `json:"ignore_weight_for_skills,omitempty"`
}

EquipmentEditData holds the Equipment data that can be edited by the UI detail editor.

func (*EquipmentEditData) ApplyTo

func (d *EquipmentEditData) ApplyTo(e *Equipment)

ApplyTo implements node.EditorData.

func (*EquipmentEditData) CopyFrom

func (d *EquipmentEditData) CopyFrom(e *Equipment)

CopyFrom implements node.EditorData.

type EquipmentListProvider

type EquipmentListProvider interface {
	EntityProvider
	CarriedEquipmentList() []*Equipment
	SetCarriedEquipmentList(list []*Equipment)
	OtherEquipmentList() []*Equipment
	SetOtherEquipmentList(list []*Equipment)
}

EquipmentListProvider defines the method needed to access the equipment list data.

type EquipmentModifier

type EquipmentModifier struct {
	EquipmentModifierData
	Entity *Entity
}

EquipmentModifier holds a modifier to a piece of Equipment.

func NewEquipmentModifier

func NewEquipmentModifier(entity *Entity, parent *EquipmentModifier, container bool) *EquipmentModifier

NewEquipmentModifier creates an EquipmentModifier.

func NewEquipmentModifiersFromFile

func NewEquipmentModifiersFromFile(fileSystem fs.FS, filePath string) ([]*EquipmentModifier, error)

NewEquipmentModifiersFromFile loads an EquipmentModifier list from a file.

func (*EquipmentModifier) ApplyNameableKeys

func (m *EquipmentModifier) ApplyNameableKeys(keyMap map[string]string)

ApplyNameableKeys replaces any nameable keys found in this EquipmentModifier with the corresponding values in the provided map.

func (*EquipmentModifier) CellData

func (m *EquipmentModifier) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*EquipmentModifier) Clone

func (m *EquipmentModifier) Clone(entity *Entity, parent *EquipmentModifier, preserveID bool) *EquipmentModifier

Clone implements Node.

func (*EquipmentModifier) CostDescription

func (m *EquipmentModifier) CostDescription() string

CostDescription returns the formatted cost.

func (*EquipmentModifier) Depth

func (m *EquipmentModifier) Depth() int

Depth returns the number of parents this node has.

func (*EquipmentModifier) Enabled

func (m *EquipmentModifier) Enabled() bool

Enabled returns true if this node is enabled.

func (*EquipmentModifier) FillWithNameableKeys

func (m *EquipmentModifier) FillWithNameableKeys(keyMap map[string]string)

FillWithNameableKeys adds any nameable keys found in this EquipmentModifier to the provided map.

func (*EquipmentModifier) FullCostDescription added in v5.2.0

func (m *EquipmentModifier) FullCostDescription() string

FullCostDescription returns a combination of the cost and weight descriptions.

func (*EquipmentModifier) FullDescription

func (m *EquipmentModifier) FullDescription() string

FullDescription returns a full description.

func (*EquipmentModifier) MarshalJSON

func (m *EquipmentModifier) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*EquipmentModifier) OwningEntity

func (m *EquipmentModifier) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*EquipmentModifier) SecondaryText

func (m *EquipmentModifier) SecondaryText(optionChecker func(display.Option) bool) string

SecondaryText returns the "secondary" text: the text display below an Trait.

func (*EquipmentModifier) SetEnabled

func (m *EquipmentModifier) SetEnabled(enabled bool)

SetEnabled makes the node enabled, if possible.

func (*EquipmentModifier) SetOwningEntity

func (m *EquipmentModifier) SetOwningEntity(entity *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*EquipmentModifier) String

func (m *EquipmentModifier) String() string

func (*EquipmentModifier) TagList added in v5.2.0

func (m *EquipmentModifier) TagList() []string

TagList returns the list of tags.

func (*EquipmentModifier) UnmarshalJSON

func (m *EquipmentModifier) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*EquipmentModifier) WeightDescription

func (m *EquipmentModifier) WeightDescription() string

WeightDescription returns the formatted weight.

type EquipmentModifierData

type EquipmentModifierData struct {
	ContainerBase[*EquipmentModifier]
	EquipmentModifierEditData
}

EquipmentModifierData holds the EquipmentModifier data that is written to disk.

func (*EquipmentModifierData) ClearUnusedFieldsForType

func (d *EquipmentModifierData) ClearUnusedFieldsForType()

ClearUnusedFieldsForType zeroes out the fields that are not applicable to this type (container vs not-container).

func (*EquipmentModifierData) Kind

func (d *EquipmentModifierData) Kind() string

Kind returns the kind of data.

type EquipmentModifierEditData

type EquipmentModifierEditData struct {
	Name         string                       `json:"name,omitempty"`
	PageRef      string                       `json:"reference,omitempty"`
	LocalNotes   string                       `json:"notes,omitempty"`
	VTTNotes     string                       `json:"vtt_notes,omitempty"`
	Tags         []string                     `json:"tags,omitempty"`
	CostType     equipment.ModifierCostType   `json:"cost_type,omitempty"`   // Non-container only
	WeightType   equipment.ModifierWeightType `json:"weight_type,omitempty"` // Non-container only
	Disabled     bool                         `json:"disabled,omitempty"`    // Non-container only
	TechLevel    string                       `json:"tech_level,omitempty"`  // Non-container only
	CostAmount   string                       `json:"cost,omitempty"`        // Non-container only
	WeightAmount string                       `json:"weight,omitempty"`      // Non-container only
	Features     feature.Features             `json:"features,omitempty"`    // Non-container only
}

EquipmentModifierEditData holds the EquipmentModifier data that can be edited by the UI detail editor.

func (*EquipmentModifierEditData) ApplyTo

ApplyTo implements node.EditorData.

func (*EquipmentModifierEditData) CopyFrom

func (d *EquipmentModifierEditData) CopyFrom(mod *EquipmentModifier)

CopyFrom implements node.EditorData.

type EquipmentModifierListProvider

type EquipmentModifierListProvider interface {
	EntityProvider
	EquipmentModifierList() []*EquipmentModifier
	SetEquipmentModifierList(list []*EquipmentModifier)
}

EquipmentModifierListProvider defines the method needed to access the equipment modifier list data.

type ExportInfo

type ExportInfo struct {
	FilePath     string   `json:"file_path"`
	TemplatePath string   `json:"template_path"`
	ExportPath   string   `json:"export_path"`
	LastUsed     jio.Time `json:"last_used"`
}

ExportInfo holds information about a recent export so that it can be redone quickly.

type GeneralModifier

type GeneralModifier interface {
	Container() bool
	Depth() int
	FullDescription() string
	FullCostDescription() string
	Enabled() bool
	SetEnabled(enabled bool)
}

GeneralModifier is used for common access to modifiers.

type HitLocation

type HitLocation struct {
	HitLocationData
	Entity    *Entity
	RollRange string
	KeyPrefix string
	// contains filtered or unexported fields
}

HitLocation holds a single hit location.

func NewHitLocation

func NewHitLocation(entity *Entity, keyPrefix string) *HitLocation

NewHitLocation creates a new hit location.

func (*HitLocation) Clone

func (h *HitLocation) Clone(entity *Entity, owningTable *Body) *HitLocation

Clone a copy of this.

func (*HitLocation) DR

func (h *HitLocation) DR(entity *Entity, tooltip *xio.ByteBuffer, drMap map[string]int) map[string]int

DR computes the DR coverage for this HitLocation. If 'tooltip' isn't nil, the buffer will be updated with details on how the DR was calculated. If 'drMap' isn't nil, it will be returned.

func (*HitLocation) DisplayDR

func (h *HitLocation) DisplayDR(entity *Entity, tooltip *xio.ByteBuffer) string

DisplayDR returns the DR for this location, formatted as a string.

func (*HitLocation) ID

func (h *HitLocation) ID() string

ID returns the ID.

func (*HitLocation) MarshalJSON

func (h *HitLocation) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*HitLocation) OwningTable

func (h *HitLocation) OwningTable() *Body

OwningTable returns the owning table.

func (*HitLocation) ResetTargetKeyPrefixes

func (h *HitLocation) ResetTargetKeyPrefixes(prefixProvider func() string)

ResetTargetKeyPrefixes assigns new key prefixes for all data within this HitLocation.

func (*HitLocation) SetID

func (h *HitLocation) SetID(value string)

SetID sets the ID, sanitizing it in the process (i.e. it may be changed from what you set -- read it back if you want to be sure of what it gets set to.

func (*HitLocation) SetSubTable

func (h *HitLocation) SetSubTable(bodyType *Body)

SetSubTable sets the Body as a sub-table.

func (*HitLocation) UnmarshalJSON

func (h *HitLocation) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type HitLocationChoice

type HitLocationChoice struct {
	Key   string
	Title string
}

HitLocationChoice holds a single hit location choice.

func (*HitLocationChoice) String

func (c *HitLocationChoice) String() string

type HitLocationData

type HitLocationData struct {
	LocID       string `json:"id"`
	ChoiceName  string `json:"choice_name"`
	TableName   string `json:"table_name"`
	Slots       int    `json:"slots,omitempty"`
	HitPenalty  int    `json:"hit_penalty,omitempty"`
	DRBonus     int    `json:"dr_bonus,omitempty"`
	Description string `json:"description,omitempty"`
	SubTable    *Body  `json:"sub_table,omitempty"`
}

HitLocationData holds the Hitlocation data that gets written to disk.

type ListProvider

ListProvider defines the methods needed to access list data.

type Node

type Node[T NodeTypes] interface {
	UUID() uuid.UUID
	Clone(newEntity *Entity, newParent T, preserveID bool) T
	OwningEntity() *Entity
	SetOwningEntity(entity *Entity)
	Kind() string
	Container() bool
	Parent() T
	SetParent(parent T)
	HasChildren() bool
	NodeChildren() []T
	SetChildren(children []T)
	Enabled() bool
	Open() bool
	SetOpen(open bool)
	CellData(column int, data *CellData)
	FillWithNameableKeys(m map[string]string)
	ApplyNameableKeys(m map[string]string)
}

Node defines the methods required of nodes in our tables.

func AsNode

func AsNode[T NodeTypes](in T) Node[T]

AsNode converts a T to a Node[T]. This shouldn't require these hoops, but Go generics (as of 1.19) fails to compile otherwise.

type NodeTypes

type NodeTypes interface {
	*ConditionalModifier | *Equipment | *EquipmentModifier | *Note | *Skill | *Spell | *Trait | *TraitModifier | *Weapon
}

NodeTypes is a constraint that defines the types that may be nodes.

type Note

type Note struct {
	NoteData
	Entity *Entity
}

Note holds a note.

func NewNote

func NewNote(entity *Entity, parent *Note, container bool) *Note

NewNote creates a new Note.

func NewNotesFromFile

func NewNotesFromFile(fileSystem fs.FS, filePath string) ([]*Note, error)

NewNotesFromFile loads an Note list from a file.

func (*Note) ApplyNameableKeys

func (n *Note) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys replaces any nameable keys found with the corresponding values in the provided map.

func (*Note) CellData

func (n *Note) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*Note) Clone

func (n *Note) Clone(entity *Entity, parent *Note, preserveID bool) *Note

Clone implements Node.

func (*Note) Depth

func (n *Note) Depth() int

Depth returns the number of parents this node has.

func (*Note) Enabled

func (n *Note) Enabled() bool

Enabled returns true if this node is enabled.

func (*Note) FillWithNameableKeys

func (n *Note) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys adds any nameable keys found to the provided map.

func (*Note) MarshalJSON

func (n *Note) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Note) OwningEntity

func (n *Note) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*Note) SetOwningEntity

func (n *Note) SetOwningEntity(entity *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*Note) UnmarshalJSON

func (n *Note) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type NoteData

type NoteData struct {
	ContainerBase[*Note]
	NoteEditData
}

NoteData holds the Note data that is written to disk.

func (*NoteData) ClearUnusedFieldsForType

func (d *NoteData) ClearUnusedFieldsForType()

ClearUnusedFieldsForType zeroes out the fields that are not applicable to this type (container vs not-container).

func (*NoteData) Kind

func (d *NoteData) Kind() string

Kind returns the kind of data.

type NoteEditData

type NoteEditData struct {
	Text    string `json:"text,omitempty"`
	PageRef string `json:"reference,omitempty"`
}

NoteEditData holds the Note data that can be edited by the UI detail editor.

func (*NoteEditData) ApplyTo

func (d *NoteEditData) ApplyTo(note *Note)

ApplyTo implements node.EditorData.

func (*NoteEditData) CopyFrom

func (d *NoteEditData) CopyFrom(note *Note)

CopyFrom implements node.EditorData.

type NoteListProvider

type NoteListProvider interface {
	EntityProvider
	NoteList() []*Note
	SetNoteList(list []*Note)
}

NoteListProvider defines the method needed to access the note list data.

type PointsRecord added in v5.3.0

type PointsRecord struct {
	When   jio.Time `json:"when"`
	Points fxp.Int  `json:"points"`
	Reason string   `json:"reason,omitempty"`
}

PointsRecord holds information about when and why points were adjusted.

func ClonePointsRecordList added in v5.3.0

func ClonePointsRecordList(list []*PointsRecord) []*PointsRecord

ClonePointsRecordList creates a clone of the provided PointsRecord list.

type PoolThreshold

type PoolThreshold struct {
	PoolThresholdData
	KeyPrefix string
}

PoolThreshold holds a point within an attribute pool where changes in state occur.

func (*PoolThreshold) AddOp

func (p *PoolThreshold) AddOp(op attribute.ThresholdOp)

AddOp adds the specified ThresholdOp.

func (*PoolThreshold) Clone

func (p *PoolThreshold) Clone() *PoolThreshold

Clone a copy of this.

func (*PoolThreshold) ContainsOp

func (p *PoolThreshold) ContainsOp(op attribute.ThresholdOp) bool

ContainsOp returns true if this PoolThreshold contains the specified ThresholdOp.

func (*PoolThreshold) MarshalJSON

func (p *PoolThreshold) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*PoolThreshold) RemoveOp

func (p *PoolThreshold) RemoveOp(op attribute.ThresholdOp)

RemoveOp removes the specified ThresholdOp.

func (*PoolThreshold) String

func (p *PoolThreshold) String() string

func (*PoolThreshold) Threshold

func (p *PoolThreshold) Threshold(resolver eval.VariableResolver) fxp.Int

Threshold returns the threshold value for the given maximum.

func (*PoolThreshold) UnmarshalJSON

func (p *PoolThreshold) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type PoolThresholdData

type PoolThresholdData struct {
	State       string                  `json:"state"`
	Expression  string                  `json:"expression"`
	Explanation string                  `json:"explanation,omitempty"`
	Ops         []attribute.ThresholdOp `json:"ops,omitempty"`
}

PoolThresholdData holds the data that will be serialized for the PoolThreshold.

type Prereq

type Prereq interface {
	nameables.Nameables
	PrereqType() prereq.Type
	// ParentList returns the owning parent list, if any.
	ParentList() *PrereqList
	// Clone creates a new copy of this Prereq.
	Clone(parent *PrereqList) Prereq
	// Satisfied returns true if this Prereq is satisfied by the specified Entity. 'buffer' will be used, if not nil, to
	// write a description of what was unsatisfied. 'prefix' will be appended to each line of the description.
	Satisfied(entity *Entity, exclude any, buffer *xio.ByteBuffer, prefix string) bool
}

Prereq holds data necessary to track a prerequisite.

type PrereqList

type PrereqList struct {
	Parent  *PrereqList      `json:"-"`
	Type    prereq.Type      `json:"type"`
	All     bool             `json:"all"`
	WhenTL  criteria.Numeric `json:"when_tl,omitempty"`
	Prereqs Prereqs          `json:"prereqs,omitempty"`
}

PrereqList holds a prereq that contains a list of prerequisites.

func NewPrereqList

func NewPrereqList() *PrereqList

NewPrereqList creates a new PrereqList.

func (*PrereqList) ApplyNameableKeys

func (p *PrereqList) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys implements Prereq.

func (*PrereqList) Clone

func (p *PrereqList) Clone(parent *PrereqList) Prereq

Clone implements Prereq.

func (*PrereqList) CloneAsPrereqList

func (p *PrereqList) CloneAsPrereqList(parent *PrereqList) *PrereqList

CloneAsPrereqList clones this prereq list.

func (*PrereqList) CloneResolvingEmpty

func (p *PrereqList) CloneResolvingEmpty(isContainer, pruneIfEmpty bool) *PrereqList

CloneResolvingEmpty clones this prereq list. If the result would be nil and it isn't a container, a new, empty, list is created. If the result would not be nil but pruneIfEmpty is true and calling ShouldOmit() on it would return true, then nil is returned.

func (*PrereqList) FillWithNameableKeys

func (p *PrereqList) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys implements Prereq.

func (*PrereqList) ParentList

func (p *PrereqList) ParentList() *PrereqList

ParentList implements Prereq.

func (*PrereqList) PrereqType

func (p *PrereqList) PrereqType() prereq.Type

PrereqType implements Prereq.

func (*PrereqList) Satisfied

func (p *PrereqList) Satisfied(entity *Entity, exclude any, buffer *xio.ByteBuffer, prefix string) bool

Satisfied implements Prereq.

func (*PrereqList) ShouldOmit

func (p *PrereqList) ShouldOmit() bool

ShouldOmit implements json.Omitter.

type Prereqs

type Prereqs []Prereq

Prereqs holds a list of prerequisites.

func (*Prereqs) UnmarshalJSON

func (p *Prereqs) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Profile

type Profile struct {
	PlayerName        string         `json:"player_name,omitempty"`
	Name              string         `json:"name,omitempty"`
	Title             string         `json:"title,omitempty"`
	Organization      string         `json:"organization,omitempty"`
	Religion          string         `json:"religion,omitempty"`
	Age               string         `json:"age,omitempty"`
	Birthday          string         `json:"birthday,omitempty"`
	Eyes              string         `json:"eyes,omitempty"`
	Hair              string         `json:"hair,omitempty"`
	Skin              string         `json:"skin,omitempty"`
	Handedness        string         `json:"handedness,omitempty"`
	Gender            string         `json:"gender,omitempty"`
	TechLevel         string         `json:"tech_level,omitempty"`
	PortraitData      []byte         `json:"portrait,omitempty"`
	PortraitImage     *unison.Image  `json:"-"`
	Height            measure.Length `json:"height,omitempty"`
	Weight            measure.Weight `json:"weight,omitempty"`
	SizeModifier      int            `json:"SM,omitempty"`
	SizeModifierBonus fxp.Int        `json:"-"`
}

Profile holds the profile information for an NPC.

func (*Profile) AdjustedSizeModifier

func (p *Profile) AdjustedSizeModifier() int

AdjustedSizeModifier returns the adjusted size modifier.

func (*Profile) AutoFill

func (p *Profile) AutoFill(entity *Entity)

AutoFill fills in the default profile entries.

func (*Profile) Portrait

func (p *Profile) Portrait() *unison.Image

Portrait returns the portrait image, if there is one.

func (*Profile) SetAdjustedSizeModifier

func (p *Profile) SetAdjustedSizeModifier(value int)

SetAdjustedSizeModifier sets the adjusted size modifier.

func (*Profile) Update

func (p *Profile) Update(entity *Entity)

Update any derived values.

type QuickExports

type QuickExports struct {
	QuickExportsData
}

QuickExports holds a list containing information about previous exports.

func NewQuickExports

func NewQuickExports() *QuickExports

NewQuickExports creates a new, empty, QuickExports object.

func (*QuickExports) Empty

func (q *QuickExports) Empty() bool

Empty implements encoding.Empty.

func (*QuickExports) MarshalJSON

func (q *QuickExports) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*QuickExports) UnmarshalJSON

func (q *QuickExports) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type QuickExportsData

type QuickExportsData struct {
	Max     int           `json:"max"`
	Exports []*ExportInfo `json:"exports,omitempty"`
}

QuickExportsData holds the QuickExports data that is written to disk.

type RawPointsAdjuster

type RawPointsAdjuster[T NodeTypes] interface {
	Node[T]
	RawPoints() fxp.Int
	SetRawPoints(points fxp.Int) bool
}

RawPointsAdjuster defines methods for nodes that can have their raw points adjusted must implement.

type ReactionModifierListProvider

type ReactionModifierListProvider interface {
	EntityProvider
	Reactions() []*ConditionalModifier
}

ReactionModifierListProvider defines the method needed to access the reaction modifier list data.

type SelfControlRollAdj

type SelfControlRollAdj byte

SelfControlRollAdj holds an Adjustment for a self-control roll.

const (
	NoCRAdj SelfControlRollAdj = iota
	ActionPenalty
	ReactionPenalty
	FrightCheckPenalty
	FrightCheckBonus
	MinorCostOfLivingIncrease
	MajorCostOfLivingIncrease
	LastSelfControlRollAdj = MajorCostOfLivingIncrease
)

Possible values.

func ExtractSelfControlRollAdj

func ExtractSelfControlRollAdj(str string) SelfControlRollAdj

ExtractSelfControlRollAdj extracts the value from a string.

func (SelfControlRollAdj) Adjustment

func (enum SelfControlRollAdj) Adjustment(cr trait.SelfControlRoll) int

Adjustment returns the adjustment amount.

func (SelfControlRollAdj) AltString

func (enum SelfControlRollAdj) AltString() string

AltString returns the alternate string.

func (SelfControlRollAdj) Description

func (enum SelfControlRollAdj) Description(cr trait.SelfControlRoll) string

Description returns a formatted description.

func (SelfControlRollAdj) EnsureValid

func (enum SelfControlRollAdj) EnsureValid() SelfControlRollAdj

EnsureValid ensures this is of a known value.

func (SelfControlRollAdj) Features

Features returns the set of features to apply.

func (SelfControlRollAdj) Key

func (enum SelfControlRollAdj) Key() string

Key returns the key used in serialization.

func (SelfControlRollAdj) MarshalText

func (enum SelfControlRollAdj) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (SelfControlRollAdj) String

func (enum SelfControlRollAdj) String() string

String implements fmt.Stringer.

func (*SelfControlRollAdj) UnmarshalText

func (enum *SelfControlRollAdj) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type SheetSettings

type SheetSettings struct {
	SheetSettingsData
	Entity *Entity `json:"-"`
}

SheetSettings holds sheet settings.

func FactorySheetSettings

func FactorySheetSettings() *SheetSettings

FactorySheetSettings returns a new SheetSettings with factory defaults.

func NewSheetSettingsFromFile

func NewSheetSettingsFromFile(fileSystem fs.FS, filePath string) (*SheetSettings, error)

NewSheetSettingsFromFile loads new settings from a file.

func SheetSettingsFor

func SheetSettingsFor(entity *Entity) *SheetSettings

SheetSettingsFor returns the SheetSettings for the given Entity, or the global settings if the Entity is nil.

func (*SheetSettings) Clone

func (s *SheetSettings) Clone(entity *Entity) *SheetSettings

Clone creates a copy of this.

func (*SheetSettings) EnsureValidity

func (s *SheetSettings) EnsureValidity()

EnsureValidity checks the current settings for validity and if they aren't valid, makes them so.

func (*SheetSettings) MarshalJSON

func (s *SheetSettings) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*SheetSettings) Save

func (s *SheetSettings) Save(filePath string) error

Save writes the settings to the file as JSON.

func (*SheetSettings) SetOwningEntity

func (s *SheetSettings) SetOwningEntity(entity *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*SheetSettings) UnmarshalJSON

func (s *SheetSettings) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type SheetSettingsData

type SheetSettingsData struct {
	Page                          *settings.Page              `json:"page,omitempty"`
	BlockLayout                   *BlockLayout                `json:"block_layout,omitempty"`
	Attributes                    *AttributeDefs              `json:"attributes,omitempty"`
	BodyType                      *Body                       `json:"body_type,alt=hit_locations,omitempty"`
	DamageProgression             attribute.DamageProgression `json:"damage_progression"`
	DefaultLengthUnits            measure.LengthUnits         `json:"default_length_units"`
	DefaultWeightUnits            measure.WeightUnits         `json:"default_weight_units"`
	UserDescriptionDisplay        display.Option              `json:"user_description_display"`
	ModifiersDisplay              display.Option              `json:"modifiers_display"`
	NotesDisplay                  display.Option              `json:"notes_display"`
	SkillLevelAdjDisplay          display.Option              `json:"skill_level_adj_display"`
	UseMultiplicativeModifiers    bool                        `json:"use_multiplicative_modifiers,omitempty"`
	UseModifyingDicePlusAdds      bool                        `json:"use_modifying_dice_plus_adds,omitempty"`
	ShowTraitModifierAdj          bool                        `json:"show_trait_modifier_adj,alt=show_advantage_modifier_adj,omitempty"`
	ShowEquipmentModifierAdj      bool                        `json:"show_equipment_modifier_adj,omitempty"`
	ShowSpellAdj                  bool                        `json:"show_spell_adj,omitempty"`
	UseTitleInFooter              bool                        `json:"use_title_in_footer,omitempty"`
	ExcludeUnspentPointsFromTotal bool                        `json:"exclude_unspent_points_from_total"`
}

SheetSettingsData holds the SheetSettings data that is written to disk.

type SheetSettingsResponder

type SheetSettingsResponder interface {
	// SheetSettingsUpdated will be called when the SheetSettings have been updated. The provided Entity will be nil if
	// it was the default SheetSettings that was updated rather than one attached to a specific entity. blockLayout will
	// be true if the BlockLayout was altered, which usually requires a full rebuild.
	SheetSettingsUpdated(entity *Entity, blockLayout bool)
}

SheetSettingsResponder defines the method required to be notified of updates to the SheetSettings.

type Skill

type Skill struct {
	SkillData
	Entity            *Entity
	LevelData         skill.Level
	UnsatisfiedReason string
}

Skill holds the data for a skill.

func NewSkill

func NewSkill(entity *Entity, parent *Skill, container bool) *Skill

NewSkill creates a new Skill.

func NewSkillsFromFile

func NewSkillsFromFile(fileSystem fs.FS, filePath string) ([]*Skill, error)

NewSkillsFromFile loads an Skill list from a file.

func NewTechnique

func NewTechnique(entity *Entity, parent *Skill, skillName string) *Skill

NewTechnique creates a new technique (i.e. a specialized use of a Skill). All parameters may be nil or empty.

func (*Skill) AdjustedPoints

func (s *Skill) AdjustedPoints(tooltip *xio.ByteBuffer) fxp.Int

AdjustedPoints returns the points, adjusted for any bonuses.

func (*Skill) AdjustedRelativeLevel

func (s *Skill) AdjustedRelativeLevel() fxp.Int

AdjustedRelativeLevel returns the relative skill level.

func (*Skill) ApplyNameableKeys

func (s *Skill) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys replaces any nameable keys found with the corresponding values in the provided map.

func (*Skill) BestSwappableSkill

func (s *Skill) BestSwappableSkill() *Skill

BestSwappableSkill returns the best skill to swap with.

func (*Skill) CalculateLevel

func (s *Skill) CalculateLevel() skill.Level

CalculateLevel returns the computed level without updating it.

func (*Skill) CanSwapDefaults

func (s *Skill) CanSwapDefaults() bool

CanSwapDefaults returns true if this skill's default can be swapped.

func (*Skill) CanSwapDefaultsWith

func (s *Skill) CanSwapDefaultsWith(other *Skill) bool

CanSwapDefaultsWith returns true if this skill's default can be swapped with the other skill.

func (*Skill) CellData

func (s *Skill) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*Skill) Clone

func (s *Skill) Clone(entity *Entity, parent *Skill, preserveID bool) *Skill

Clone implements Node.

func (*Skill) DecrementSkillLevel

func (s *Skill) DecrementSkillLevel()

DecrementSkillLevel removes enough points to decrement the skill level to the previous level.

func (*Skill) DefaultSkill

func (s *Skill) DefaultSkill() *Skill

DefaultSkill returns the skill currently defaulted to, or nil.

func (*Skill) Depth

func (s *Skill) Depth() int

Depth returns the number of parents this node has.

func (*Skill) Description

func (s *Skill) Description() string

Description implements WeaponOwner.

func (*Skill) Enabled

func (s *Skill) Enabled() bool

Enabled returns true if this node is enabled.

func (*Skill) FeatureList

func (s *Skill) FeatureList() feature.Features

FeatureList returns the list of Features.

func (*Skill) FillWithNameableKeys

func (s *Skill) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys adds any nameable keys found to the provided map.

func (*Skill) HasDefaultTo

func (s *Skill) HasDefaultTo(other *Skill) bool

HasDefaultTo returns true if the set of possible defaults includes the other skill.

func (*Skill) IncrementSkillLevel

func (s *Skill) IncrementSkillLevel()

IncrementSkillLevel adds enough points to increment the skill level to the next level.

func (*Skill) MarshalJSON

func (s *Skill) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Skill) ModifierNotes

func (s *Skill) ModifierNotes() string

ModifierNotes returns the notes due to modifiers.

func (*Skill) Notes

func (s *Skill) Notes() string

Notes implements WeaponOwner.

func (*Skill) OwningEntity

func (s *Skill) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*Skill) RawPoints

func (s *Skill) RawPoints() fxp.Int

RawPoints returns the unadjusted points.

func (*Skill) RelativeLevel

func (s *Skill) RelativeLevel() string

RelativeLevel returns the adjusted relative level as a string.

func (*Skill) RequiresTL

func (s *Skill) RequiresTL() bool

RequiresTL implements TechLevelProvider.

func (*Skill) SecondaryText

func (s *Skill) SecondaryText(optionChecker func(display.Option) bool) string

SecondaryText returns the less important information that should be displayed with the description.

func (*Skill) SetOwningEntity

func (s *Skill) SetOwningEntity(entity *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*Skill) SetRawPoints

func (s *Skill) SetRawPoints(points fxp.Int) bool

SetRawPoints sets the unadjusted points and updates the level. Returns true if the level changed.

func (*Skill) SetTL

func (s *Skill) SetTL(tl string)

SetTL implements TechLevelProvider.

func (*Skill) String

func (s *Skill) String() string

func (*Skill) SwapDefaults

func (s *Skill) SwapDefaults()

SwapDefaults causes this skill's default to be swapped.

func (*Skill) TL

func (s *Skill) TL() string

TL implements TechLevelProvider.

func (*Skill) TagList

func (s *Skill) TagList() []string

TagList returns the list of tags.

func (*Skill) TechniqueSatisfied

func (s *Skill) TechniqueSatisfied(tooltip *xio.ByteBuffer, prefix string) bool

TechniqueSatisfied returns true if the Technique is satisfied.

func (*Skill) TemplatePickerData added in v5.3.0

func (s *Skill) TemplatePickerData() *TemplatePicker

TemplatePickerData returns the TemplatePicker data, if any.

func (*Skill) UnmarshalJSON

func (s *Skill) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Skill) UpdateLevel

func (s *Skill) UpdateLevel() bool

UpdateLevel updates the level of the skill, returning true if it has changed.

type SkillAdjustmentProvider

type SkillAdjustmentProvider[T NodeTypes] interface {
	RawPointsAdjuster[T]
	IncrementSkillLevel()
	DecrementSkillLevel()
}

SkillAdjustmentProvider defines methods for nodes that can have their skill level adjusted must implement.

type SkillData

type SkillData struct {
	ContainerBase[*Skill]
	SkillEditData
}

SkillData holds the Skill data that is written to disk.

func (*SkillData) ClearUnusedFieldsForType

func (d *SkillData) ClearUnusedFieldsForType()

ClearUnusedFieldsForType zeroes out the fields that are not applicable to this type (container vs not-container).

func (*SkillData) Kind

func (d *SkillData) Kind() string

Kind returns the kind of data.

type SkillDefault

type SkillDefault struct {
	DefaultType    string  `json:"type"`
	Name           string  `json:"name,omitempty"`
	Specialization string  `json:"specialization,omitempty"`
	Modifier       fxp.Int `json:"modifier,omitempty"`
	Level          fxp.Int `json:"level,omitempty"`
	AdjLevel       fxp.Int `json:"adjusted_level,omitempty"`
	Points         fxp.Int `json:"points,omitempty"`
}

SkillDefault holds data for a Skill default.

func (*SkillDefault) ApplyNameableKeys

func (s *SkillDefault) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys replaces any nameable keys found in this SkillDefault with the corresponding values in the provided map.

func (*SkillDefault) CloneWithoutLevelOrPoints

func (s *SkillDefault) CloneWithoutLevelOrPoints() *SkillDefault

CloneWithoutLevelOrPoints creates a copy, but without the level or points set.

func (*SkillDefault) Equivalent

func (s *SkillDefault) Equivalent(other *SkillDefault) bool

Equivalent returns true if this can be considered equivalent to other.

func (*SkillDefault) FillWithNameableKeys

func (s *SkillDefault) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys adds any nameable keys found in this SkillDefault to the provided map.

func (*SkillDefault) FullName

func (s *SkillDefault) FullName(entity *Entity) string

FullName returns the full name of the skill to default from.

func (*SkillDefault) ModifierAsString

func (s *SkillDefault) ModifierAsString() string

ModifierAsString returns the modifier as a string suitable for appending.

func (*SkillDefault) SetType

func (s *SkillDefault) SetType(t string)

SetType sets the type of the SkillDefault.

func (*SkillDefault) SkillBased

func (s *SkillDefault) SkillBased() bool

SkillBased returns true if the Type() is Skill-based.

func (*SkillDefault) SkillLevel

func (s *SkillDefault) SkillLevel(entity *Entity, requirePoints bool, excludes map[string]bool, ruleOf20 bool) fxp.Int

SkillLevel returns the base skill level for this SkillDefault.

func (*SkillDefault) SkillLevelFast

func (s *SkillDefault) SkillLevelFast(entity *Entity, requirePoints bool, excludes map[string]bool, ruleOf20 bool) fxp.Int

SkillLevelFast returns the base skill level for this SkillDefault.

func (*SkillDefault) Type

func (s *SkillDefault) Type() string

Type returns the type of the SkillDefault.

type SkillEditData

type SkillEditData struct {
	Name                         string              `json:"name,omitempty"`
	PageRef                      string              `json:"reference,omitempty"`
	LocalNotes                   string              `json:"notes,omitempty"`
	VTTNotes                     string              `json:"vtt_notes,omitempty"`
	Tags                         []string            `json:"tags,omitempty"`
	Specialization               string              `json:"specialization,omitempty"`                 // Non-container only
	TechLevel                    *string             `json:"tech_level,omitempty"`                     // Non-container only
	Difficulty                   AttributeDifficulty `json:"difficulty,omitempty"`                     // Non-container only
	Points                       fxp.Int             `json:"points,omitempty"`                         // Non-container only
	EncumbrancePenaltyMultiplier fxp.Int             `json:"encumbrance_penalty_multiplier,omitempty"` // Non-container only
	DefaultedFrom                *SkillDefault       `json:"defaulted_from,omitempty"`                 // Non-container only
	Defaults                     []*SkillDefault     `json:"defaults,omitempty"`                       // Non-container only
	TechniqueDefault             *SkillDefault       `json:"default,omitempty"`                        // Non-container only
	TechniqueLimitModifier       *fxp.Int            `json:"limit,omitempty"`                          // Non-container only
	Prereq                       *PrereqList         `json:"prereqs,omitempty"`                        // Non-container only
	Weapons                      []*Weapon           `json:"weapons,omitempty"`                        // Non-container only
	Features                     feature.Features    `json:"features,omitempty"`                       // Non-container only
	Study                        []*Study            `json:"study,omitempty"`                          // Non-container only
	TemplatePicker               *TemplatePicker     `json:"template_picker,omitempty"`                // Container only
}

SkillEditData holds the Skill data that can be edited by the UI detail editor.

func (*SkillEditData) ApplyTo

func (d *SkillEditData) ApplyTo(s *Skill)

ApplyTo implements node.EditorData.

func (*SkillEditData) CopyFrom

func (d *SkillEditData) CopyFrom(s *Skill)

CopyFrom implements node.EditorData.

type SkillListProvider

type SkillListProvider interface {
	EntityProvider
	SkillList() []*Skill
	SetSkillList(list []*Skill)
}

SkillListProvider defines the method needed to access the skill list data.

type SkillPrereq

type SkillPrereq struct {
	Parent                 *PrereqList      `json:"-"`
	Type                   prereq.Type      `json:"type"`
	Has                    bool             `json:"has"`
	NameCriteria           criteria.String  `json:"name,omitempty"`
	LevelCriteria          criteria.Numeric `json:"level,omitempty"`
	SpecializationCriteria criteria.String  `json:"specialization,omitempty"`
}

SkillPrereq holds a prerequisite for a skill.

func NewSkillPrereq

func NewSkillPrereq() *SkillPrereq

NewSkillPrereq creates a new SkillPrereq.

func (*SkillPrereq) ApplyNameableKeys

func (s *SkillPrereq) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys implements Prereq.

func (*SkillPrereq) Clone

func (s *SkillPrereq) Clone(parent *PrereqList) Prereq

Clone implements Prereq.

func (*SkillPrereq) FillWithNameableKeys

func (s *SkillPrereq) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys implements Prereq.

func (*SkillPrereq) ParentList

func (s *SkillPrereq) ParentList() *PrereqList

ParentList implements Prereq.

func (*SkillPrereq) PrereqType

func (s *SkillPrereq) PrereqType() prereq.Type

PrereqType implements Prereq.

func (*SkillPrereq) Satisfied

func (s *SkillPrereq) Satisfied(entity *Entity, exclude any, tooltip *xio.ByteBuffer, prefix string) bool

Satisfied implements Prereq.

type Spell

type Spell struct {
	SpellData
	Entity            *Entity
	LevelData         skill.Level
	UnsatisfiedReason string
}

Spell holds the data for a spell.

func NewRitualMagicSpell

func NewRitualMagicSpell(entity *Entity, parent *Spell, _ bool) *Spell

NewRitualMagicSpell creates a new Ritual Magic Spell.

func NewSpell

func NewSpell(entity *Entity, parent *Spell, container bool) *Spell

NewSpell creates a new Spell.

func NewSpellsFromFile

func NewSpellsFromFile(fileSystem fs.FS, filePath string) ([]*Spell, error)

NewSpellsFromFile loads an Spell list from a file.

func (*Spell) AdjustedPoints

func (s *Spell) AdjustedPoints(tooltip *xio.ByteBuffer) fxp.Int

AdjustedPoints returns the points, adjusted for any bonuses.

func (*Spell) AdjustedRelativeLevel

func (s *Spell) AdjustedRelativeLevel() fxp.Int

AdjustedRelativeLevel returns the relative skill level.

func (*Spell) ApplyNameableKeys

func (s *Spell) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys replaces any nameable keys found with the corresponding values in the provided map.

func (*Spell) CalculateLevel

func (s *Spell) CalculateLevel() skill.Level

CalculateLevel returns the computed level without updating it.

func (*Spell) CellData

func (s *Spell) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*Spell) Clone

func (s *Spell) Clone(entity *Entity, parent *Spell, preserveID bool) *Spell

Clone implements Node.

func (*Spell) DecrementSkillLevel

func (s *Spell) DecrementSkillLevel()

DecrementSkillLevel removes enough points to decrement the skill level to the previous level.

func (*Spell) Depth

func (s *Spell) Depth() int

Depth returns the number of parents this node has.

func (*Spell) Description

func (s *Spell) Description() string

Description implements WeaponOwner.

func (*Spell) Enabled

func (s *Spell) Enabled() bool

Enabled returns true if this node is enabled.

func (*Spell) FeatureList

func (s *Spell) FeatureList() feature.Features

FeatureList returns the list of Features.

func (*Spell) FillWithNameableKeys

func (s *Spell) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys adds any nameable keys found to the provided map.

func (*Spell) IncrementSkillLevel

func (s *Spell) IncrementSkillLevel()

IncrementSkillLevel adds enough points to increment the skill level to the next level.

func (*Spell) MarshalJSON

func (s *Spell) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Spell) Notes

func (s *Spell) Notes() string

Notes implements WeaponOwner.

func (*Spell) OwningEntity

func (s *Spell) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*Spell) RawPoints

func (s *Spell) RawPoints() fxp.Int

RawPoints returns the unadjusted points.

func (*Spell) RelativeLevel

func (s *Spell) RelativeLevel() string

RelativeLevel returns the adjusted relative level as a string.

func (*Spell) RequiresTL

func (s *Spell) RequiresTL() bool

RequiresTL implements TechLevelProvider.

func (*Spell) RitualMagicSatisfied

func (s *Spell) RitualMagicSatisfied(tooltip *xio.ByteBuffer, prefix string) bool

RitualMagicSatisfied returns true if the Ritual Magic Spell is satisfied.

func (*Spell) Rituals

func (s *Spell) Rituals() string

Rituals returns the rituals required to cast the spell.

func (*Spell) SecondaryText

func (s *Spell) SecondaryText(optionChecker func(display.Option) bool) string

SecondaryText returns the less important information that should be displayed with the description.

func (*Spell) SetOwningEntity

func (s *Spell) SetOwningEntity(entity *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*Spell) SetRawPoints

func (s *Spell) SetRawPoints(points fxp.Int) bool

SetRawPoints sets the unadjusted points and updates the level. Returns true if the level changed.

func (*Spell) SetTL

func (s *Spell) SetTL(tl string)

SetTL implements TechLevelProvider.

func (*Spell) String

func (s *Spell) String() string

func (*Spell) TL

func (s *Spell) TL() string

TL implements TechLevelProvider.

func (*Spell) TagList

func (s *Spell) TagList() []string

TagList returns the list of tags.

func (*Spell) TemplatePickerData added in v5.3.0

func (s *Spell) TemplatePickerData() *TemplatePicker

TemplatePickerData returns the TemplatePicker data, if any.

func (*Spell) UnmarshalJSON

func (s *Spell) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Spell) UpdateLevel

func (s *Spell) UpdateLevel() bool

UpdateLevel updates the level of the spell, returning true if it has changed.

type SpellData

type SpellData struct {
	ContainerBase[*Spell]
	SpellEditData
}

SpellData holds the Spell data that is written to disk.

func (*SpellData) ClearUnusedFieldsForType

func (d *SpellData) ClearUnusedFieldsForType()

ClearUnusedFieldsForType zeroes out the fields that are not applicable to this type (container vs not-container).

func (*SpellData) Kind

func (d *SpellData) Kind() string

Kind returns the kind of data.

type SpellEditData

type SpellEditData struct {
	Name              string              `json:"name,omitempty"`
	PageRef           string              `json:"reference,omitempty"`
	LocalNotes        string              `json:"notes,omitempty"`
	VTTNotes          string              `json:"vtt_notes,omitempty"`
	Tags              []string            `json:"tags,omitempty"`
	TechLevel         *string             `json:"tech_level,omitempty"`       // Non-container only
	Difficulty        AttributeDifficulty `json:"difficulty,omitempty"`       // Non-container only
	College           CollegeList         `json:"college,omitempty"`          // Non-container only
	PowerSource       string              `json:"power_source,omitempty"`     // Non-container only
	Class             string              `json:"spell_class,omitempty"`      // Non-container only
	Resist            string              `json:"resist,omitempty"`           // Non-container only
	CastingCost       string              `json:"casting_cost,omitempty"`     // Non-container only
	MaintenanceCost   string              `json:"maintenance_cost,omitempty"` // Non-container only
	CastingTime       string              `json:"casting_time,omitempty"`     // Non-container only
	Duration          string              `json:"duration,omitempty"`         // Non-container only
	RitualSkillName   string              `json:"base_skill,omitempty"`       // Non-container only
	RitualPrereqCount int                 `json:"prereq_count,omitempty"`     // Non-container only
	Points            fxp.Int             `json:"points,omitempty"`           // Non-container only
	Prereq            *PrereqList         `json:"prereqs,omitempty"`          // Non-container only
	Weapons           []*Weapon           `json:"weapons,omitempty"`          // Non-container only
	Study             []*Study            `json:"study,omitempty"`            // Non-container only
	TemplatePicker    *TemplatePicker     `json:"template_picker,omitempty"`  // Container only
}

SpellEditData holds the Spell data that can be edited by the UI detail editor.

func (*SpellEditData) ApplyTo

func (d *SpellEditData) ApplyTo(s *Spell)

ApplyTo implements node.EditorData.

func (*SpellEditData) CopyFrom

func (d *SpellEditData) CopyFrom(s *Spell)

CopyFrom implements node.EditorData.

type SpellListProvider

type SpellListProvider interface {
	EntityProvider
	SpellList() []*Spell
	SetSpellList(list []*Spell)
}

SpellListProvider defines the method needed to access the spell list data.

type SpellPrereq

type SpellPrereq struct {
	Parent            *PrereqList          `json:"-"`
	Type              prereq.Type          `json:"type"`
	SubType           spell.ComparisonType `json:"sub_type"`
	Has               bool                 `json:"has"`
	QualifierCriteria criteria.String      `json:"qualifier,omitempty"`
	QuantityCriteria  criteria.Numeric     `json:"quantity,omitempty"`
}

SpellPrereq holds a prerequisite for a spell.

func NewSpellPrereq

func NewSpellPrereq() *SpellPrereq

NewSpellPrereq creates a new SpellPrereq.

func (*SpellPrereq) ApplyNameableKeys

func (s *SpellPrereq) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys implements Prereq.

func (*SpellPrereq) Clone

func (s *SpellPrereq) Clone(parent *PrereqList) Prereq

Clone implements Prereq.

func (*SpellPrereq) FillWithNameableKeys

func (s *SpellPrereq) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys implements Prereq.

func (*SpellPrereq) ParentList

func (s *SpellPrereq) ParentList() *PrereqList

ParentList implements Prereq.

func (*SpellPrereq) PrereqType

func (s *SpellPrereq) PrereqType() prereq.Type

PrereqType implements Prereq.

func (*SpellPrereq) Satisfied

func (s *SpellPrereq) Satisfied(entity *Entity, exclude any, tooltip *xio.ByteBuffer, prefix string) bool

Satisfied implements Prereq.

type Study added in v5.3.0

type Study struct {
	Type  StudyType `json:"type"`
	Hours fxp.Int   `json:"hours"`
	Note  string    `json:"note,omitempty"`
}

Study holds data about a single study session.

func (*Study) Clone added in v5.3.0

func (s *Study) Clone() *Study

Clone creates a copy of the TemplatePicker.

type StudyType added in v5.3.0

type StudyType byte

StudyType holds the type of study.

const (
	SelfStudyType StudyType = iota
	JobStudyType
	TeacherStudyType
	IntensiveStudyType
	LastStudyType = IntensiveStudyType
)

Possible values.

func ExtractStudyType added in v5.3.0

func ExtractStudyType(str string) StudyType

ExtractStudyType extracts the value from a string.

func (StudyType) EnsureValid added in v5.3.0

func (enum StudyType) EnsureValid() StudyType

EnsureValid ensures this is of a known value.

func (StudyType) Key added in v5.3.0

func (enum StudyType) Key() string

Key returns the key used in serialization.

func (StudyType) Limitations added in v5.3.0

func (enum StudyType) Limitations() []string

Limitations returns a list of strings describing the limitations when doing this type of study.

func (StudyType) MarshalText added in v5.3.0

func (enum StudyType) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (StudyType) Multiplier added in v5.3.0

func (enum StudyType) Multiplier() fxp.Int

Multiplier returns the amount to multiply hours spent by for effective study hours.

func (StudyType) String added in v5.3.0

func (enum StudyType) String() string

String implements fmt.Stringer.

func (*StudyType) UnmarshalText added in v5.3.0

func (enum *StudyType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type TechLevelProvider

type TechLevelProvider[T NodeTypes] interface {
	Node[T]
	RequiresTL() bool
	TL() string
	SetTL(tl string)
}

TechLevelProvider defines methods that a TechLevel provider must implement.

type Template

type Template struct {
	Type      string       `json:"type"`
	Version   int          `json:"version"`
	ID        uuid.UUID    `json:"id"`
	Traits    []*Trait     `json:"traits,alt=advantages,omitempty"`
	Skills    []*Skill     `json:"skills,omitempty"`
	Spells    []*Spell     `json:"spells,omitempty"`
	Equipment []*Equipment `json:"equipment,omitempty"`
	Notes     []*Note      `json:"notes,omitempty"`
}

Template holds the GURPS Template data that is written to disk.

func NewTemplate

func NewTemplate() *Template

NewTemplate creates a new Template.

func NewTemplateFromFile

func NewTemplateFromFile(fileSystem fs.FS, filePath string) (*Template, error)

NewTemplateFromFile loads a Template from a file.

func (*Template) CRC64

func (t *Template) CRC64() uint64

CRC64 computes a CRC-64 value for the canonical disk format of the data.

func (*Template) CarriedEquipmentList

func (t *Template) CarriedEquipmentList() []*Equipment

CarriedEquipmentList implements ListProvider

func (*Template) Entity

func (t *Template) Entity() *Entity

Entity implements EntityProvider.

func (*Template) NoteList

func (t *Template) NoteList() []*Note

NoteList implements ListProvider

func (*Template) OtherEquipmentList

func (t *Template) OtherEquipmentList() []*Equipment

OtherEquipmentList implements ListProvider

func (*Template) Save

func (t *Template) Save(filePath string) error

Save the Template to a file as JSON.

func (*Template) SetCarriedEquipmentList

func (t *Template) SetCarriedEquipmentList(list []*Equipment)

SetCarriedEquipmentList implements ListProvider

func (*Template) SetNoteList

func (t *Template) SetNoteList(list []*Note)

SetNoteList implements ListProvider

func (*Template) SetOtherEquipmentList

func (t *Template) SetOtherEquipmentList(_ []*Equipment)

SetOtherEquipmentList implements ListProvider

func (*Template) SetSkillList

func (t *Template) SetSkillList(list []*Skill)

SetSkillList implements ListProvider

func (*Template) SetSpellList

func (t *Template) SetSpellList(list []*Spell)

SetSpellList implements ListProvider

func (*Template) SetTraitList

func (t *Template) SetTraitList(list []*Trait)

SetTraitList implements ListProvider

func (*Template) SkillList

func (t *Template) SkillList() []*Skill

SkillList implements ListProvider

func (*Template) SpellList

func (t *Template) SpellList() []*Spell

SpellList implements ListProvider

func (*Template) TraitList

func (t *Template) TraitList() []*Trait

TraitList implements ListProvider

type TemplatePicker added in v5.3.0

type TemplatePicker struct {
	Type      TemplatePickerType `json:"type"`
	Qualifier criteria.Numeric   `json:"qualifier"`
}

TemplatePicker holds the data necessary to allow a template choice to be made.

func (*TemplatePicker) Clone added in v5.3.0

func (t *TemplatePicker) Clone() *TemplatePicker

Clone creates a copy of the TemplatePicker.

func (*TemplatePicker) Description added in v5.3.0

func (t *TemplatePicker) Description() string

Description returns a description of the picker action.

func (*TemplatePicker) ShouldOmit added in v5.3.0

func (t *TemplatePicker) ShouldOmit() bool

ShouldOmit implements json.Omitter.

type TemplatePickerProvider added in v5.3.0

type TemplatePickerProvider interface {
	TemplatePickerData() *TemplatePicker
}

TemplatePickerProvider defines the methods a TemplatePicker provider has.

type TemplatePickerType added in v5.3.0

type TemplatePickerType byte

TemplatePickerType holds the type of template picker.

const (
	NotApplicableTemplatePickerType TemplatePickerType = iota
	CountTemplatePickerType
	PointsTemplatePickerType
	LastTemplatePickerType = PointsTemplatePickerType
)

Possible values.

func ExtractTemplatePickerType added in v5.3.0

func ExtractTemplatePickerType(str string) TemplatePickerType

ExtractTemplatePickerType extracts the value from a string.

func (TemplatePickerType) EnsureValid added in v5.3.0

func (enum TemplatePickerType) EnsureValid() TemplatePickerType

EnsureValid ensures this is of a known value.

func (TemplatePickerType) Key added in v5.3.0

func (enum TemplatePickerType) Key() string

Key returns the key used in serialization.

func (TemplatePickerType) MarshalText added in v5.3.0

func (enum TemplatePickerType) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (TemplatePickerType) String added in v5.3.0

func (enum TemplatePickerType) String() string

String implements fmt.Stringer.

func (*TemplatePickerType) UnmarshalText added in v5.3.0

func (enum *TemplatePickerType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Trait

type Trait struct {
	TraitData
	Entity            *Entity
	UnsatisfiedReason string
}

Trait holds an advantage, disadvantage, quirk, or perk.

func NewNaturalAttacks

func NewNaturalAttacks(entity *Entity, parent *Trait) *Trait

NewNaturalAttacks creates a new "Natural Attacks" trait.

func NewTrait

func NewTrait(entity *Entity, parent *Trait, container bool) *Trait

NewTrait creates a new Trait.

func NewTraitsFromFile

func NewTraitsFromFile(fileSystem fs.FS, filePath string) ([]*Trait, error)

NewTraitsFromFile loads an Trait list from a file.

func (*Trait) ActiveModifierFor

func (a *Trait) ActiveModifierFor(name string) *TraitModifier

ActiveModifierFor returns the first modifier that matches the name (case-insensitive).

func (*Trait) AdjustedPoints

func (a *Trait) AdjustedPoints() fxp.Int

AdjustedPoints returns the total points, taking levels and modifiers into account.

func (*Trait) AllModifiers

func (a *Trait) AllModifiers() []*TraitModifier

AllModifiers returns the modifiers plus any inherited from parents.

func (*Trait) ApplyNameableKeys

func (a *Trait) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys replaces any nameable keys found with the corresponding values in the provided map.

func (*Trait) CellData

func (a *Trait) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*Trait) Clone

func (a *Trait) Clone(entity *Entity, parent *Trait, preserveID bool) *Trait

Clone implements Node.

func (*Trait) Depth

func (a *Trait) Depth() int

Depth returns the number of parents this node has.

func (*Trait) Description

func (a *Trait) Description() string

Description returns a description, which doesn't include any levels.

func (*Trait) EffectivelyDisabled added in v5.1.0

func (a *Trait) EffectivelyDisabled() bool

EffectivelyDisabled returns true if this node or a parent is disabled.

func (*Trait) Enabled

func (a *Trait) Enabled() bool

Enabled returns true if this Trait and all of its parents are enabled.

func (*Trait) FeatureList

func (a *Trait) FeatureList() feature.Features

FeatureList returns the list of Features.

func (*Trait) FillWithNameableKeys

func (a *Trait) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys adds any nameable keys found to the provided map.

func (*Trait) IsLeveled

func (a *Trait) IsLeveled() bool

IsLeveled returns true if the Trait is capable of having levels.

func (*Trait) MarshalJSON

func (a *Trait) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Trait) ModifierNotes

func (a *Trait) ModifierNotes() string

ModifierNotes returns the notes due to modifiers.

func (*Trait) Notes

func (a *Trait) Notes() string

Notes returns the local notes.

func (*Trait) OwningEntity

func (a *Trait) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*Trait) SecondaryText

func (a *Trait) SecondaryText(optionChecker func(display.Option) bool) string

SecondaryText returns the "secondary" text: the text display below an Trait.

func (*Trait) SetOwningEntity

func (a *Trait) SetOwningEntity(entity *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*Trait) String

func (a *Trait) String() string

String implements fmt.Stringer.

func (*Trait) TagList

func (a *Trait) TagList() []string

TagList returns the list of tags.

func (*Trait) TemplatePickerData added in v5.3.0

func (a *Trait) TemplatePickerData() *TemplatePicker

TemplatePickerData returns the TemplatePicker data, if any.

func (*Trait) UnmarshalJSON

func (a *Trait) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type TraitData

type TraitData struct {
	ContainerBase[*Trait]
	TraitEditData
}

TraitData holds the Trait data that is written to disk.

func (*TraitData) ClearUnusedFieldsForType

func (d *TraitData) ClearUnusedFieldsForType()

ClearUnusedFieldsForType zeroes out the fields that are not applicable to this type (container vs not-container).

func (*TraitData) Kind

func (d *TraitData) Kind() string

Kind returns the kind of data.

type TraitEditData

type TraitEditData struct {
	Name           string                `json:"name,omitempty"`
	PageRef        string                `json:"reference,omitempty"`
	LocalNotes     string                `json:"notes,omitempty"`
	VTTNotes       string                `json:"vtt_notes,omitempty"`
	Ancestry       string                `json:"ancestry,omitempty"` // Container only
	UserDesc       string                `json:"userdesc,omitempty"`
	Tags           []string              `json:"tags,omitempty"`
	Modifiers      []*TraitModifier      `json:"modifiers,omitempty"`
	BasePoints     fxp.Int               `json:"base_points,omitempty"`      // Non-container only
	Levels         fxp.Int               `json:"levels,omitempty"`           // Non-container only
	PointsPerLevel fxp.Int               `json:"points_per_level,omitempty"` // Non-container only
	Prereq         *PrereqList           `json:"prereqs,omitempty"`          // Non-container only
	Weapons        []*Weapon             `json:"weapons,omitempty"`          // Non-container only
	Features       feature.Features      `json:"features,omitempty"`         // Non-container only
	Study          []*Study              `json:"study,omitempty"`            // Non-container only
	TemplatePicker *TemplatePicker       `json:"template_picker,omitempty"`  // Container only
	CR             trait.SelfControlRoll `json:"cr,omitempty"`
	CRAdj          SelfControlRollAdj    `json:"cr_adj,omitempty"`
	ContainerType  trait.ContainerType   `json:"container_type,omitempty"` // Container only
	Disabled       bool                  `json:"disabled,omitempty"`
	RoundCostDown  bool                  `json:"round_down,omitempty"` // Non-container only
	CanLevel       bool                  `json:"can_level,omitempty"`  // Non-container only
}

TraitEditData holds the Trait data that can be edited by the UI detail editor.

func (*TraitEditData) ApplyTo

func (d *TraitEditData) ApplyTo(t *Trait)

ApplyTo implements node.EditorData.

func (*TraitEditData) CopyFrom

func (d *TraitEditData) CopyFrom(t *Trait)

CopyFrom implements node.EditorData.

type TraitListProvider

type TraitListProvider interface {
	EntityProvider
	TraitList() []*Trait
	SetTraitList(list []*Trait)
}

TraitListProvider defines the method needed to access the trait list data.

type TraitModifier

type TraitModifier struct {
	TraitModifierData
	Entity *Entity
}

TraitModifier holds a modifier to an Trait.

func NewTraitModifier

func NewTraitModifier(entity *Entity, parent *TraitModifier, container bool) *TraitModifier

NewTraitModifier creates a TraitModifier.

func NewTraitModifiersFromFile

func NewTraitModifiersFromFile(fileSystem fs.FS, filePath string) ([]*TraitModifier, error)

NewTraitModifiersFromFile loads a TraitModifier list from a file.

func (*TraitModifier) ApplyNameableKeys

func (m *TraitModifier) ApplyNameableKeys(keyMap map[string]string)

ApplyNameableKeys replaces any nameable keys found in this TraitModifier with the corresponding values in the provided map.

func (*TraitModifier) CellData

func (m *TraitModifier) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*TraitModifier) Clone

func (m *TraitModifier) Clone(entity *Entity, parent *TraitModifier, preserveID bool) *TraitModifier

Clone implements Node.

func (*TraitModifier) CostDescription

func (m *TraitModifier) CostDescription() string

CostDescription returns the formatted cost.

func (*TraitModifier) CostModifier

func (m *TraitModifier) CostModifier() fxp.Int

CostModifier returns the total cost modifier.

func (*TraitModifier) Depth

func (m *TraitModifier) Depth() int

Depth returns the number of parents this node has.

func (*TraitModifier) Enabled

func (m *TraitModifier) Enabled() bool

Enabled returns true if this node is enabled.

func (*TraitModifier) FillWithNameableKeys

func (m *TraitModifier) FillWithNameableKeys(keyMap map[string]string)

FillWithNameableKeys adds any nameable keys found in this TraitModifier to the provided map.

func (*TraitModifier) FullCostDescription added in v5.2.0

func (m *TraitModifier) FullCostDescription() string

FullCostDescription is the same as CostDescription().

func (*TraitModifier) FullDescription

func (m *TraitModifier) FullDescription() string

FullDescription returns a full description.

func (*TraitModifier) HasLevels

func (m *TraitModifier) HasLevels() bool

HasLevels returns true if this TraitModifier has levels.

func (*TraitModifier) MarshalJSON

func (m *TraitModifier) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*TraitModifier) OwningEntity

func (m *TraitModifier) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*TraitModifier) SecondaryText

func (m *TraitModifier) SecondaryText(optionChecker func(display.Option) bool) string

SecondaryText returns the "secondary" text: the text display below an Trait.

func (*TraitModifier) SetEnabled

func (m *TraitModifier) SetEnabled(enabled bool)

SetEnabled makes the node enabled, if possible.

func (*TraitModifier) SetOwningEntity

func (m *TraitModifier) SetOwningEntity(entity *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*TraitModifier) String

func (m *TraitModifier) String() string

func (*TraitModifier) TagList added in v5.2.0

func (m *TraitModifier) TagList() []string

TagList returns the list of tags.

func (*TraitModifier) UnmarshalJSON

func (m *TraitModifier) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type TraitModifierData

type TraitModifierData struct {
	ContainerBase[*TraitModifier]
	TraitModifierEditData
}

TraitModifierData holds the TraitModifier data that is written to disk.

func (*TraitModifierData) ClearUnusedFieldsForType

func (d *TraitModifierData) ClearUnusedFieldsForType()

ClearUnusedFieldsForType zeroes out the fields that are not applicable to this type (container vs not-container).

func (*TraitModifierData) Kind

func (d *TraitModifierData) Kind() string

Kind returns the kind of data.

type TraitModifierEditData

type TraitModifierEditData struct {
	Name       string                 `json:"name,omitempty"`
	PageRef    string                 `json:"reference,omitempty"`
	LocalNotes string                 `json:"notes,omitempty"`
	VTTNotes   string                 `json:"vtt_notes,omitempty"`
	Tags       []string               `json:"tags,omitempty"`
	Cost       fxp.Int                `json:"cost,omitempty"`      // Non-container only
	Levels     fxp.Int                `json:"levels,omitempty"`    // Non-container only
	Affects    trait.Affects          `json:"affects,omitempty"`   // Non-container only
	CostType   trait.ModifierCostType `json:"cost_type,omitempty"` // Non-container only
	Disabled   bool                   `json:"disabled,omitempty"`  // Non-container only
	Features   feature.Features       `json:"features,omitempty"`  // Non-container only
}

TraitModifierEditData holds the TraitModifier data that can be edited by the UI detail editor.

func (*TraitModifierEditData) ApplyTo

func (d *TraitModifierEditData) ApplyTo(mod *TraitModifier)

ApplyTo implements node.EditorData.

func (*TraitModifierEditData) CopyFrom

func (d *TraitModifierEditData) CopyFrom(mod *TraitModifier)

CopyFrom implements node.EditorData.

type TraitModifierListProvider

type TraitModifierListProvider interface {
	EntityProvider
	TraitModifierList() []*TraitModifier
	SetTraitModifierList(list []*TraitModifier)
}

TraitModifierListProvider defines the method needed to access the trait modifier list data.

type TraitPrereq

type TraitPrereq struct {
	Parent        *PrereqList      `json:"-"`
	Type          prereq.Type      `json:"type"`
	Has           bool             `json:"has"`
	NameCriteria  criteria.String  `json:"name,omitempty"`
	LevelCriteria criteria.Numeric `json:"level,omitempty"`
	NotesCriteria criteria.String  `json:"notes,omitempty"`
}

TraitPrereq holds a prereq against a Trait.

func NewTraitPrereq

func NewTraitPrereq() *TraitPrereq

NewTraitPrereq creates a new TraitPrereq.

func (*TraitPrereq) ApplyNameableKeys

func (a *TraitPrereq) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys implements Prereq.

func (*TraitPrereq) Clone

func (a *TraitPrereq) Clone(parent *PrereqList) Prereq

Clone implements Prereq.

func (*TraitPrereq) FillWithNameableKeys

func (a *TraitPrereq) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys implements Prereq.

func (*TraitPrereq) ParentList

func (a *TraitPrereq) ParentList() *PrereqList

ParentList implements Prereq.

func (*TraitPrereq) PrereqType

func (a *TraitPrereq) PrereqType() prereq.Type

PrereqType implements Prereq.

func (*TraitPrereq) Satisfied

func (a *TraitPrereq) Satisfied(entity *Entity, exclude any, tooltip *xio.ByteBuffer, prefix string) bool

Satisfied implements Prereq.

type Weapon

type Weapon struct {
	WeaponData
	Owner WeaponOwner
}

Weapon holds the stats for a weapon.

func ExtractWeaponsOfType

func ExtractWeaponsOfType(desiredType weapon.Type, list []*Weapon) []*Weapon

ExtractWeaponsOfType filters the input list down to only those weapons of the given type.

func NewWeapon

func NewWeapon(owner WeaponOwner, weaponType weapon.Type) *Weapon

NewWeapon creates a new weapon of the given type.

func SeparateWeapons

func SeparateWeapons(list []*Weapon) (melee, ranged []*Weapon)

SeparateWeapons returns separate lists for melee and ranged weapons found in the input list.

func (*Weapon) ApplyNameableKeys

func (w *Weapon) ApplyNameableKeys(m map[string]string)

ApplyNameableKeys replaces any nameable keys found in this Weapon with the corresponding values in the provided map.

func (*Weapon) ApplyTo

func (w *Weapon) ApplyTo(t *Weapon)

ApplyTo implements node.EditorData.

func (*Weapon) CellData

func (w *Weapon) CellData(column int, data *CellData)

CellData returns the cell data information for the given column.

func (*Weapon) Clone

func (w *Weapon) Clone(_ *Entity, _ *Weapon, preserveID bool) *Weapon

Clone implements Node.

func (*Weapon) Container

func (w *Weapon) Container() bool

Container returns true if this is a container.

func (*Weapon) CopyFrom

func (w *Weapon) CopyFrom(t *Weapon)

CopyFrom implements node.EditorData.

func (*Weapon) Enabled

func (w *Weapon) Enabled() bool

Enabled returns true if this node is enabled.

func (*Weapon) EncumbrancePenalty

func (w *Weapon) EncumbrancePenalty(entity *Entity, tooltip *xio.ByteBuffer) fxp.Int

EncumbrancePenalty returns the current encumbrance penalty.

func (*Weapon) Entity

func (w *Weapon) Entity() *Entity

Entity returns the owning entity, if any.

func (*Weapon) FillWithNameableKeys

func (w *Weapon) FillWithNameableKeys(m map[string]string)

FillWithNameableKeys adds any nameable keys found in this Weapon to the provided map.

func (*Weapon) HasChildren

func (w *Weapon) HasChildren() bool

HasChildren returns true if this node has children.

func (*Weapon) HashCode

func (w *Weapon) HashCode() uint32

HashCode returns a hash value for this weapon's resolved state.

func (*Weapon) Kind

func (w *Weapon) Kind() string

Kind returns the kind of data.

func (*Weapon) Less

func (w *Weapon) Less(other *Weapon) bool

Less returns true if this weapon should be sorted above the other weapon.

func (*Weapon) MarshalJSON

func (w *Weapon) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Weapon) NodeChildren

func (w *Weapon) NodeChildren() []*Weapon

NodeChildren returns the children of this node, if any.

func (*Weapon) Notes

func (w *Weapon) Notes() string

Notes returns the notes for this weapon.

func (*Weapon) Open

func (w *Weapon) Open() bool

Open returns true if this node is currently open.

func (*Weapon) OwningEntity

func (w *Weapon) OwningEntity() *Entity

OwningEntity returns the owning Entity.

func (*Weapon) PC

func (w *Weapon) PC() *Entity

PC returns the owning PC, if any.

func (*Weapon) Parent

func (w *Weapon) Parent() *Weapon

Parent returns the parent.

func (*Weapon) ResolvedBlock

func (w *Weapon) ResolvedBlock(tooltip *xio.ByteBuffer) string

ResolvedBlock returns the resolved block level.

func (*Weapon) ResolvedMinimumStrength

func (w *Weapon) ResolvedMinimumStrength() fxp.Int

ResolvedMinimumStrength returns the resolved minimum strength required to use this weapon, or 0 if there is none.

func (*Weapon) ResolvedParry

func (w *Weapon) ResolvedParry(tooltip *xio.ByteBuffer) string

ResolvedParry returns the resolved parry level.

func (*Weapon) ResolvedRange

func (w *Weapon) ResolvedRange() string

ResolvedRange returns the range, fully resolved for the user's ST, if possible.

func (*Weapon) SetChildren

func (w *Weapon) SetChildren(_ []*Weapon)

SetChildren sets the children of this node.

func (*Weapon) SetOpen

func (w *Weapon) SetOpen(_ bool)

SetOpen sets the current open state for this node.

func (*Weapon) SetOwner

func (w *Weapon) SetOwner(owner WeaponOwner)

SetOwner sets the owner and ensures sub-components have their owners set.

func (*Weapon) SetOwningEntity

func (w *Weapon) SetOwningEntity(_ *Entity)

SetOwningEntity sets the owning entity and configures any sub-components as needed.

func (*Weapon) SetParent

func (w *Weapon) SetParent(_ *Weapon)

SetParent sets the parent.

func (*Weapon) SkillLevel

func (w *Weapon) SkillLevel(tooltip *xio.ByteBuffer) fxp.Int

SkillLevel returns the resolved skill level.

func (*Weapon) String

func (w *Weapon) String() string

func (*Weapon) UUID

func (w *Weapon) UUID() uuid.UUID

UUID returns the UUID of this data.

func (*Weapon) UnmarshalJSON

func (w *Weapon) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type WeaponDamage

type WeaponDamage struct {
	WeaponDamageData
	Owner *Weapon
}

WeaponDamage holds the damage information for a weapon.

func (*WeaponDamage) Clone

func (w *WeaponDamage) Clone(owner *Weapon) *WeaponDamage

Clone creates a copy of this data.

func (*WeaponDamage) DamageTooltip

func (w *WeaponDamage) DamageTooltip() string

DamageTooltip returns a formatted tooltip for the damage.

func (*WeaponDamage) MarshalJSON

func (w *WeaponDamage) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*WeaponDamage) ResolvedDamage

func (w *WeaponDamage) ResolvedDamage(tooltip *xio.ByteBuffer) string

ResolvedDamage returns the damage, fully resolved for the user's sw or thr, if possible.

func (*WeaponDamage) String

func (w *WeaponDamage) String() string

func (*WeaponDamage) UnmarshalJSON

func (w *WeaponDamage) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type WeaponDamageData

type WeaponDamageData struct {
	Type                      string                `json:"type"`
	StrengthType              weapon.StrengthDamage `json:"st,omitempty"`
	Base                      *dice.Dice            `json:"base,omitempty"`
	ArmorDivisor              fxp.Int               `json:"armor_divisor,omitempty"`
	Fragmentation             *dice.Dice            `json:"fragmentation,omitempty"`
	FragmentationArmorDivisor fxp.Int               `json:"fragmentation_armor_divisor,omitempty"`
	FragmentationType         string                `json:"fragmentation_type,omitempty"`
	ModifierPerDie            fxp.Int               `json:"modifier_per_die,omitempty"`
}

WeaponDamageData holds the WeaponDamage data that is written to disk.

type WeaponData

type WeaponData struct {
	ID              uuid.UUID       `json:"id"`
	Type            weapon.Type     `json:"type"`
	Damage          WeaponDamage    `json:"damage"`
	MinimumStrength string          `json:"strength,omitempty"`
	Usage           string          `json:"usage,omitempty"`
	UsageNotes      string          `json:"usage_notes,omitempty"`
	Reach           string          `json:"reach,omitempty"`
	Parry           string          `json:"parry,omitempty"`
	Block           string          `json:"block,omitempty"`
	Accuracy        string          `json:"accuracy,omitempty"`
	Range           string          `json:"range,omitempty"`
	RateOfFire      string          `json:"rate_of_fire,omitempty"`
	Shots           string          `json:"shots,omitempty"`
	Bulk            string          `json:"bulk,omitempty"`
	Recoil          string          `json:"recoil,omitempty"`
	Defaults        []*SkillDefault `json:"defaults,omitempty"`
}

WeaponData holds the Weapon data that is written to disk.

type WeaponListProvider

type WeaponListProvider interface {
	EntityProvider
	WeaponOwner() WeaponOwner
	Weapons(weaponType weapon.Type) []*Weapon
	SetWeapons(weaponType weapon.Type, list []*Weapon)
}

WeaponListProvider defines the method needed to access the weapon list data.

type WeaponOwner

type WeaponOwner interface {
	fmt.Stringer
	OwningEntity() *Entity
	Description() string
	Notes() string
	FeatureList() feature.Features
	TagList() []string
}

WeaponOwner defines the methods required of a Weapon owner.

Jump to

Keyboard shortcuts

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