Files
horse/horse/skill.go

173 lines
5.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package horse
import (
"bytes"
"fmt"
"strconv"
)
type SkillID int32
type TenThousandths int32
func (x TenThousandths) String() string {
b := make([]byte, 0, 12)
if x < 0 {
x = -x
b = append(b, '-')
}
b = strconv.AppendInt(b, int64(x/1e4), 10)
if x%1e4 != 0 {
b = append(b, '.')
b = fmt.Appendf(b, "%04d", x%1e4)
b = bytes.TrimRight(b, "0")
}
return string(b)
}
// Skill is the internal data about a skill.
type Skill struct {
ID SkillID
Name string
Description string
Group int32
Rarity int8
GroupRate int8
GradeValue int32
WitCheck bool
Activations []Activation
SPCost int
IconID int
}
// Activation is the parameters controlling when a skill activates.
type Activation struct {
Precondition string
Condition string
Duration TenThousandths
Cooldown TenThousandths
Abilities []Ability
}
// Ability is an individual effect applied by a skill.
type Ability struct {
Type AbilityType
ValueUsage AbilityValueUsage
Value TenThousandths
Target AbilityTarget
TargetValue int32
}
func (a Ability) String() string {
r := make([]byte, 0, 64)
r = append(r, a.Type.String()...)
if a.Value != 0 {
r = append(r, ' ')
if a.Value > 0 {
r = append(r, '+')
}
switch a.Type {
case AbilityPassiveSpeed, AbilityPassiveStamina, AbilityPassivePower, AbilityPassiveGuts, AbilityPassiveWit:
r = append(r, a.Value.String()...)
case AbilityVision:
r = append(r, a.Value.String()...)
r = append(r, 'm')
case AbilityHP:
r = append(r, (a.Value * 100).String()...)
r = append(r, '%')
case AbilityGateDelay:
r = append(r, a.Value.String()...)
r = append(r, "×"...)
case AbilityFrenzy:
r = append(r, a.Value.String()...)
r = append(r, 's')
case AbilityCurrentSpeed, AbilityTargetSpeed, AbilityLaneSpeed:
r = append(r, a.Value.String()...)
r = append(r, " m/s"...)
case AbilityAccel:
r = append(r, a.Value.String()...)
r = append(r, " m/s²"...)
case AbilityLaneChange:
r = append(r, a.Value.String()...)
r = append(r, " track widths"...)
}
}
if a.Target != TargetSelf {
r = append(r, " to "...)
if a.TargetValue > 1 && a.TargetValue < 18 {
r = strconv.AppendInt(r, int64(a.TargetValue), 10)
r = append(r, ' ')
}
r = append(r, a.Target.String()...)
}
if a.ValueUsage != ValueUsageDirect {
r = append(r, ' ')
r = append(r, a.ValueUsage.String()...)
}
return string(r)
}
type AbilityType int8
//go:generate go run golang.org/x/tools/cmd/stringer@v0.41.0 -type AbilityType -trimprefix Ability -linecomment
const (
AbilityPassiveSpeed AbilityType = 1 // Speed
AbilityPassiveStamina AbilityType = 2 // Stamina
AbilityPassivePower AbilityType = 3 // Power
AbilityPassiveGuts AbilityType = 4 // Guts
AbilityPassiveWit AbilityType = 5 // Wit
AbilityGreatEscape AbilityType = 6 // Enable Great Escape
AbilityVision AbilityType = 8 // Vision
AbilityHP AbilityType = 9 // HP
AbilityGateDelay AbilityType = 10 // Gate delay multiplier
AbilityFrenzy AbilityType = 13 // Frenzy
AbilityCurrentSpeed AbilityType = 21 // Current speed
AbilityTargetSpeed AbilityType = 27 // Target speed
AbilityLaneSpeed AbilityType = 28 // Lane change speed
AbilityAccel AbilityType = 31 // Acceleration
AbilityLaneChange AbilityType = 35 // Forced lane change
)
type AbilityValueUsage int8
//go:generate go run golang.org/x/tools/cmd/stringer@v0.41.0 -type AbilityValueUsage -trimprefix ValueUsage -linecomment
const (
ValueUsageDirect AbilityValueUsage = 1 // directly
ValueUsageSkillCount AbilityValueUsage = 2 // scaling with the number of skills
ValueUsageTeamSpeed AbilityValueUsage = 3 // scaling with team Speed
ValueUsageTeamStamina AbilityValueUsage = 4 // scaling with team Stamina
ValueUsageTeamPower AbilityValueUsage = 5 // scaling with team Power
ValueUsageTeamGuts AbilityValueUsage = 6 // scaling with team Guts
ValueUsageTeamWit AbilityValueUsage = 7 // scaling with team Wit
ValueUsageRandom AbilityValueUsage = 8 // with a random 0× to 0.04× multiplier
ValueUsageRandom2 AbilityValueUsage = 9 // with a random 0× to 0.04× multiplier
ValueUsageClimax AbilityValueUsage = 10 // scaling with the number of races won in training
ValueUsageMaxStat AbilityValueUsage = 13 // scaling with the highest raw stat
ValueUsageGreenCount AbilityValueUsage = 14 // scaling with the number of Passive skills activated
ValueUsageDistAdd AbilityValueUsage = 19 // plus extra when far from the lead
ValueUsageMidSideBlock AbilityValueUsage = 20 // scaling with mid-race phase blocked side time
ValueUsageSpeed AbilityValueUsage = 22 // scaling with overall speed
ValueUsageSpeed2 AbilityValueUsage = 23 // scaling with overall speed
ValueUsageArcPotential AbilityValueUsage = 24 // scaling with L'Arc global potential
ValueUsageMaxLead AbilityValueUsage = 25 // scaling with the longest lead obtained in the first ⅔
)
type AbilityTarget int8
//go:generate go run golang.org/x/tools/cmd/stringer@v0.41.0 -type AbilityTarget -trimprefix Target -linecomment
const (
TargetSelf AbilityTarget = 1 // self
TargetSympathizers AbilityTarget = 2 // others with Sympathy
TargetInView AbilityTarget = 4 // others in view
TargetFrontmost AbilityTarget = 7 // frontmost
TargetAhead AbilityTarget = 9 // others ahead
TargetBehind AbilityTarget = 10 // others behind
TargetAllTeammates AbilityTarget = 11 // all teammates
TargetStyle AbilityTarget = 18 // using style
TargetRushingAhead AbilityTarget = 19 // rushing others ahead
TargetRushingBehind AbilityTarget = 20 // rushing others behind
TargetRushingStyle AbilityTarget = 21 // rushing using style
TargetCharacter AbilityTarget = 22 // specific character
TargetTriggering AbilityTarget = 23 // whosoever triggered this skill
)