strategy

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttackStrategy

type AttackStrategy struct {
	Name        string
	Description string
	DeployLine  string
	Sides       int
	DropOrders  []Drop
}

type Drop

type Drop struct {
	X, Y     int
	Troop    string
	Quantity int
	Delay    int
	Slot     int
	DropType string
	Wave     int
}

type DynamicStrategy

type DynamicStrategy struct {
	Name                  string  `yaml:"name"`
	Description           string  `yaml:"description"`
	TargetEdge            string  `yaml:"target_edge"`
	Phases                []Phase `yaml:"phases"`
	AutoDeployEventTroops *bool   `yaml:"auto_deploy_eventTroops"` // Auto-deploy event troops not in strategy. nil = enabled (default).
	// EndAtPercent ends the battle automatically once the destruction
	// percentage reaches this value (0 = disabled, the default). Useful
	// for armies that secure the win early (e.g. Valkyrie spam at 50%)
	// and should not wait out the full stall timer.
	EndAtPercent int `yaml:"end_at_percent"`

	// StallTimerSeconds optionally overrides the battle stall timer in seconds.
	// 0 disables the stall timer for this strategy. If omitted (nil), falls
	// back to the global AttackConfig.StallTimerSeconds.
	StallTimerSeconds *int `yaml:"stall_timer_seconds,omitempty"`

	// ArmySlot is the saved-army recipe to arm before attacking
	// (1-based, default 1). Each saved recipe holds a different
	// composition, so a strategy must declare which recipe its unit
	// phases expect — e.g. valk_spam.yaml targets the 4th saved recipe.
	// 0 means the same as 1 (first recipe).
	ArmySlot int `yaml:"army_slot"`

	// Loadout is what the player has to put in that recipe. Optional.
	Loadout *Loadout `yaml:"loadout,omitempty"`
}

func ParseYAML

func ParseYAML(path string) (*DynamicStrategy, error)

func (*DynamicStrategy) EventTroopsAutoDeployEnabled

func (s *DynamicStrategy) EventTroopsAutoDeployEnabled() bool

EventTroopsAutoDeployEnabled reports whether the strategy wants the end-of-attack event-troop dump. Defaults to TRUE when the YAML key is absent so every army auto-dumps bonus/seasonal troops on the bar; set `auto_deploy_eventTroops: false` to opt out.

func (*DynamicStrategy) SelectedArmySlot

func (s *DynamicStrategy) SelectedArmySlot() int

SelectedArmySlot returns the 1-based army recipe to arm, clamping the default to 1 when the YAML omits the key.

type Loadout added in v1.1.0

type Loadout struct {
	ArmyCamp      int           `yaml:"army_camp"`
	SpellCapacity int           `yaml:"spell_capacity"`
	SiegeCapacity int           `yaml:"siege_capacity"`
	Troops        []LoadoutUnit `yaml:"troops"`
	Spells        []LoadoutUnit `yaml:"spells"`
	Siege         []LoadoutUnit `yaml:"siege"`
}

Loadout is the army a player has to assemble in-game before this strategy can run, in the terms the army editor uses: camp space, spell space, siege space and the units that fill them. Optional: a strategy without a loadout still runs, the launch screen just cannot instruct the player.

type LoadoutUnit added in v1.1.0

type LoadoutUnit struct {
	Name  string `yaml:"name"`
	Count int    `yaml:"count"`
	// Slots is how much space one of these takes: camp space for a troop,
	// housing slots for a spell (Rage is 2) or for a siege machine. 0 means
	// "not stated", and the launch screen then only shows the count.
	Slots int `yaml:"slots"`
}

LoadoutUnit is one line of "what to train" — a troop, spell or siege name with the count the recipe must hold. It is display/config data for the launch screen; the bot still deploys from Phases, not from here.

type Phase

type Phase struct {
	Name             string `yaml:"name"`
	Units            []Unit `yaml:"units"`
	Pattern          string `yaml:"pattern"`  // "Line", "Point", "FourSides"
	Position         string `yaml:"position"` // "Center", "Left", "Right", "Full"
	Offset           int    `yaml:"offset"`
	DelayAfterMS     int    `yaml:"delay_after_ms"`
	Retry            int    `yaml:"retry"`              // Max retry attempts per unit (default: 3)
	VerifyBeforeNext bool   `yaml:"verify_before_next"` // Wait for slot empty before next phase
}

type Unit

type Unit struct {
	Name         string `yaml:"name"`
	Amount       string `yaml:"amount"`        // Can be "All" or a number
	Pattern      string `yaml:"pattern"`       // Optional: Override phase pattern (e.g., "Ability")
	FallbackSlot int    `yaml:"fallback_slot"` // Optional: Deterministic slot index (1-based)
	Offset       int    `yaml:"offset"`        // Optional: Per-unit inward offset

	// PhaseOffset is the phase-level Offset copied in by DeployPlanner at
	// plan time (never authored in YAML — hence "-"). Deployers read it
	// as the fallback when the unit's own Offset is unset, so a phase
	// pin like "offset: 130 # Deeper in for EQs" applies to every unit
	// in that phase without each unit having to repeat it.
	PhaseOffset int `yaml:"-"`
}

Jump to

Keyboard shortcuts

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