Documentation
¶
Index ¶
- Constants
- func CreatePetSpec(p *Pet) error
- func DeletePetSpec(petType string) error
- func GetAllPetSpecs() map[string]Pet
- func GetMemoryUsage() map[string]util.MemoryResult
- func LoadDataFiles()
- func SavePetScript(petType string, content string) error
- func SavePetSpec(p *Pet) error
- type AbilityDisplay
- type CombatMessages
- type Food
- type Pet
- func (p *Pet) CheckDailyTick() (int, bool)
- func (p *Pet) DailyLevelCheck() int
- func (p *Pet) DecrementMissing() bool
- func (p *Pet) DisplayName() string
- func (p *Pet) Exists() bool
- func (p *Pet) Filename() string
- func (p *Pet) Filepath() string
- func (p *Pet) FindItem(itemName string) (items.Item, bool)
- func (p *Pet) GetAbilityDisplays() []AbilityDisplay
- func (p *Pet) GetBuffs() []int
- func (p *Pet) GetCombatMessages(targetType string) CombatMessages
- func (p *Pet) GetCurrentAbility() *PetAbility
- func (p *Pet) GetCurrentAbilityDisplay() *AbilityDisplay
- func (p *Pet) GetCurrentDayKey() string
- func (p *Pet) GetDiceRoll() (attacks int, dCount int, dSides int, bonus int, buffOnCrit []int)
- func (p *Pet) GetEffectiveBuffs() []int
- func (p *Pet) GetEffectiveCapacity() int
- func (p *Pet) GetEffectiveDamage() (int, items.Damage)
- func (p *Pet) GetEffectiveStatMods() statmods.StatMods
- func (p *Pet) GetScript() string
- func (p *Pet) GetScriptPath() string
- func (p *Pet) GoMissing(rounds int)
- func (p *Pet) HasScript() bool
- func (p *Pet) Id() string
- func (p *Pet) IsMissing() bool
- func (p *Pet) LevelChange(delta int) (oldLevel int, newLevel int, changed bool)
- func (p *Pet) RemoveItem(i items.Item) bool
- func (p *Pet) Save() error
- func (p *Pet) StatMod(statName string) int
- func (p *Pet) StoreItem(i items.Item) bool
- func (p *Pet) Validate() error
- type PetAbility
Constants ¶
const ( TokenPetName = `{petname}` TokenDamage = `{damage}` TokenTargetName = `{targetname}` )
Variables ¶
This section is empty.
Functions ¶
func CreatePetSpec ¶ added in v0.9.8
CreatePetSpec registers a new pet type. Returns an error if the type already exists.
func DeletePetSpec ¶ added in v0.9.8
DeletePetSpec removes a pet type from disk and the in-memory cache.
func GetAllPetSpecs ¶ added in v0.9.8
GetAllPetSpecs returns a copy of every loaded pet type keyed by type ID.
func GetMemoryUsage ¶ added in v0.9.8
func GetMemoryUsage() map[string]util.MemoryResult
func SavePetScript ¶ added in v0.9.8
SavePetScript writes (or removes) the JavaScript script file for a pet type.
func SavePetSpec ¶ added in v0.9.8
SavePetSpec validates, persists a pet spec to disk, and updates the in-memory cache.
Types ¶
type AbilityDisplay ¶ added in v0.9.8
type CombatMessages ¶ added in v0.9.8
type CombatMessages struct {
// ToOwner is sent to the player who owns the pet.
ToOwner string `yaml:"toowner,omitempty" json:"toowner,omitempty"`
// ToTarget is sent to the player being attacked (if the target is a player).
ToTarget string `yaml:"totarget,omitempty" json:"totarget,omitempty"`
// ToRoom is sent to everyone else in the room observing the attack.
ToRoom string `yaml:"toroom,omitempty" json:"toroom,omitempty"`
// Miss is sent to the pet owner when the pet's attack misses.
Miss string `yaml:"miss,omitempty" json:"miss,omitempty"`
}
CombatMessages holds optional custom attack message templates for a pet. Each field is a Go text/template-style string supporting the tokens:
{petname} - replaced with the pet's display name (may contain ANSI tags)
{damage} - replaced with the integer damage dealt (plain text)
{targetname} - replaced with the target's formatted name (may contain ANSI tags)
All four fields are optional. When a field is empty the combat system falls back to the built-in default message for that slot.
func DefaultCombatMessages ¶ added in v0.9.8
func DefaultCombatMessages(targetType string) CombatMessages
DefaultCombatMessages returns the built-in fallback messages used when a pet type does not define its own. targetType is the ANSI fg colour prefix for the target (e.g. "mob" or "user").
func (CombatMessages) ApplyTokens ¶ added in v0.9.8
func (cm CombatMessages) ApplyTokens(s, petName string, damage int, targetName string) string
ApplyTokens replaces all recognised tokens in s and returns the result. petName and targetName may contain ANSI markup; damage is plain text.
func (CombatMessages) IsEmpty ¶ added in v0.9.8
func (cm CombatMessages) IsEmpty() bool
IsEmpty returns true when no custom messages are defined.
type Pet ¶
type Pet struct {
Name string `yaml:"name,omitempty"` // Name of the pet (player provided hopefully)
NameStyle string `yaml:"namestyle,omitempty"` // Optional color pattern to apply
Type string `yaml:"type"` // type of pet
RoundActChance int `yaml:"roundactchance,omitempty"` // 0-100 chance per round to fire PetAct script
Food Food `yaml:"food,omitempty"` // how much food the pet has
Level int `yaml:"level,omitempty"` // Pet level (1-10)
LastMealRound uint8 `yaml:"lastmealround,omitempty"` // When the pet was last fed
LastLevelCheck string `yaml:"lastlevelcheck,omitempty"` // "{year}.{day}" of last daily tick
Abilities []PetAbility `yaml:"abilities,omitempty"` // Refreshed from definition file on Validate()
Items []items.Item `yaml:"items,omitempty"` // Items held by this pet
MissingCountdown int `yaml:"missingcountdown,omitempty"` // When non-zero, pet is absent
// contains filtered or unexported fields
}
func GetPetCopy ¶
func (*Pet) CheckDailyTick ¶ added in v0.9.8
CheckDailyTick returns (levelChange, needsValidate) if a new day has passed. Returns (0, false) if no tick is needed.
func (*Pet) DailyLevelCheck ¶ added in v0.9.8
func (*Pet) DecrementMissing ¶ added in v0.9.8
DecrementMissing decrements the missing countdown by one. Returns true if the countdown just reached zero (pet is returning this round).
func (*Pet) DisplayName ¶
func (*Pet) GetAbilityDisplays ¶ added in v0.9.8
func (p *Pet) GetAbilityDisplays() []AbilityDisplay
func (*Pet) GetCombatMessages ¶ added in v0.9.8
func (p *Pet) GetCombatMessages(targetType string) CombatMessages
GetCombatMessages returns the effective combat messages for the current ability level. Any empty slot in the ability's AttackMessages is filled in from the built-in defaults. targetType is the ANSI fg colour prefix (e.g. "mob" or "user") used when building the default fallback strings.
func (*Pet) GetCurrentAbility ¶ added in v0.9.8
func (p *Pet) GetCurrentAbility() *PetAbility
func (*Pet) GetCurrentAbilityDisplay ¶ added in v0.9.8
func (p *Pet) GetCurrentAbilityDisplay() *AbilityDisplay
func (*Pet) GetCurrentDayKey ¶ added in v0.9.8
func (*Pet) GetDiceRoll ¶
func (*Pet) GetEffectiveBuffs ¶ added in v0.9.8
func (*Pet) GetEffectiveCapacity ¶ added in v0.9.8
func (*Pet) GetEffectiveDamage ¶ added in v0.9.8
func (*Pet) GetEffectiveStatMods ¶ added in v0.9.8
func (*Pet) GetScriptPath ¶ added in v0.9.8
func (*Pet) GoMissing ¶ added in v0.9.8
GoMissing sets the missing countdown to the given number of rounds. A value of zero clears the missing state immediately.
func (*Pet) LevelChange ¶ added in v0.9.8
type PetAbility ¶ added in v0.9.8
type PetAbility struct {
LevelGranted int `yaml:"levelgranted,omitempty"`
CombatChance int `yaml:"combatchance,omitempty"` // odds (out of 100) that it will join in this round of combat
Damage items.Damage `yaml:"damage,omitempty"`
AttackMessages CombatMessages `yaml:"attackmessages,omitempty"` // Optional custom combat messages for this ability level
StatMods statmods.StatMods `yaml:"statmods,omitempty"`
BuffIds []int `yaml:"buffids,omitempty"`
Capacity int `yaml:"capacity,omitempty"`
}