board

package
v0.0.0-...-8ae69cb Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllHPMethods holds all possible HPMethods.
	AllHPMethods []HPMethod
)

Functions

This section is empty.

Types

type Board

type Board struct {
	Round            int          `json:"round"`
	Current          int          `json:"current"`
	Combatants       []*Combatant `json:"combatants,omitempty"`
	InitiativeDice   *dice.Dice   `json:"initiative_dice,omitempty"`
	HPMethod         HPMethod     `json:"hp_method,omitempty"`
	LibrarySelection int          `json:"library_selection,omitempty"`
	LibraryEntity    *data.Entity `json:"-"`
	LastID           int64        `json:"-"`
}

Board holds the initiative board data.

func (*Board) CurrentTag

func (b *Board) CurrentTag(c *Combatant) string

CurrentTag returns the current tag to use for the combatant, if any.

func (*Board) DuplicateCombatant

func (b *Board) DuplicateCombatant(who *Combatant) *Combatant

DuplicateCombatant duplicates an existing combatant and add them to the board.

func (*Board) IsCurrent

func (b *Board) IsCurrent(c *Combatant) bool

IsCurrent returns true if the specified combatant is the current one.

func (*Board) Load

func (b *Board) Load(path string) error

Load state from the specified path.

func (*Board) Lookup

func (b *Board) Lookup(id int) *Combatant

Lookup a combatant by ID.

func (*Board) NewCombatant

func (b *Board) NewCombatant(genID bool, entity *data.Entity) *Combatant

NewCombatant creates a new combatant.

func (*Board) NextID

func (b *Board) NextID() int

NextID returns the next ID to use for a combatant.

func (*Board) Save

func (b *Board) Save(path string) error

Save state to the specified path.

func (*Board) SetLibrarySelection

func (b *Board) SetLibrarySelection(e *data.Entity)

SetLibrarySelection sets the current library selection.

func (*Board) SuggestName

func (b *Board) SuggestName(nameHint string) string

SuggestName suggests a name for a combatant.

type Combatant

type Combatant struct {
	ID               int      `json:"id"`
	Name             string   `json:"name,omitempty"`
	Initiative       int      `json:"initiative,omitempty"`
	InitiativeBase   int      `json:"initiative_base,omitempty"`
	RandomTieBreaker int      `json:"random_tie_breaker,omitempty"`
	HPFull           int      `json:"hp_full,omitempty"`
	HPTemporary      int      `json:"hp_temp,omitempty"`
	HPDamage         int      `json:"hp_damage,omitempty"`
	HPChanges        []string `json:"hp_changes,omitempty"`
	EntityID         int      `json:"entity_id,omitempty"`
	Notes            []Note   `json:"notes,omitempty"`
	Enemy            bool     `json:"enemy,omitempty"`
}

Combatant holds information for a single entity in combat.

func (*Combatant) BasedOn

func (c *Combatant) BasedOn() string

BasedOn returns the name of the entity the combatant was based on.

func (*Combatant) Clone

func (c *Combatant) Clone(newID int) *Combatant

Clone creates a copy of the combatant, but with a new ID.

func (*Combatant) CurrentHP

func (c *Combatant) CurrentHP() int

CurrentHP returns the current hit point total.

func (*Combatant) FormattedHP

func (c *Combatant) FormattedHP() string

FormattedHP returns the HP formatted for display.

func (*Combatant) Harm

func (c *Combatant) Harm(round, amount int)

Harm a combatant. 'round' indicates what round the harm occurred.

func (*Combatant) Heal

func (c *Combatant) Heal(round, amount int)

Heal a combatant. 'round' indicates what round the healing occurred.

func (*Combatant) Out

func (c *Combatant) Out() bool

Out returns true if the combatant is out of the combat.

func (*Combatant) PossessiveName

func (c *Combatant) PossessiveName() string

PossessiveName returns the possessive form of the combatant's name.

func (*Combatant) RecordHPChange

func (c *Combatant) RecordHPChange(round, delta int)

RecordHPChange records a hit point change. 'round' indicates what round the change occurred.

func (*Combatant) Status

func (c *Combatant) Status() string

Status returns a description of the combatant's current health.

func (*Combatant) StatusTag

func (c *Combatant) StatusTag() string

StatusTag returns the current status tag to use.

func (*Combatant) Type

func (c *Combatant) Type() string

Type returns the type of combatant, enemy or ally.

func (*Combatant) TypeDescription

func (c *Combatant) TypeDescription() string

TypeDescription returns a human-readable type for the combatant.

type HPMethod

type HPMethod byte

HPMethod is an enum of possible ways to determine HP for an entity.

const (
	RolledHPMethod HPMethod = iota
	MinimumHPMethod
	AverageHPMethod
	MaximumHPMethod
	ThreeQuartersHPMethod
)

Possible HPMethods.

func (HPMethod) AllMethods

func (hpm HPMethod) AllMethods() []HPMethod

AllMethods returns all possible methods.

func (HPMethod) HP

func (hpm HPMethod) HP(e *data.Entity) int

HP determines the HP for an entity based on the method chosen.

func (HPMethod) Key

func (hpm HPMethod) Key() string

Key returns the key used for encoding.

func (HPMethod) Lookup

func (hpm HPMethod) Lookup(key string) HPMethod

Lookup returns the HPMethod by keyed name.

func (HPMethod) MarshalText

func (hpm HPMethod) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (HPMethod) String

func (hpm HPMethod) String() string

func (*HPMethod) UnmarshalText

func (hpm *HPMethod) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Note

type Note struct {
	Description string `json:"description,omitempty"`
	Timed       bool   `json:"timed,omitempty"`
	UntilEnd    bool   `json:"until_end,omitempty"`
	Who         int    `json:"who,omitempty"`
	Round       int    `json:"round,omitempty"`
}

Note holds a note about a combatant, which may be set to expire at a given point in time.

func (*Note) Detail

func (n *Note) Detail(b *Board) string

Detail returns the detail to use in a tooltip.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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