skill

package
v0.0.0-...-cf0ae38 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasicMovement  = "static-movement"
	UseConsumable  = "use-consumable"
	FleeFromCombat = "flee-from-combat"
	EndTurn        = "end-turn"
)

Some skills should be staticly compiled into the executable, so that they can have special logic. They're not really part of game data.

Variables

This section is empty.

Functions

func ClassificationStrings

func ClassificationStrings() []string

ClassificationStrings returns a slice of all String values of the enum

func InjuryTypeStrings

func InjuryTypeStrings() []string

InjuryTypeStrings returns a slice of all String values of the enum

func NewTimingRealiser

func NewTimingRealiser(m map[TimingPoint]time.Duration) func(Timing) time.Duration

NewTimingRealiser creates a function to realise when to trigger an effect.

func OperatorStrings

func OperatorStrings() []string

OperatorStrings returns a slice of all String values of the enum

Types

type Classification

type Classification int
const (
	Skill Classification = iota
	Attack
	Spell
	Attunement
)

func ClassificationString

func ClassificationString(s string) (Classification, error)

ClassificationString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ClassificationValues

func ClassificationValues() []Classification

ClassificationValues returns all values of the enum

func (Classification) IsAClassification

func (i Classification) IsAClassification() bool

IsAClassification returns "true" if the value is listed in the enum definition. "false" otherwise

func (Classification) MarshalJSON

func (i Classification) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Classification

func (Classification) String

func (i Classification) String() string

func (*Classification) UnmarshalJSON

func (i *Classification) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Classification

type CostType

type CostType int

CostType defines what resources a skill costs to use. A skill might cost Action Points, Mana, etc, or some combination of costs.

const (
	CostsActionPoints CostType = iota
	CostsMana
	CostsExhaustionPercent
	CostsHealthSacrificePercent
)

func CostTypeFromString

func CostTypeFromString(s string) *CostType

func (CostType) String

func (i CostType) String() string

type DamageEffect

type DamageEffect struct {
	Min            Operations     // "0.5 * attunement * 0.22 * INT"
	Max            Operations     // "10 + 5 * attunement * 0.17 * INT"
	Classification Classification // Spell or Attack: can it be negated or dodged?
	DamageType     game.DamageType
}

DamageEffect deals damage.

type DefileEffect

type DefileEffect struct{}

DefileEffect changes the target's state from KnockedDown to Defiled.

type Description

type Description struct {
	ID          ID
	Name        string
	Explanation string

	// Tags critically includes Attack or Spell, and allows the game to select
	// an appropriate animation to use when using the skill.
	Tags []Classification

	Icon game.FrameAnimation

	Targeting targeting.Rule

	// Effects of triggering this skill.
	Effects []Effect

	Costs map[CostType]int

	// AttackChanceToHitModifier multiplies the base chance to hit of the skill.
	// A value of zero does not modify the chance to hit. A value of 0.1
	// improves the chance to hit by 10%. A value of -0.5 halves the chance to
	// hit.
	AttackChanceToHitModifier float64
}

Description contains all the data for a skill so that it can be displayed in menus or utilised in combat.

func (Description) IsAttack

func (d Description) IsAttack() bool

IsAttack returns whether a skill is an attack or not.

type Effect

type Effect struct {
	When Timing
	What []interface{}
}

Effect is anything that executing a skill could trigger.

type HealEffect

type HealEffect struct {
	Amount       float64
	IsPercentage bool
}

HealEffect heals the target. By default the amount is treated as a value to increment the current health by, but if IsPercentage is true, then the current health is incremented by the maximum health multiplied by Amount.

type ID

type ID string

ID identifies skills with a human-readable code.

type InjuryEffect

type InjuryEffect struct {
	Type  InjuryType
	Value int
}

InjuryEffect applies an injury to the target.

type InjuryType

type InjuryType int

InjuryType enumerates injuries.

const (
	BleedingInjury InjuryType = iota
)

func InjuryTypeFromString

func InjuryTypeFromString(s string) *InjuryType

func InjuryTypeString

func InjuryTypeString(s string) (InjuryType, error)

InjuryTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func InjuryTypeValues

func InjuryTypeValues() []InjuryType

InjuryTypeValues returns all values of the enum

func (InjuryType) IsAInjuryType

func (i InjuryType) IsAInjuryType() bool

IsAInjuryType returns "true" if the value is listed in the enum definition. "false" otherwise

func (InjuryType) MarshalJSON

func (i InjuryType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for InjuryType

func (InjuryType) String

func (i InjuryType) String() string

func (*InjuryType) UnmarshalJSON

func (i *InjuryType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for InjuryType

type Map

type Map map[ID]Description

Map of skill IDs to skill Descriptions.

type Operation

type Operation struct {
	Operator Operator
	Variable string // literal float, or substitute value like STR, INT, fire attunement
}

type Operations

type Operations []Operation

func (Operations) Calculate

func (o Operations) Calculate(dereferencer func(string) float64) int

type Operator

type Operator int
const (
	AddOp Operator = iota
	MultOp
)

func OperatorString

func OperatorString(s string) (Operator, error)

OperatorString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func OperatorValues

func OperatorValues() []Operator

OperatorValues returns all values of the enum

func (Operator) IsAOperator

func (i Operator) IsAOperator() bool

IsAOperator returns "true" if the value is listed in the enum definition. "false" otherwise

func (Operator) MarshalJSON

func (i Operator) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Operator

func (Operator) String

func (i Operator) String() string

func (*Operator) UnmarshalJSON

func (i *Operator) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Operator

type ReviveEffect

type ReviveEffect struct{}

ReviveEffect changes the status from KnockedDown to Alive, and sets the target's current health to 1. Does nothing if the target is not KnockedDown.

type SpawnParticipantEffect

type SpawnParticipantEffect struct {
	Profession string
	Level      Operations
}

SpawnParticipantEffect spawns a new participant.

type Timing

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

Timing represents when a skill effect should be triggered. It allows both concrete time.Duration values that specify the amount of time after skill execution starts, and virtualised "points" in the skill execution like "end" or "when the blow lands".

func NewTiming

func NewTiming(at time.Duration) Timing

NewTiming constructs a Timing for an effect that should be triggered the specified Duration after the skill execution starts.

func NewTimingFromPoint

func NewTimingFromPoint(point TimingPoint) Timing

NewTimingFromPoint constructs a Timing from a TimingPoint.

type TimingPoint

type TimingPoint int
const (
	// AttackApexTimingPoint applies to spells too!
	AttackApexTimingPoint TimingPoint = iota
	EndTimingPoint
)

func TimingPointFromString

func TimingPointFromString(s string) *TimingPoint

func (TimingPoint) String

func (i TimingPoint) String() string

Jump to

Keyboard shortcuts

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