core

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 8 Imported by: 25

Documentation

Index

Constants

View Source
const (
	MaxStam            = 240
	StamCDFrames       = 90
	JumpFrames         = 33
	DashFrames         = 24
	WalkFrames         = 1
	SwapCDFrames       = 60
	MaxTeamPlayerCount = 4
	DefaultTargetIndex = 1
)

Variables

View Source
var CharNameToKey = map[string]CharKey{
	"travelerelectro":    TravelerElectro,
	"traveleranemo":      TravelerAnemo,
	"travelergeo":        TravelerGeo,
	"travelerhydro":      TravelerHydro,
	"travelercryo":       TravelerCryo,
	"travelerpyro":       TravelerPyro,
	"travelerdendro":     TravelerDendro,
	"traveler (electro)": TravelerElectro,
	"traveler (anemo)":   TravelerAnemo,
	"traveler (geo)":     TravelerGeo,
	"traveler (hydro)":   TravelerHydro,
	"traveler (cryo)":    TravelerCryo,
	"traveler (pyro)":    TravelerPyro,
	"traveler (dendro)":  TravelerDendro,
	"albedo":             Albedo,
	"aloy":               Aloy,
	"amber":              Amber,
	"barbara":            Barbara,
	"beidou":             Beidou,
	"bennett":            Bennett,
	"chongyun":           Chongyun,
	"diluc":              Diluc,
	"diona":              Diona,
	"eula":               Eula,
	"fischl":             Fischl,
	"ganyu":              Ganyu,
	"hutao":              Hutao,
	"jean":               Jean,
	"kaedeharakazuha":    Kazuha,
	"kazuha":             Kazuha,
	"kaeya":              Kaeya,
	"kamisatoayaka":      Ayaka,
	"ayaka":              Ayaka,
	"keqing":             Keqing,
	"klee":               Klee,
	"kujousara":          Sara,
	"kujosara":           Sara,
	"sara":               Sara,
	"lisa":               Lisa,
	"mona":               Mona,
	"ningguang":          Ningguang,
	"noelle":             Noelle,
	"qiqi":               Qiqi,
	"raidenshogun":       Raiden,
	"raiden":             Raiden,
	"razor":              Razor,
	"rosaria":            Rosaria,
	"sangonomiyakokomi":  Kokomi,
	"kokomi":             Kokomi,
	"sayu":               Sayu,
	"sucrose":            Sucrose,
	"tartaglia":          Tartaglia,
	"thoma":              Thoma,
	"venti":              Venti,
	"xiangling":          Xiangling,
	"xiao":               Xiao,
	"xingqiu":            Xingqiu,
	"xinyan":             Xinyan,
	"yanfei":             Yanfei,
	"yoimiya":            Yoimiya,
	"yunjin":             Yunjin,
	"zhongli":            Zhongli,
	"gorou":              Gorou,
	"aratakiitto":        Itto,
	"itto":               Itto,
	"shenhe":             Shenhe,
	"yae":                YaeMiko,
	"yaemiko":            YaeMiko,
}
View Source
var ConstructNameToKey = map[string]GeoConstructType{
	"ningguang":      GeoConstructNingSkill,
	"zhongli":        GeoConstructZhongliSkill,
	"traveler_skill": GeoConstructTravellerSkill,
	"traveler_burst": GeoConstructTravellerBurst,
	"albedo":         GeoConstructAlbedoSkill,
	"itto":           GeoConstructIttoSkill,
}
View Source
var ConstructString = [...]string{
	"Invalid",
	"NingSkill",
	"ZhongliSkill",
	"TravellerSkill",
	"TravellerBurst",
	"AlbedoSkill",
	"IttoSkill",
}
View Source
var EleTypeString = [...]string{
	"electro",
	"pyro",
	"cryo",
	"hydro",
	"frozen",
	"delim",
	"anemo",
	"dendro",
	"geo",
	"",
	"physical",
	"ec",
	"unknown",
}
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 LogSourceFromString = map[string]LogSource{
	"procs":           LogProcs,
	"damage":          LogDamageEvent,
	"pre_damage_mods": LogPreDamageMod,
	"hurt":            LogHurtEvent,
	"heal":            LogHealEvent,
	"calc":            LogCalc,
	"reaction":        LogReactionEvent,
	"element":         LogElementEvent,
	"snapshot":        LogSnapshotEvent,
	"snapshot_mods":   LogSnapshotModsEvent,
	"status":          LogStatusEvent,
	"action":          LogActionEvent,
	"queue":           LogQueueEvent,
	"energy":          LogEnergyEvent,
	"character":       LogCharacterEvent,
	"enemy":           LogEnemyEvent,
	"hook":            LogHookEvent,
	"sim":             LogSimEvent,
	"task":            LogTaskEvent,
	"artifact":        LogArtifactEvent,
	"weapon":          LogWeaponEvent,
	"shield":          LogShieldEvent,
	"construct":       LogConstructEvent,
	"icd":             LogICDEvent,
}
View Source
var LogSourceString = [...]string{
	"procs",
	"damage",
	"pre_damage_mods",
	"hurt",
	"heal",
	"calc",
	"reaction",
	"element",
	"snapshot",
	"snapshot_mods",
	"status",
	"action",
	"queue",
	"energy",
	"character",
	"enemy",
	"hook",
	"sim",
	"task",
	"artifact",
	"weapon",
	"shield",
	"construct",
	"icd",
}
View Source
var StatTypeString = [...]string{
	"n/a",
	"def%",
	"def",
	"hp",
	"hp%",
	"atk",
	"atk%",
	"er",
	"em",
	"cr",
	"cd",
	"heal",
	"pyro%",
	"hydro%",
	"cryo%",
	"electro%",
	"anemo%",
	"geo%",
	"phys%",

	"dendro%",
	"atkspd%",
	"dmg%",
}

Functions

func PrettyPrintStats

func PrettyPrintStats(stats []float64) string

func PrettyPrintStatsSlice

func PrettyPrintStatsSlice(stats []float64) []string

func RegisterCharFunc

func RegisterCharFunc(char CharKey, f NewCharacterFunc)

func RegisterSetFunc

func RegisterSetFunc(name string, f NewSetFunc)

func RegisterWeaponFunc

func RegisterWeaponFunc(name string, f NewWeaponFunc)

Types

type ActionBlock

type ActionBlock struct {
	Label string //label for this block
	Type  ActionBlockType
	//sequence is only relevant to ActionBlockTypeSequence
	Sequence     []ActionItem
	SequenceChar CharKey

	ChainSequences []ActionBlock

	//conditions
	Conditions *ExprTreeNode //conditions to be met
	OnField    bool          //if true then can only use if char is on field; sequence only
	Needs      string        //previous queued action block label must match this
	Limit      int           //number of times this action block can be queued
	Timeout    int           //the action block cannot be used again for x frames

	//options
	SwapTo            CharKey //character to swap to after this block
	SwapLock          int     //must stay on current char for x frames
	Try               bool    //if true then drop rest of queue if any action is not ready
	TryDropIfNotReady bool    //if false will keep trying next action; other wise drop sequence. Only if Try is set to true

	//tracking
	NumQueued  int //number of times this action block has been queued
	LastQueued int //last time this action block was queued

	//options related to wait
	Wait     CmdWait
	CalcWait CmdCalcWait
}

func (*ActionBlock) Clone

func (a *ActionBlock) Clone() ActionBlock

type ActionBlockType

type ActionBlockType int
const (
	ActionBlockTypeSequence ActionBlockType = iota
	ActionBlockTypeWait
	ActionBlockTypeChain
	ActionBlockTypeResetLimit
	ActionBlockTypeCalcWait
	ActionBlockTypeCalcRestart
)

type ActionItem

type ActionItem struct {
	Typ    ActionType
	Param  map[string]int
	Target CharKey
}

func (*ActionItem) Clone

func (a *ActionItem) Clone() ActionItem

func (*ActionItem) Type

func (a *ActionItem) Type() CommandType

type ActionType

type ActionType int
const (
	InvalidAction ActionType = iota
	ActionSkill
	ActionBurst
	ActionAttack
	ActionCharge
	ActionHighPlunge
	ActionLowPlunge
	ActionAim
	ActionCancellable // delim cancellable action
	ActionDash
	ActionJump
	ActionSwap
	ActionWalk
	EndActionType
	//these are only used for frames purposes and that's why it's after end
	ActionSkillHoldFramesOnly
)

func (ActionType) String

func (a ActionType) String() string

type AnimationState

type AnimationState int
const (
	Idle AnimationState = iota
	NormalAttackState
	ChargeAttackState
	PlungeAttackState
	SkillState
	BurstState
	AimState
	DashState
)

type AttackCB

type AttackCB struct {
	Target      Target
	AttackEvent *AttackEvent
	Damage      float64
	IsCrit      bool
}

type AttackCBFunc

type AttackCBFunc func(AttackCB)

type AttackEvent

type AttackEvent struct {
	Info    AttackInfo
	Pattern AttackPattern
	// Timing        AttackTiming
	Cancelled   bool //provide a way to cancel an attack event
	Snapshot    Snapshot
	SourceFrame int            //source frame
	Callbacks   []AttackCBFunc `json:"-"`
}

type AttackInfo

type AttackInfo struct {
	ActorIndex       int    //character this attack belongs to
	DamageSrc        int    //source of this attack (i.e. index of core.Targets); always 0 for player, 1+ for the rest
	Abil             string //name of ability triggering the damage
	AttackTag        AttackTag
	ICDTag           ICDTag
	ICDGroup         ICDGroup
	Element          EleType    //element of ability
	Durability       Durability //durability of aura, 0 if nothing applied
	NoImpulse        bool
	HitWeakPoint     bool
	Mult             float64 //ability multiplier. could set to 0 from initial Mona dmg
	StrikeType       StrikeType
	UseDef           bool    //we use this instead of flatdmg to make sure stat snapshotting works properly
	FlatDmg          float64 //flat dmg;
	IgnoreDefPercent float64 //by default this value is 0; if = 1 then the attack will ignore defense; raiden c2 should be set to 0.6 (i.e. ignore 60%)
	IgnoreInfusion   bool
	//amp info
	Amped   bool         //new flag used by new reaction system
	AmpMult float64      //amplier
	AmpType ReactionType //melt or vape i guess
	//special flag for sim generated attack
	SourceIsSim bool
	DoNotLog    bool
}

type AttackPattern

type AttackPattern struct {
	Shape    Shape
	Targets  [TargettableTypeCount]bool
	SelfHarm bool
}

func NewCircleHit

func NewCircleHit(x, y, r float64, self bool, targets ...TargettableType) AttackPattern

func NewDefBoxHit

func NewDefBoxHit(w, h float64, self bool, targets ...TargettableType) AttackPattern

func NewDefCircHit

func NewDefCircHit(r float64, self bool, targets ...TargettableType) AttackPattern

func NewDefSingleTarget

func NewDefSingleTarget(ind int, typ TargettableType) AttackPattern

type AttackTag

type AttackTag int //attacktag is used instead of actions etc..
const (
	AttackTagNone AttackTag = iota
	AttackTagNormal
	AttackTagExtra
	AttackTagPlunge
	AttackTagElementalArt
	AttackTagElementalArtHold
	AttackTagElementalBurst
	AttackTagWeaponSkill
	AttackTagMonaBubbleBreak
	AttackTagNoneStat
	ReactionAttackDelim
	AttackTagOverloadDamage
	AttackTagSuperconductDamage
	AttackTagECDamage
	AttackTagShatter
	AttackTagSwirlPyro
	AttackTagSwirlHydro
	AttackTagSwirlCryo
	AttackTagSwirlElectro
	AttackTagLength
)

type CDAdjust

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

type CharKey

type CharKey int
const (
	NoChar CharKey = iota
	TravelerElectro
	TravelerAnemo
	TravelerGeo
	TravelerHydro
	TravelerCryo
	TravelerPyro
	TravelerDendro
	TravelerMale
	TravelerFemale
	TravelerDelim // delim
	Albedo
	Aloy
	Amber
	Barbara
	Beidou
	Bennett
	Chongyun
	Diluc
	Diona
	Eula
	Fischl
	Ganyu
	Hutao
	Jean
	Kazuha
	Kaeya
	Ayaka
	Keqing
	Klee
	Sara
	Lisa
	Mona
	Ningguang
	Noelle
	Qiqi
	Raiden
	Razor
	Rosaria
	Kokomi
	Sayu
	Sucrose
	Tartaglia
	Thoma
	Venti
	Xiangling
	Xiao
	Xingqiu
	Xinyan
	Yanfei
	Yoimiya
	Zhongli
	Gorou
	Itto
	Shenhe
	Yunjin
	YaeMiko
)

func (CharKey) String

func (c CharKey) String() string

type CharStatMod

type CharStatMod struct {
	Key           string
	AffectedStat  StatType
	Amount        func() ([]float64, bool) // Returns an array containing the stats boost and whether mod applies
	ConditionTags []AttackTag
	Expiry        int
}

type Character

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

	//information functions
	Key() CharKey
	Name() string
	CharIndex() int
	Ele() EleType
	Level() int
	WeaponClass() WeaponClass
	SetWeaponKey(k string)
	WeaponKey() string
	Zone() ZoneType
	CurrentEnergy() float64 //current energy
	MaxEnergy() float64
	HP() float64
	MaxHP() float64
	ModifyHP(float64)
	Stat(s StatType) float64

	CalcBaseStats() error

	AddTask(fun func(), name string, delay int)

	//actions; each action should return 2 ints:
	//	the earliest frame at which the next action may be queued, and;
	// 	the total length of the animation state
	Attack(p map[string]int) (int, int)
	Aimed(p map[string]int) (int, int)
	ChargeAttack(p map[string]int) (int, int)
	HighPlungeAttack(p map[string]int) (int, int)
	LowPlungeAttack(p map[string]int) (int, int)
	Skill(p map[string]int) (int, int)
	Burst(p map[string]int) (int, int)
	Dash(p map[string]int) (int, int)

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

	//number of frames this action will take
	// ActionFrames(a ActionType, p map[string]int) int
	//return the number of frames the current action must wait before it can be
	//executed;
	ActionInterruptableDelay(next ActionType, p map[string]int) int

	//char stat mods
	AddMod(mod CharStatMod)
	ModIsActive(key string) bool
	AddPreDamageMod(mod PreDamageMod)
	AddWeaponInfuse(inf WeaponInfusion)
	WeaponInfuseIsActive(key string) bool
	AddReactBonusMod(mod ReactionBonusMod)
	ReactBonus(AttackInfo) float64

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

	//status stuff
	AddTag(key string, val int)
	RemoveTag(key string)
	Tag(key string) int

	//energy
	QueueParticle(src string, num int, ele EleType, delay int)
	ReceiveParticle(p Particle, isActive bool, partyCount int)
	AddEnergy(src string, e float64)

	//combat
	Snapshot(a *AttackInfo) Snapshot
	PreDamageSnapshotAdjust(*AttackEvent, Target) []interface{}
	ResetNormalCounter()
}

type CharacterBase

type CharacterBase struct {
	Key      CharKey `json:"-"`
	Name     string  `json:"name"`
	Element  EleType `json:"element"`
	Level    int     `json:"level"`
	MaxLevel int     `json:"max_level"`
	HP       float64 `json:"-"`
	Atk      float64 `json:"-"`
	Def      float64 `json:"-"`
	Cons     int     `json:"cons"`
	StartHP  float64 `json:"-"`
}

type CharacterProfile

type CharacterProfile struct {
	Base      CharacterBase             `json:"base"`
	Weapon    WeaponProfile             `json:"weapon"`
	Talents   TalentProfile             `json:"talents"`
	Stats     []float64                 `json:"stats"`
	Sets      map[string]int            `json:"sets"`
	SetParams map[string]map[string]int `json:"-"`
	Params    map[string]int            `json:"-"`
}

func (*CharacterProfile) Clone

type Circle

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

func NewCircle

func NewCircle(x, y, r float64) *Circle

func (*Circle) IntersectCircle

func (c *Circle) IntersectCircle(c2 Circle) bool

func (*Circle) IntersectRectangle

func (c *Circle) IntersectRectangle(r Rectangle) bool

func (*Circle) Pos

func (c *Circle) Pos() (float64, float64)

func (*Circle) String

func (c *Circle) String() string

type CmdCalcWait

type CmdCalcWait struct {
	Frames bool
	Val    int
}

type CmdNoSwap

type CmdNoSwap struct {
	Val int
}

func (*CmdNoSwap) Type

func (c *CmdNoSwap) Type() CommandType

type CmdResetLimit

type CmdResetLimit struct {
}

func (CmdResetLimit) Type

func (c CmdResetLimit) Type() CommandType

type CmdWait

type CmdWait struct {
	For        CmdWaitType
	Max        int //cannot be 0 if type is timed
	Source     string
	Conditions Condition
	FillAction ActionItem
}

func (*CmdWait) Clone

func (c *CmdWait) Clone() CmdWait

func (*CmdWait) Type

func (c *CmdWait) Type() CommandType

type CmdWaitType

type CmdWaitType int
const (
	CmdWaitTypeInvalid CmdWaitType = iota
	CmdWaitTypeTimed
	CmdWaitTypeParticle
	CmdWaitTypeMods
)

type CombatHandler

type CombatHandler interface {
	ApplyDamage(*AttackEvent) float64
	QueueAttack(a AttackInfo, p AttackPattern, snapshotDelay int, dmgDelay int, callbacks ...AttackCBFunc)
	QueueAttackWithSnap(a AttackInfo, s Snapshot, p AttackPattern, dmgDelay int, callbacks ...AttackCBFunc)
	QueueAttackEvent(ae *AttackEvent, dmgDelay int)
	TargetHasResMod(debuff string, param int) bool
	TargetHasDefMod(debuff string, param int) bool
	TargetHasElement(ele EleType, param int) bool
}

type Command

type Command interface {
	Type() CommandType
}

Command is what gets executed by the sim.

type CommandHandler

type CommandHandler interface {
	Exec(n Command) (frames int, done bool, err error) //return frames, if executed, any errors
}

type CommandType

type CommandType int
const (
	CommandTypeAction CommandType = iota
	CommandTypeWait
	CommandTypeNoSwap
	CommandTypeResetLimit
)

type Condition

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

func (*Condition) Clone

func (c *Condition) Clone() Condition

func (*Condition) String

func (c *Condition) String()

type Construct

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

type ConstructHandler

type ConstructHandler interface {
	New(c Construct, refresh bool)
	NewNoLimitCons(c Construct, refresh bool)
	Count() int
	CountByType(t GeoConstructType) int
	Destroy(key int) bool
	Has(key int) bool
	Expiry(t GeoConstructType) int
	Tick()
}

type Core

type Core struct {
	//control
	F     int   // current frame
	Flags Flags // global flags
	Rand  *rand.Rand
	Log   LogCtrl

	//core data
	Stam   float64
	SwapCD int

	//track characters
	ActiveChar     int             // index of currently active char
	ActiveDuration int             // duration in frames that the current char has been on field for
	Chars          []Character     // array holding all the characters on the team
	CharPos        map[CharKey]int // map of character string name to their index (for quick lookup by name)

	//track targets
	Targets     []Target
	TotalDamage float64 // keeps tracks of total damage dealt for the purpose of final results

	//last action taken by the sim
	LastAction ActionItem

	//handlers
	Status     StatusHandler
	Energy     EnergyHandler
	Action     CommandHandler
	Queue      QueueHandler
	Combat     CombatHandler
	Tasks      TaskHandler
	Constructs ConstructHandler
	Shields    ShieldHandler
	Health     HealthHandler
	Events     EventHandler
	// contains filtered or unexported fields
}

func New

func New() *Core

func (*Core) AbsorbCheck

func (c *Core) AbsorbCheck(prio ...EleType) EleType

func (*Core) AddChar

func (c *Core) AddChar(v CharacterProfile) (Character, error)

func (*Core) AddStamMod

func (c *Core) AddStamMod(f func(a ActionType) (float64, bool), key string)

func (*Core) AddTarget

func (c *Core) AddTarget(t Target)

func (*Core) AnimationCancelDelay

func (c *Core) AnimationCancelDelay(next ActionType, p map[string]int) int

func (*Core) CharByName

func (c *Core) CharByName(key CharKey) (Character, bool)

func (*Core) ClearState

func (c *Core) ClearState()

func (*Core) EnemyByDistance

func (c *Core) EnemyByDistance(x, y float64, excl int) []int

EnemeyByDistance returns an array of indices of the enemies sorted by distance

func (*Core) EnemyExcl

func (c *Core) EnemyExcl(self int) []int

EnemyExcl returns array of indices of enemies, excluding self

func (*Core) GetCustomFlag

func (c *Core) GetCustomFlag(key string) (int, bool)

func (*Core) Init

func (c *Core) Init()

func (*Core) RandomEnemyTarget

func (c *Core) RandomEnemyTarget() int

func (*Core) RandomTargetIndex

func (c *Core) RandomTargetIndex(typ TargettableType) int

func (*Core) RemoveTarget

func (c *Core) RemoveTarget(i int)

func (*Core) ResetAllNormalCounter

func (c *Core) ResetAllNormalCounter()

func (*Core) RestoreStam

func (c *Core) RestoreStam(v float64)

func (*Core) SetCustomFlag

func (c *Core) SetCustomFlag(key string, val int)

func (*Core) SetState

func (c *Core) SetState(state AnimationState, duration int)

func (*Core) Skip

func (c *Core) Skip(n int)

func (*Core) StamPercentMod

func (c *Core) StamPercentMod(a ActionType) float64

func (*Core) State

func (c *Core) State() AnimationState

func (*Core) Swap

func (c *Core) Swap(next CharKey) int

func (*Core) Tick

func (c *Core) Tick()

func (*Core) UserCustomDelay

func (c *Core) UserCustomDelay() int

type DefMod

type DefMod struct {
	Key    string
	Value  float64
	Expiry int
}

type Delays added in v0.5.5

type Delays struct {
	Swap   int
	Attack int
	Charge int
	Skill  int
	Burst  int
	Dash   int
	Jump   int
}

type Durability

type Durability float64

type EleType

type EleType int

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

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

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

func StringToEle

func StringToEle(s string) EleType

func (EleType) String

func (e EleType) String() string

type EnemyProfile

type EnemyProfile struct {
	Level          int                 `json:"level"`
	HP             float64             `json:"-"`
	Resist         map[EleType]float64 `json:"-"`
	Size           float64             `json:"-"`
	CoordX, CoordY float64             `json:"-"`
}

func (*EnemyProfile) Clone

func (e *EnemyProfile) Clone() EnemyProfile

type EnergyEvent

type EnergyEvent struct {
	Active    bool
	Once      bool //how often
	Start     int
	End       int
	Particles int
}

type EnergyHandler

type EnergyHandler interface {
	DistributeParticle(p Particle)
}

type EventHandler

type EventHandler interface {
	Subscribe(e EventType, f EventHook, key string)
	Unsubscribe(e EventType, key string)
	Emit(e EventType, args ...interface{})
}

type EventHook

type EventHook func(args ...interface{}) bool

type EventType

type EventType int
const (
	OnAttackWillLand EventType = iota //target, AttackEvent
	OnDamage                          //target, AttackEvent, amount, crit

	OnAuraDurabilityAdded    //target, ele, durability
	OnAuraDurabilityDepleted //target, ele
	// OnReaction               //target, AttackEvent, ReactionType
	ReactionEventStartDelim
	OnOverload       //target, AttackEvent
	OnSuperconduct   //target, AttackEvent
	OnMelt           //target, AttackEvent
	OnVaporize       //target, AttackEvent
	OnFrozen         //target, AttackEvent
	OnElectroCharged //target, AttackEvent
	OnSwirlHydro
	OnSwirlCryo
	OnSwirlElectro
	OnSwirlPyro
	OnCrystallizeHydro
	OnCrystallizeCryo
	OnCrystallizeElectro
	OnCrystallizePyro
	ReactionEventEndDelim
	//other stuff
	OnStamUse          //abil
	OnShielded         //shield
	OnCharacterSwap    //prev, next
	OnDash             //nil
	OnParticleReceived //particle
	OnEnergyChange     //character_received, pre_energy, energy_change, src (post-energy available in character_received)
	OnTargetDied       //target
	OnCharacterHurt    //nil
	OnHeal             //src char, target character, amount
	//ability use
	PreSkill         //nil
	PostSkill        //nil, frames
	PreBurst         //nil
	PostBurst        //nil, frames
	PreAttack        //nil
	PostAttack       //nil, frames
	PreChargeAttack  //nil
	PostChargeAttack //nil, frames
	PrePlunge        //nil
	PostPlunge       //nil, frames
	PreAimShoot      //nil
	PostAimShoot     //nil, frames
	PreDash
	PostDash
	//sim stuff
	OnInitialize  //nil
	OnStateChange //prev, next
	OnTargetAdded //t
	EndEventTypes //elim
)

type ExprTreeNode

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

func (*ExprTreeNode) Clone

func (e *ExprTreeNode) Clone() *ExprTreeNode

type Flags

type Flags struct {
	DamageMode     bool
	EnergyCalcMode bool // Allows Burst Action when not at full Energy, logs current Energy when using Burst
	LogDebug       bool // Used to determine logging level
	ChildeActive   bool // Used for Childe +1 NA talent passive
	Delays         Delays
	// AmpReactionDidOccur bool
	// AmpReactionType     ReactionType
	// NextAttackMVMult    float64 // melt vape multiplier
	// ReactionDamageTriggered bool
	Custom map[string]int
}

type GeoConstructType

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

func (GeoConstructType) String

func (c GeoConstructType) String() string

type HealthHandler

type HealthHandler interface {
	HealIndex(caller int, index int, amt float64)
	HealActive(caller int, amt float64)
	HealAll(caller int, amt float64)
	HealAllPercent(caller int, percent float64)
	AddIncHealBonus(f func(healedCharIndex int) float64)

	AddDamageReduction(f func() (float64, bool))
	HurtChar(dmg float64, ele EleType)
}

type HurtEvent

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

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
	ICDTagDash
	ICDTagLisaElectro
	ICDTagYanfeiFire
	ICDTagVentiBurstAnemo
	ICDTagVentiBurstPyro
	ICDTagVentiBurstHydro
	ICDTagVentiBurstCryo
	ICDTagVentiBurstElectro
	ICDTagMonaWaterDamage
	ICDTagTravelerWakeOfEarth
	ICDTagKleeFireDamage
	ICDTagTartagliaRiptideFlash
	ICDReactionDamageDelim
	ICDTagOverloadDamage
	ICDTagSuperconductDamage
	ICDTagECDamage
	ICDTagShatter
	ICDTagSwirlPyro
	ICDTagSwirlHydro
	ICDTagSwirlCryo
	ICDTagSwirlElectro
	ICDTagLength
)

type LogCtrl

type LogCtrl interface {
	NewEvent(msg string, typ LogSource, srcChar int, keysAndValues ...interface{}) LogEvent
	NewEventBuildMsg(typ LogSource, srcChar int, msg ...string) LogEvent
	Dump() ([]byte, error) //print out all the logged events in array of JSON strings in the ordered they were added
}

type LogEvent

type LogEvent interface {
	LogSource() LogSource           //returns the type of this log event i.e. character, sim, damage, etc...
	StartFrame() int                //returns the frame on which this event was started
	Src() int                       //returns the index of the character that triggered this event. -1 if it's not a character
	Write(keyAndVal ...interface{}) //write additional keyAndVal pairs to the event
	SetEnded(f int)
}

type LogSource

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

func (LogSource) String

func (l LogSource) String() string

type NewCharacterFunc

type NewCharacterFunc func(core *Core, p CharacterProfile) (Character, error)

type NewSetFunc

type NewSetFunc func(c Character, core *Core, count int, param map[string]int)

type NewWeaponFunc

type NewWeaponFunc func(c Character, core *Core, r int, param map[string]int) string

type NilLogEvent

type NilLogEvent struct{}

func (*NilLogEvent) LogSource

func (n *NilLogEvent) LogSource() LogSource

func (*NilLogEvent) SetEnded

func (n *NilLogEvent) SetEnded(f int)

func (*NilLogEvent) Src

func (n *NilLogEvent) Src() int

func (*NilLogEvent) StartFrame

func (n *NilLogEvent) StartFrame() int

func (*NilLogEvent) Write

func (n *NilLogEvent) Write(keyAndVal ...interface{})

type NilLogger

type NilLogger struct{}

func (*NilLogger) Dump

func (n *NilLogger) Dump() ([]byte, error)

func (*NilLogger) NewEvent

func (n *NilLogger) NewEvent(msg string, typ LogSource, srcChar int, keysAndValues ...interface{}) LogEvent

func (*NilLogger) NewEventBuildMsg

func (n *NilLogger) NewEventBuildMsg(typ LogSource, srcChar int, msg ...string) LogEvent

type Particle

type Particle struct {
	Source string
	Num    int
	Ele    EleType
}

type PreDamageMod

type PreDamageMod struct {
	Key    string
	Amount func(atk *AttackEvent, t Target) ([]float64, bool) // Returns an array containing the stats boost and whether mod applies
	Expiry int
}

type QueueHandler

type QueueHandler interface {
	//returns a sequence of 1 or more commands to execute,
	//whether or not to drop sequence if any is not ready, and any error
	Next() (queue []Command, dropIfFailed bool, err error)
	SetActionList(pq []ActionBlock) error
}

type ReactionBonusMod

type ReactionBonusMod struct {
	Key    string
	Amount func(AttackInfo) (float64, bool)
	Expiry int
}

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 Rectangle

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

func (*Rectangle) IntersectCircle

func (r *Rectangle) IntersectCircle(c Circle) bool

func (*Rectangle) IntersectRectangle

func (r *Rectangle) IntersectRectangle(r2 Rectangle) bool

func (*Rectangle) Pos

func (r *Rectangle) Pos() (float64, float64)

func (*Rectangle) String

func (r *Rectangle) String() string

type ResistMod

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

type SelfDamage

type SelfDamage struct{}

this is for attack that only hits self

func (*SelfDamage) IntersectCircle

func (c *SelfDamage) IntersectCircle(in Circle) bool

func (*SelfDamage) IntersectRectangle

func (c *SelfDamage) IntersectRectangle(in Rectangle) bool

type Shape

type Shape interface {
	IntersectCircle(c Circle) bool
	IntersectRectangle(r Rectangle) bool
	Pos() (x, y float64)
	String() string
}

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 ShieldHandler

type ShieldHandler interface {
	Add(shd Shield)
	IsShielded(char int) bool
	Get(t ShieldType) Shield
	AddBonus(f func() float64)
	OnDamage(dmg float64, ele EleType) float64
	Count() int
	Tick()
}

type ShieldType

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

type SimulationConfig

type SimulationConfig struct {
	//these settings relate to each simulation iteration
	DamageMode bool
	Targets    []EnemyProfile
	Characters struct {
		Initial CharKey
		Profile []CharacterProfile
	}
	Rotation []ActionBlock
	Hurt     HurtEvent
	Energy   EnergyEvent
	Settings SimulatorSettings
}

SimulationConfig describes the required settings to run an simulation

func (*SimulationConfig) Clone

type SimulationQueueMode

type SimulationQueueMode int
const (
	ActionPriorityList SimulationQueueMode = iota
	SequentialList
)

type SimulatorSettings

type SimulatorSettings struct {
	Duration   int
	DamageMode bool
	Delays     Delays

	//modes
	QueueMode  SimulationQueueMode
	ERCalcMode bool

	//other stuff
	NumberOfWorkers int // how many workers to run the simulation
	Iterations      int // how many iterations to run
}

type SingleTarget

type SingleTarget struct {
	Target int
}

func (*SingleTarget) IntersectCircle

func (s *SingleTarget) IntersectCircle(in Circle) bool

func (*SingleTarget) IntersectRectangle

func (s *SingleTarget) IntersectRectangle(in Rectangle) bool

func (*SingleTarget) Pos

func (s *SingleTarget) Pos() (float64, float64)

func (*SingleTarget) String

func (s *SingleTarget) String() string

type Snapshot

type Snapshot struct {
	CharLvl    int
	ActorEle   EleType
	ExtraIndex int                  //this is currently purely for Kaeya icicle ICD
	Cancelled  bool                 //set to true if this snap should be ignored
	Stats      [EndStatType]float64 //total character stats including from artifact, bonuses, etc...
	BaseAtk    float64              //base attack used in calc
	BaseDef    float64

	SourceFrame int           // frame snapshot was generated at
	Logs        []interface{} // logs for the snapshot
}

type StatType

type StatType int
const (
	NoStat StatType = iota
	DEFP
	DEF
	HP
	HPP
	ATK
	ATKP
	ER
	EM
	CR
	CD
	Heal
	PyroP
	HydroP
	CryoP
	ElectroP
	AnemoP
	GeoP
	PhyP
	// ElementalP
	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 StatusHandler

type StatusHandler interface {
	Duration(key string) int
	AddStatus(key string, dur int)
	ExtendStatus(key string, dur int)
	DeleteStatus(key string)
}

type StrikeType

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

type TalentProfile

type TalentProfile struct {
	Attack int `json:"attack"`
	Skill  int `json:"skill"`
	Burst  int `json:"burst"`
}

type Target

type Target interface {
	//basic info
	Type() TargettableType //type of target
	Index() int            //should correspond to index
	SetIndex(ind int)      //update the current index
	MaxHP() float64
	HP() float64

	//collision detection
	Shape() Shape

	//attacks
	Attack(*AttackEvent, LogEvent) (float64, bool)

	//reaction/aura stuff
	Tick()
	AuraContains(...EleType) bool
	AuraType() EleType

	//tags
	SetTag(key string, val int)
	GetTag(key string) int
	RemoveTag(key string)

	//target mods
	AddDefMod(key string, val float64, dur int)
	AddResMod(key string, val ResistMod)
	RemoveResMod(key string)
	RemoveDefMod(key string)
	HasDefMod(key string) bool
	HasResMod(key string) bool

	//getting rid of
	Kill()
}

type TargettableType

type TargettableType int
const (
	TargettableEnemy TargettableType = iota
	TargettablePlayer
	TargettableObject
	TargettableTypeCount
)

type TaskHandler

type TaskHandler interface {
	Add(f func(), delay int)
	Run()
}

type WeaponClass

type WeaponClass int
const (
	WeaponClassSword WeaponClass = iota
	WeaponClassClaymore
	WeaponClassSpear
	WeaponClassBow
	WeaponClassCatalyst
	EndWeaponClass
)

func (WeaponClass) String

func (w WeaponClass) String() string

type WeaponInfusion

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

type WeaponProfile

type WeaponProfile struct {
	Name     string         `json:"name"`
	Key      string         `json:""` //use this to match with weapon curve mapping
	Class    WeaponClass    `json:"-"`
	Refine   int            `json:"refine"`
	Level    int            `json:"level"`
	MaxLevel int            `json:"max_level"`
	Atk      float64        `json:"-"`
	Params   map[string]int `json:"-"`
}

type ZoneType

type ZoneType int
const (
	ZoneMondstadt ZoneType = iota
	ZoneLiyue
	ZoneInazuma
)

Jump to

Keyboard shortcuts

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