combat

package
v0.0.0-...-48d56c4 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WeakDurability   = 25
	MedDurability    = 50
	StrongDurability = 100
)
View Source
const (
	PostSnapshot snapshotHookType = iota
	PreDamageHook
	PostDamageHook
	OnCritDamage
	PreTransReaction
	PostTransReaction
	PreAmpReaction
	PostAmpReaction
	//delim
	EndSnapshotHook
)
View Source
const (
	PreSwapHook eventHookType = iota
	PostSwapHook
	PreBurstHook
	PostBurstHook
	PreSkillHook
	PostSkillHook
	PostAttackHook
	PostShieldHook
	PostParticleHook
	//delim
	EndEventHook
)
View Source
const (
	WeakAuraBase   int64 = 570
	MedAuraBase    int64 = 360
	StrongAuraBase int64 = 225
)

Variables

View Source
var EleTypeString = [...]string{
	"pyro",
	"hydro",
	"cryo",
	"electro",
	"geo",
	"anemo",
	"dendro",
	"physical",
	"frozen",
	"ec",
	"",
}
View Source
var ICDGroupDamageSequence = [][]float64{

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
}
View Source
var ICDGroupEleApplicationSequence = [][]int{

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 1.0},

	{1.0, 1.0},
}
View Source
var ICDGroupResetTimer = []int{
	150,
	60,
	60,
	300,
	300,
	30,
	6,
	30,
	30,
}
View Source
var LogSourceString = [...]string{
	"procs",
	"damage",
	"hurt",
	"heal",
	"calc",
	"reaction",
	"element",
	"snapshot",
	"status",
	"action",
	"queue",
	"energy",
	"character",
	"enemy",
	"hook",
	"sim",
	"artifact",
	"weapon",
	"shield",
	"construct",
	"icd",
}
View Source
var StatTypeString = [...]string{
	"def%",
	"def",
	"hp",
	"hp%",
	"atk",
	"atk%",
	"er",
	"em",
	"cr",
	"cd",
	"heal",
	"pyro%",
	"hydro%",
	"cryo%",
	"electro%",
	"anemo%",
	"geo%",
	"ele%",
	"phys%",
	"dendro%",
	"atkspd%",
	"dmg%",
}

Functions

func PrettyPrintStats

func PrettyPrintStats(stats []float64) string

func RegisterCharFunc

func RegisterCharFunc(name string, f NewCharacterFunc)

func RegisterSetFunc

func RegisterSetFunc(name string, f NewSetFunc)

func RegisterWeaponFunc

func RegisterWeaponFunc(name string, f NewWeaponFunc)

func UnfreezeDmg

func UnfreezeDmg(s *Sim)

Types

type AbilUsage

type AbilUsage struct {
	Actor  string `json:"actor"`
	Action string `json:"action"`
	Param  string `json:"param"`
}

type Action

type Action struct {
	Name   string
	Target string //either character or a sequence name

	Exec     []ActionItem //if len > 1 then it's a sequence
	IsSeq    bool         // is this a sequence
	IsStrict bool         //strict sequence?
	Once     bool         // is this an opener (execute once)
	Disabled bool         // is this action disabled
	Pos      int          //current position in execution, default 0

	Last       int //last time this was executed (frame)
	ActionLock int //how many frames this action is locked from executing again

	ActiveCond string
	SwapTo     string
	SwapLock   int
	PostAction ActionType

	Conditions *ExprTreeNode //conditions to be met

	Raw []string //raw action in string
}

type ActionItem

type ActionItem struct {
	Typ    ActionType
	Param  map[string]int
	Target string
	// contains filtered or unexported fields
}

type ActionType

type ActionType int
const (
	ActionSequence ActionType = iota
	ActionSequenceStrict
	ActionDelimiter
	ActionSequenceReset
	ActionSkill
	ActionBurst
	ActionAttack
	ActionCharge
	ActionHighPlunge
	ActionLowPlunge
	ActionSpecialProc
	ActionAim
	ActionSwap
	ActionSwapLock    //force swap lock
	ActionCancellable // delim cancellable action
	ActionDash
	ActionJump
	ActionOtherEvents //delim for other events
	ActionHurt        //damage characters
	//delim
	EndActionType
)

func (ActionType) String

func (a ActionType) String() string

type AttackTag

type AttackTag int //attacktag is used instead of actions etc..
const (
	AttackTagNone AttackTag = iota
	AttackTagNormal
	AttackTagExtra
	AttackTagPlunge
	AttackTagElementalArt
	AttackTagElementalBurst
	AttackTagWeaponSkill
	AttackTagTartagliaAttack
	AttackTagGandalfrAttack
	AttackTagElementalArtHold
	AttackTagLength
)

type Aura

type Aura interface {
	React(ds Snapshot, s *Sim) Aura
	Tick(s *Sim) bool //remove if true
	Attach(e EleType, durability float64, f int)
	Refresh(dur float64, s *Sim)
	E() EleType
	ContainsEle(e EleType) bool
}

type CDAdjust

type CDAdjust struct {
	Key    string
	Amount func(a ActionType) float64
	Expiry int
}

type CharStatMod

type CharStatMod struct {
	Key       string
	Mod       []float64
	Condition func(ds Snapshot) bool
	Expiry    int
}

type CharTask

type CharTask struct {
	Name  string
	F     func()
	Delay int
	// contains filtered or unexported fields
}

type Character

type Character interface {
	Init(index int) //to be called when everything including weapon and artifacts has been loaded
	Tick()          //function to be called every frame

	//information functions
	Name() string
	CharIndex() int
	Ele() EleType
	WeaponClass() WeaponClass
	CurrentEnergy() float64 //current energy
	TalentLvlSkill() int
	TalentLvlAttack() int
	TalentLvlBurst() int
	HP() float64
	MaxHP() float64
	ModifyHP(float64)

	//actions
	Attack(p map[string]int) int
	Aimed(p map[string]int) int
	ChargeAttack(p map[string]int) int
	HighPlungeAttack(p map[string]int) int
	LowPlungeAttack(p map[string]int) int
	Skill(p map[string]int) int
	Burst(p map[string]int) int
	Dash(p map[string]int) int

	//info methods
	ActionReady(a ActionType, p map[string]int) bool
	ActionFrames(a ActionType, p map[string]int) int
	ActionStam(a ActionType, p map[string]int) float64

	//char stat mods
	AddMod(mod CharStatMod)
	AddWeaponInfuse(inf WeaponInfusion)

	//cooldown stuff
	SetCD(a ActionType, dur int)
	Cooldown(a ActionType) int
	ResetActionCooldown(a ActionType)
	ReduceActionCooldown(a ActionType, v int)
	AddCDAdjustFunc(rd CDAdjust)

	//status stuff
	Tag(key string) int

	//energy
	ReceiveParticle(p Particle, isActive bool, partyCount int)
	AddEnergy(e float64)

	//combat
	Snapshot(name string, a AttackTag, icd ICDTag, g ICDGroup, st StrikeType, e EleType, d float64, mult float64) Snapshot
	ResetNormalCounter()
}

type CharacterBase

type CharacterBase struct {
	Name    string  `yaml:"Name"`
	Element EleType `yaml:"Element"`
	Level   int     `yaml:"Level"`
	HP      float64 `yaml:"BaseHP"`
	Atk     float64 `yaml:"BaseAtk"`
	Def     float64 `yaml:"BaseDef"`
	Cons    int     `yaml:"Constellation"`
	StartHP float64
}

type CharacterProfile

type CharacterProfile struct {
	Base    CharacterBase `yaml:"Base"`
	Weapon  WeaponProfile `yaml:"Weapon"`
	Talents TalentProfile
	Stats   []float64
	Sets    map[string]int
}

CharacterProfile ...

type CharacterTemplate

type CharacterTemplate struct {
	S     *Sim
	Index int
	//this should describe the frame in which the abil becomes available
	//if frame > current then it's available. no need to decrement this way
	// CD        map[string]int
	ActionCD []int
	Mods     []CharStatMod
	Tags     map[string]int
	//Profile info
	Base     CharacterBase
	Weapon   WeaponProfile
	Stats    []float64
	Talents  TalentProfile
	SkillCon int
	BurstCon int

	CDReductionFuncs []CDAdjust

	Energy    float64
	MaxEnergy float64

	HPCurrent float64
	HPMax     float64

	//Tasks specific to the character to be executed at set frames
	Tasks map[int][]CharTask
	//counters
	NormalHitNum  int //how many hits in a normal combo
	NormalCounter int

	//infusion
	Infusion WeaponInfusion //TODO currently just overides the old; disregarding any existing
}

func NewTemplateChar

func NewTemplateChar(s *Sim, p CharacterProfile) (*CharacterTemplate, error)

func (*CharacterTemplate) ActionFrames

func (c *CharacterTemplate) ActionFrames(a ActionType, p map[string]int) int

func (*CharacterTemplate) ActionReady

func (c *CharacterTemplate) ActionReady(a ActionType, p map[string]int) bool

func (*CharacterTemplate) ActionStam

func (c *CharacterTemplate) ActionStam(a ActionType, p map[string]int) float64

func (*CharacterTemplate) AddCDAdjustFunc

func (c *CharacterTemplate) AddCDAdjustFunc(rd CDAdjust)

func (*CharacterTemplate) AddEnergy

func (c *CharacterTemplate) AddEnergy(e float64)

func (*CharacterTemplate) AddMod

func (c *CharacterTemplate) AddMod(mod CharStatMod)

func (*CharacterTemplate) AddTask

func (c *CharacterTemplate) AddTask(f func(), name string, delay int)

func (*CharacterTemplate) AddWeaponInfuse

func (c *CharacterTemplate) AddWeaponInfuse(inf WeaponInfusion)

func (*CharacterTemplate) AdvanceNormalIndex

func (c *CharacterTemplate) AdvanceNormalIndex()

advance normal index, return the current one

func (*CharacterTemplate) Aimed

func (c *CharacterTemplate) Aimed(p map[string]int) int

func (*CharacterTemplate) Attack

func (c *CharacterTemplate) Attack(p map[string]int) int

func (*CharacterTemplate) Burst

func (c *CharacterTemplate) Burst(p map[string]int) int

func (*CharacterTemplate) CharIndex

func (c *CharacterTemplate) CharIndex() int

func (*CharacterTemplate) ChargeAttack

func (c *CharacterTemplate) ChargeAttack(p map[string]int) int

func (*CharacterTemplate) Cooldown

func (c *CharacterTemplate) Cooldown(a ActionType) int

func (*CharacterTemplate) CurrentEnergy

func (c *CharacterTemplate) CurrentEnergy() float64

func (*CharacterTemplate) Dash

func (c *CharacterTemplate) Dash(p map[string]int) int

func (*CharacterTemplate) Ele

func (c *CharacterTemplate) Ele() EleType

func (*CharacterTemplate) HP

func (c *CharacterTemplate) HP() float64

func (*CharacterTemplate) HighPlungeAttack

func (c *CharacterTemplate) HighPlungeAttack(p map[string]int) int

func (*CharacterTemplate) Init

func (c *CharacterTemplate) Init(index int)

func (*CharacterTemplate) LowPlungeAttack

func (c *CharacterTemplate) LowPlungeAttack(p map[string]int) int

func (*CharacterTemplate) MaxHP

func (c *CharacterTemplate) MaxHP() float64

func (*CharacterTemplate) ModifyHP

func (c *CharacterTemplate) ModifyHP(amt float64)

func (*CharacterTemplate) Name

func (c *CharacterTemplate) Name() string

func (*CharacterTemplate) ReceiveParticle

func (c *CharacterTemplate) ReceiveParticle(p Particle, isActive bool, partyCount int)

func (*CharacterTemplate) ReduceActionCooldown

func (c *CharacterTemplate) ReduceActionCooldown(a ActionType, v int)

func (*CharacterTemplate) ResetActionCooldown

func (c *CharacterTemplate) ResetActionCooldown(a ActionType)

func (*CharacterTemplate) ResetNormalCounter

func (c *CharacterTemplate) ResetNormalCounter()

func (*CharacterTemplate) SetCD

func (c *CharacterTemplate) SetCD(a ActionType, dur int)

func (*CharacterTemplate) Skill

func (c *CharacterTemplate) Skill(p map[string]int) int

func (*CharacterTemplate) Snapshot

func (c *CharacterTemplate) Snapshot(name string, a AttackTag, icd ICDTag, g ICDGroup, st StrikeType, e EleType, d float64, mult float64) Snapshot

func (*CharacterTemplate) Tag

func (c *CharacterTemplate) Tag(key string) int

func (*CharacterTemplate) TalentLvlAttack

func (c *CharacterTemplate) TalentLvlAttack() int

func (*CharacterTemplate) TalentLvlBurst

func (c *CharacterTemplate) TalentLvlBurst() int

func (*CharacterTemplate) TalentLvlSkill

func (c *CharacterTemplate) TalentLvlSkill() int

func (*CharacterTemplate) Tick

func (c *CharacterTemplate) Tick()

func (*CharacterTemplate) WeaponClass

func (c *CharacterTemplate) WeaponClass() WeaponClass

type Condition

type Condition struct {
	Fields []string
	Op     string
	Value  int
}

func (Condition) String

func (c Condition) String()

type ConfigArtifact

type ConfigArtifact struct {
	Level int                `yaml:"Level"`
	Set   string             `yaml:"Set"`
	Main  map[string]float64 `yaml:"Main"`
	Sub   map[string]float64 `yaml:"Sub"`
}

type Construct

type Construct interface {
	OnDestruct()
	Key() int
	Type() GeoConstructType
	Expiry() int
	IsLimited() bool
	Count() int
}

type CryoAura

type CryoAura struct {
	*Element
}

func NewCryo

func NewCryo() *CryoAura

func (*CryoAura) React

func (c *CryoAura) React(ds Snapshot, s *Sim) Aura

type DefMod

type DefMod struct {
	Key    int
	Value  float64
	Expiry int
}

type EffectFunc

type EffectFunc func(s *Sim) bool

type EleType

type EleType int

EleType is a string representing an element i.e. HYDRO/PYRO/etc...

const (
	Pyro EleType = iota
	Hydro
	Cryo
	Electro
	Geo
	Anemo
	Dendro
	Physical
	Frozen
	EC
	NoElement
)

ElementType should be pryo, Hydro, Cryo, Electro, Geo, Anemo and maybe dendro

func (EleType) String

func (e EleType) String() string

type ElectroAura

type ElectroAura struct {
	*Element
}

func NewElectro

func NewElectro() *ElectroAura

func (*ElectroAura) React

func (e *ElectroAura) React(ds Snapshot, s *Sim) Aura

type ElectroChargeAura

type ElectroChargeAura struct {
	*Element
	Hydro    *HydroAura
	Electro  *ElectroAura
	NextTick int
	Snap     Snapshot
}

func NewEC

func NewEC() *ElectroChargeAura

func (*ElectroChargeAura) ContainsEle

func (e *ElectroChargeAura) ContainsEle(ele EleType) bool

func (*ElectroChargeAura) Init

func (e *ElectroChargeAura) Init(electro *ElectroAura, hydro *HydroAura, ds Snapshot, s *Sim)

func (*ElectroChargeAura) React

func (e *ElectroChargeAura) React(ds Snapshot, s *Sim) Aura

func (*ElectroChargeAura) Tick

func (e *ElectroChargeAura) Tick(s *Sim) bool

type Element

type Element struct {
	Type          EleType
	MaxDurability float64
	Durability    float64
	Start         int //when the aura was first added
	Expiry        int //when the aura is gone, use this instead of ticks
}

func NewElement

func NewElement() *Element

func (*Element) Attach

func (e *Element) Attach(ele EleType, durability float64, f int)

func (*Element) ContainsEle

func (e *Element) ContainsEle(ele EleType) bool

func (*Element) E

func (e *Element) E() EleType

func (*Element) React

func (e *Element) React(ds Snapshot, s *Sim) Aura

react with next element, modifying the existing to = whatever the result should be

func (*Element) Reduce

func (e *Element) Reduce(durability float64, s *Sim)

func (*Element) Refresh

func (e *Element) Refresh(durability float64, s *Sim)

func (*Element) Remain

func (e *Element) Remain(f int) float64

calculate how much of the durability remains after passage of time

func (*Element) Tick

func (e *Element) Tick(s *Sim) bool

type Enemy

type Enemy struct {
	Level int

	HPMode bool
	MaxHP  float64
	HP     float64

	F   *int
	Log *zap.SugaredLogger

	//stats
	Damage float64 //total damage received
	// contains filtered or unexported fields
}

Enemy keeps track of the status of one enemy Enemy

func (*Enemy) AddDefMod

func (e *Enemy) AddDefMod(key int, val float64, dur int)

func (*Enemy) AddResMod

func (e *Enemy) AddResMod(key string, val ResistMod)

func (*Enemy) DeactivateResMod

func (e *Enemy) DeactivateResMod(key string)

func (*Enemy) DefAdj

func (e *Enemy) DefAdj() float64

func (*Enemy) HasResMod

func (e *Enemy) HasResMod(key string) bool

func (*Enemy) Resist

func (e *Enemy) Resist(ele EleType, char int) float64

type EnemyProfile

type EnemyProfile struct {
	Level  int                 `yaml:"Level"`
	Resist map[EleType]float64 `yaml:"Resist"`
}

EnemyProfile ...

type ExprTreeNode

type ExprTreeNode struct {
	Left   *ExprTreeNode
	Right  *ExprTreeNode
	IsLeaf bool
	Op     string //&& || ( )
	Expr   Condition
}

type Flags

type Flags struct {
	ChildeActive        bool
	AmpReactionDidOccur bool
	AmpReactionType     ReactionType
	NextAttackMVMult    float64 // melt vape multiplier
	// ReactionDamageTriggered bool
	Custom map[string]int
}

type FreezeAura

type FreezeAura struct {
	*Element
	OldHydro *HydroAura
	OldCryo  *CryoAura
	NewHydro *HydroAura
	NewCryo  *CryoAura
	Expire   int
}

func NewFreeze

func NewFreeze() *FreezeAura

func (*FreezeAura) ContainsEle

func (f *FreezeAura) ContainsEle(ele EleType) bool

func (*FreezeAura) Init

func (f *FreezeAura) Init(cryo *CryoAura, hydro *HydroAura, dur float64, s *Sim)

func (*FreezeAura) React

func (f *FreezeAura) React(ds Snapshot, s *Sim) Aura

TODO: what happens if we apply new hydro then new cryo all before freeze expires? shouldn't be possible to due cds but right now this code wouldn't retrigger freeze even though it probably should

func (*FreezeAura) Tick

func (f *FreezeAura) Tick(s *Sim) bool

type GeoConstructType

type GeoConstructType int
const (
	GeoConstructNingSkill GeoConstructType = iota
	GeoConstructZhongliSkill
	GeoConstructTravellerSkill
	GeoConstructTravellerBurst
	GeoConstructAlbedoSkill
)

type HurtEvent

type HurtEvent struct {
	WillHurt bool
	Once     bool //how often
	Start    int  //
	End      int
	Min      float64
	Max      float64
	Ele      EleType
}

type HydroAura

type HydroAura struct {
	*Element
}

func NewHydro

func NewHydro() *HydroAura

func (*HydroAura) React

func (h *HydroAura) React(ds Snapshot, s *Sim) Aura

type ICDGroup

type ICDGroup int //same ICD group shares the same timer

group dictate both the sequence and the reset timer

const (
	ICDGroupDefault ICDGroup = iota
	ICDGroupAmber
	ICDGroupVenti
	ICDGroupFischl
	ICDGroupDiluc
	ICDGroupPole
	ICDGroupXiaoDash
	ICDGroupReactionA
	ICDGroupReactionB
	ICDGroupLength
)

type ICDTag

type ICDTag int //same ICD tag shares the same counter
const (
	ICDTagNone ICDTag = iota
	ICDTagNormalAttack
	ICDTagExtraAttack
	ICDTagElementalArt
	ICDTagElementalBurst
	ICDTagLisaElectro
	ICDTagYanfeiFire
	ICDTagVentiBurstAnemo
	ICDTagVentiBurstPyro
	ICDTagVentiBurstHydro
	ICDTagVentiBurstCryo
	ICDTagVentiBurstElectro
	ICDTagMonaWaterDamage
	ICDTagTravelerWakeOfEarth
	ICDTagKleeFireDamage
	ICDTagLength
)

type LogConfig

type LogConfig struct {
	LogLevel      string
	LogFile       string
	LogShowCaller bool
	LogEvents     []bool
}

type LogSource

type LogSource int
const (
	LogProcs LogSource = iota
	LogDamageEvent
	LogHurtEvent
	LogHealEvent
	LogCalc
	LogReactionEvent
	LogElementEvent
	LogSnapshotEvent
	LogStatusEvent
	LogActionEvent
	LogQueueEvent
	LogEnergyEvent
	LogCharacterEvent
	LogEnemyEvent
	LogHookEvent
	LogSimEvent
	LogArtifactEvent
	LogWeaponEvent
	LogShieldEvent
	LogConstructEvent
	LogICDEvent
)

func (LogSource) String

func (l LogSource) String() string

type NewCharacterFunc

type NewCharacterFunc func(s *Sim, p CharacterProfile) (Character, error)

type NewSetFunc

type NewSetFunc func(c Character, s *Sim, count int)

type NewWeaponFunc

type NewWeaponFunc func(c Character, s *Sim, refine int, params map[string]int)

type NoAura

type NoAura struct {
	*Element
}

func NewNoAura

func NewNoAura() *NoAura

func (*NoAura) React

func (n *NoAura) React(ds Snapshot, s *Sim) Aura

type Particle

type Particle struct {
	Source string
	Num    int
	Ele    EleType
	Delay  int
}

type Profile

type Profile struct {
	Label         string             `yaml:"Label"`
	Enemy         EnemyProfile       `yaml:"Enemy"`
	InitialActive string             `yaml:"InitialActive"`
	Characters    []CharacterProfile `yaml:"Characters"`
	Rotation      []Action
	Hurt          HurtEvent
	LogConfig     LogConfig
	LogStats      bool
	FixedRand     bool //if this is true then use the same seed
}

type PyroAura

type PyroAura struct {
	*Element
}

func NewPyro

func NewPyro() *PyroAura

func (*PyroAura) React

func (p *PyroAura) React(ds Snapshot, s *Sim) Aura

type ReactionType

type ReactionType string
const (
	Overload           ReactionType = "overload"
	Superconduct       ReactionType = "superconduct"
	Freeze             ReactionType = "freeze"
	Melt               ReactionType = "melt"
	Vaporize           ReactionType = "vaporize"
	CrystallizeElectro ReactionType = "crystallize-electro"
	CrystallizeHydro   ReactionType = "crystallize-hydro"
	CrystallizePyro    ReactionType = "crystallize-pyro"
	CrystallizeCryo    ReactionType = "crystallize-cryo"
	SwirlElectro       ReactionType = "swirl-electro"
	SwirlHydro         ReactionType = "swirl-hydro"
	SwirlPyro          ReactionType = "swirl-pyro"
	SwirlCryo          ReactionType = "swirl-cryo"
	ElectroCharged     ReactionType = "electrocharged"
	Shatter            ReactionType = "shatter"
	NoReaction         ReactionType = ""
	FreezeExtend       ReactionType = "FreezeExtend"
)

type ResistMod

type ResistMod struct {
	Key      string
	Ele      EleType
	Value    float64
	Duration int
	Expiry   int
}

type Shield

type Shield interface {
	Key() int
	Type() ShieldType
	OnDamage(dmg float64, ele EleType, bonus float64) (float64, bool) //return dmg taken and shield stays
	OnExpire()
	OnOverwrite()
	Expiry() int
	CurrentHP() float64
	Element() EleType
	Desc() string
}

type ShieldType

type ShieldType int
const (
	ShieldCrystallize ShieldType = iota //lasts 15 seconds
	ShieldNoelleSkill
	ShieldNoelleA2
	ShieldZhongliJadeShield
	ShieldDionaSkill
	ShieldBeidouThunderShield
	ShieldXinyanSkill
	ShieldXinyanC2
	ShieldKaeyaC4
	ShieldYanfeiC4
)

type Sim

type Sim struct {
	Target           *Enemy
	Status           map[string]int
	ActiveChar       string
	ActiveIndex      int
	CharActiveLength int
	Chars            []Character
	SwapCD           int
	Stats            SimStats

	//log related
	Log         *zap.SugaredLogger
	DebugDetail bool

	//icd related
	ICDGroupOnTimer       [][]bool
	ICDTagCounter         [][]int
	ICDDamageGroupOnTimer [][]bool
	ICDDamageGroupCounter [][]int

	//stam related
	LastStamUse  int
	Stam         float64
	StamModifier []func(a ActionType) float64

	DRFunc           []func() float64
	ShieldBonusFunc  []func() float64
	IncHealBonusFunc []func() float64 //% to add to amount healed

	//hurt event
	LastHurt int
	Hurt     HurtEvent
	OnHurt   []func(s *Sim)

	//reaction related
	TargetAura Aura

	Rand *rand.Rand

	F int

	GlobalFlags Flags
	// contains filtered or unexported fields
}

Sim keeps track of one simulation

func New

func New(p Profile) (*Sim, error)

New creates new sim from given profile

func (*Sim) AddDRFunc

func (s *Sim) AddDRFunc(f func() float64)

func (*Sim) AddEnergyParticles

func (s *Sim) AddEnergyParticles(source string, num int, ele EleType, delay int)

func (*Sim) AddEventHook

func (s *Sim) AddEventHook(f func(s *Sim) bool, key string, hook eventHookType)

AddHook adds a hook to sim. Hook will be called based on the type of hook

func (*Sim) AddIncHealBonus

func (s *Sim) AddIncHealBonus(f func() float64)

func (*Sim) AddOnHurt

func (s *Sim) AddOnHurt(f func(s *Sim))

func (*Sim) AddShield

func (s *Sim) AddShield(shd Shield)

func (*Sim) AddShieldBonus

func (s *Sim) AddShieldBonus(f func() float64)

func (*Sim) AddSnapshotHook

func (s *Sim) AddSnapshotHook(f func(ds *Snapshot) bool, key string, hook snapshotHookType)

AddCombatHook adds a hook to sim. Hook will be called based on the type of hook

func (*Sim) AddStamMod

func (s *Sim) AddStamMod(f func(a ActionType) float64)

func (*Sim) AddStatus

func (s *Sim) AddStatus(key string, dur int)

func (*Sim) AddTask

func (s *Sim) AddTask(f TaskFunc, name string, delay int)

func (*Sim) ApplyDamage

func (s *Sim) ApplyDamage(ds Snapshot) (float64, string)

ApplyDamage applies damage to the target given a snapshot

func (*Sim) ApplyReactionDamage

func (s *Sim) ApplyReactionDamage(ds Snapshot)

func (*Sim) ConstructCount

func (s *Sim) ConstructCount() int

how many of the given

func (*Sim) ConstructCountType

func (s *Sim) ConstructCountType(t GeoConstructType) int

func (*Sim) ConstructTick

func (s *Sim) ConstructTick()

func (*Sim) DamageChar

func (s *Sim) DamageChar(dmg float64, ele EleType)

func (*Sim) DamageShields

func (s *Sim) DamageShields(dmg float64, ele EleType) float64

func (*Sim) DeleteStatus

func (s *Sim) DeleteStatus(key string)

func (*Sim) Destroy

func (s *Sim) Destroy(key int) bool

destroy key if exist, return true if destroyed

func (*Sim) GetShield

func (s *Sim) GetShield(t ShieldType) Shield

func (*Sim) GroupTagDamageMult

func (s *Sim) GroupTagDamageMult(grp ICDGroup, char int) float64

func (*Sim) HasConstruct

func (s *Sim) HasConstruct(key int) bool

func (*Sim) HealActive

func (s *Sim) HealActive(hp float64)

func (*Sim) HealAll

func (s *Sim) HealAll(hp float64)

func (*Sim) HealIndex

func (s *Sim) HealIndex(index int, hp float64)

func (*Sim) IncomingHealBonusMult

func (s *Sim) IncomingHealBonusMult() float64

func (*Sim) IsShielded

func (s *Sim) IsShielded() bool

func (*Sim) NewConstruct

func (s *Sim) NewConstruct(c Construct, refresh bool)

func (*Sim) NewNoLimitCons

func (s *Sim) NewNoLimitCons(c Construct, refresh bool)

func (*Sim) QueueDamage

func (s *Sim) QueueDamage(ds Snapshot, delay int)

func (*Sim) ResetAllNormalCounter

func (s *Sim) ResetAllNormalCounter()

func (*Sim) ResetDamageCounterAfterDelay

func (s *Sim) ResetDamageCounterAfterDelay(grp ICDGroup, char int)

func (*Sim) ResetReactionFlags

func (s *Sim) ResetReactionFlags()

func (*Sim) ResetTagCounterAfterDelay

func (s *Sim) ResetTagCounterAfterDelay(tag ICDTag, grp ICDGroup, char int)

func (*Sim) Run

func (s *Sim) Run(length int) (float64, SimStats)

Run the sim; length in seconds

func (*Sim) RunHPMode

func (s *Sim) RunHPMode(hp float64) (float64, SimStats)

Run the sim; length in seconds

func (*Sim) ShieldTick

func (s *Sim) ShieldTick()

func (*Sim) StamPercentMod

func (s *Sim) StamPercentMod(a ActionType) float64

func (*Sim) StatusActive

func (s *Sim) StatusActive(key string) bool

func (*Sim) WillApplyGauge

func (s *Sim) WillApplyGauge(tag ICDTag, grp ICDGroup, char int) bool

type SimStats

type SimStats struct {
	AuraUptime map[EleType]int `json:"aura_uptime"` //uptime in frames

	//these follow 4 are available in avg mode as well
	CharNames            []string             `json:"char_names"`
	DamageByChar         []map[string]float64 `json:"damage_by_char"`
	CharActiveTime       []int                `json:"char_active_time"`
	AbilUsageCountByChar []map[string]int     `json:"abil_usage_count_by_char"`
	ReactionsTriggered   map[ReactionType]int `json:"reactions_triggered"`
	SimDuration          int                  `json:"sim_duration"`
	//super detailed data by frame, only in time mode
	Detailed struct {
		DamageHist         []float64         `json:"damage_hist"`
		LogDetailed        bool              `json:"-"`
		CharActiveFrame    [][]int           `json:"char_active_frame"`
		ElementActiveFrame map[EleType][]int `json:"element_active_frame"`
		AbilUsageByFrame   []AbilUsage       `json:"abil_usage_frame"`
	} `json:"detailed"`

	//final result
	DPS float64 `json:"dps"`
}

type Snapshot

type Snapshot struct {
	CharLvl    int
	ActorEle   EleType
	Actor      string //name of the character triggering the damage
	ActorIndex int

	SourceFrame     int
	AnimationFrames int //really only for amos bow...

	Abil        string      //name of ability triggering the damage
	WeaponClass WeaponClass //b.c. Gladiators...
	AttackTag   AttackTag
	ICDTag      ICDTag
	ICDGroup    ICDGroup
	ImpulseLvl  int

	HitWeakPoint bool
	Mult         float64 //ability multiplier. could set to 0 from initial Mona dmg
	StrikeType   StrikeType
	Element      EleType //element of ability
	Durability   float64 //durability of aura, 0 if nothing applied

	UseDef  bool    //default false
	FlatDmg float64 //flat dmg; so far only zhongli

	Stats []float64 //total character stats including from artifact, bonuses, etc...

	BaseAtk float64 //base attack used in calc
	BaseDef float64 //base def used in calc

	//reaction flags
	IsReaction   bool
	ReactionType ReactionType
	IsMeltVape   bool    //trigger melt/vape
	ReactMult    float64 //reaction multiplier for melt/vape
	ReactBonus   float64 //reaction bonus %+ such as witch; should be 0 and only affected by hooks

}

func (*Snapshot) Clone

func (s *Snapshot) Clone() Snapshot

type StatType

type StatType int
const (
	DEFP StatType = iota
	DEF
	HP
	HPP
	ATK
	ATKP
	ER
	EM
	CR
	CD
	Heal
	PyroP
	HydroP
	CryoP
	ElectroP
	AnemoP
	GeoP
	EleP
	PhyP
	DendroP
	AtkSpd
	DmgP
	//delim
	EndStatType
)

stat types

func EleToDmgP

func EleToDmgP(e EleType) StatType

func StrToStatType

func StrToStatType(s string) StatType

func (StatType) String

func (s StatType) String() string

type StrikeType

type StrikeType int
const (
	StrikeTypeDefault StrikeType = iota
	StrikeTypePierce
	StrikeTypeBlunt
	StrikeTypeSlash
	StrikeTypeSpear
)

type TalentProfile

type TalentProfile struct {
	Attack int
	Skill  int
	Burst  int
}

type Task

type Task struct {
	Name  string
	F     TaskFunc
	Delay int
	// contains filtered or unexported fields
}

func (Task) String

func (t Task) String() string

type TaskFunc

type TaskFunc func(s *Sim)

type TemplateShield

type TemplateShield struct {
	Name       string
	Src        int
	ShieldType ShieldType
	Ele        EleType
	HP         float64
	Expires    int
}

func (*TemplateShield) CurrentHP

func (t *TemplateShield) CurrentHP() float64

func (*TemplateShield) Desc

func (t *TemplateShield) Desc() string

func (*TemplateShield) Element

func (t *TemplateShield) Element() EleType

func (*TemplateShield) Expiry

func (t *TemplateShield) Expiry() int

func (*TemplateShield) Key

func (t *TemplateShield) Key() int

func (*TemplateShield) OnDamage

func (t *TemplateShield) OnDamage(dmg float64, ele EleType, bonus float64) (float64, bool)

func (*TemplateShield) OnExpire

func (t *TemplateShield) OnExpire()

func (*TemplateShield) OnOverwrite

func (t *TemplateShield) OnOverwrite()

func (*TemplateShield) Type

func (t *TemplateShield) Type() ShieldType

type WeaponClass

type WeaponClass string
const (
	WeaponClassSword    WeaponClass = "sword"
	WeaponClassClaymore WeaponClass = "claymore"
	WeaponClassSpear    WeaponClass = "spear"
	WeaponClassBow      WeaponClass = "bow"
	WeaponClassCatalyst WeaponClass = "catalyst"
)

type WeaponInfusion

type WeaponInfusion struct {
	Key    string
	Ele    EleType
	Tags   []AttackTag
	Expiry int
}

type WeaponProfile

type WeaponProfile struct {
	Name   string      `yaml:"WeaponName"`
	Class  WeaponClass `yaml:"WeaponClass"`
	Refine int         `yaml:"WeaponRefinement"`
	Atk    float64     `yaml:"WeaponBaseAtk"`
	Param  map[string]int
}

Jump to

Keyboard shortcuts

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