pattern

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 3 Imported by: 0 modules, 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

Overview

Package pattern holds the shapes an area skill covers.

A pattern is a primary cell plus a list of step chains leading away from it. The six hex directions have stable names, so a shape can be authored as "the primary and the cell above it" or "the primary and both cells deeper in" without the engine tracking facing.

⚠️ **The names are written in the ALLY's frame and a shape is walked in its CASTER's**, which is why every entry point takes the caster's side. The package used to say "an ally always faces east" and walk absolute steps for everybody, and the second half did not follow from the first: hex.Place puts the enemy half down under a 180 degree rotation, which maps up to down and right to left, so an enemy holding a shape called `pierce` spread it back towards the midline instead of through the formation, and `wedge_right` pointed at its own backline. The whole board stopped being its own mirror — measured on the shipped squads, a mirror match and its own reverse summed to 1119, 1153 and 1057 per mille where they must sum to 1000. → TODO.md ENG-012.

The walk is done in the caster's own frame by rotating into it and back out, rather than by naming a second set of directions: hex.Place is its own inverse, so conjugating the walk through it makes the two halves each other's reflection **by construction** rather than by a table somebody has to keep true.

Resolution drops any cell that falls off the board or onto the other half of the battlefield. A shape aimed at an enemy therefore never catches an ally, and a shape aimed at the edge of a formation covers fewer cells than one aimed at its middle. That is not an edge case to smooth over: it is the reason where a skill is aimed matters as much as which skill it is.

Index

Constants

View Source
const DirectionCount = int(LowerLeft) + 1

DirectionCount is the number of directions.

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	// MaxTargets is the most cells any shape may cover.
	MaxTargets int
	// SplashPower is the share of a skill's power a splash cell takes, in parts
	// per thousand. The primary always takes the full amount.
	SplashPower int
	// contains filtered or unexported fields
}

Book is a named collection of shapes plus the design limits they obey.

func ParseBook

func ParseBook(raw []byte) (*Book, error)

ParseBook reads a shape declaration. It never touches the filesystem.

func (*Book) Lookup

func (b *Book) Lookup(name string) (Pattern, error)

Lookup returns a shape by name.

func (*Book) Patterns

func (b *Book) Patterns() []Pattern

Patterns returns every shape in declaration order.

func (*Book) Power

func (b *Book) Power(index int) int

Power returns the share of a skill's power a cell takes: the full amount for the primary, the book's splash share for anything else.

type Direction

type Direction uint8

Direction is one of the six hex neighbours, named for the board's fixed orientation: columns run left to right and odd columns sit half a cell lower.

const (
	Up Direction = iota
	Down
	UpperRight
	LowerRight
	UpperLeft
	LowerLeft
)

func Directions

func Directions() []Direction

Directions returns every direction in declaration order.

func ParseDirection

func ParseDirection(name string) (Direction, error)

ParseDirection resolves a direction name as written in the data files.

func (Direction) Step

func (d Direction) Step() hex.Cube

Step returns the cube offset the direction moves by.

func (Direction) String

func (d Direction) String() string

func (Direction) Valid

func (d Direction) Valid() bool

Valid reports whether the value is a declared direction.

type Pattern

type Pattern struct {
	Name string
	// Splash holds one step chain per additional cell, each walked from the
	// primary. A chain of one step is a neighbour; a chain of two reaches past
	// it, which is how a shape can pierce into a formation rather than spread
	// across it.
	Splash [][]Direction
}

Pattern is one area shape: the primary cell plus a chain of steps for every splash cell.

func (Pattern) MaxTargets

func (p Pattern) MaxTargets() int

MaxTargets is how many cells the shape covers when nothing is dropped.

func (Pattern) Targets

func (p Pattern) Targets(primary hex.Offset, caster hex.Side) []hex.Offset

Targets returns the cells the shape covers when aimed at a primary, primary first. Cells off the board, cells on the other half of the battlefield, and duplicates are dropped, so the result can be shorter than MaxTargets.

caster is the side holding the skill, and it is the frame the steps are read in — not the side the primary belongs to. A shape spreads away from whoever cast it. → the package doc, on why that is a parameter rather than an assumption.

func (Pattern) TargetsAcross

func (p Pattern) TargetsAcross(primary hex.Offset, caster hex.Side) []hex.Offset

TargetsAcross is Targets for a skill aimed at both halves of the battlefield: the same shape, with the midline no longer stopping it.

It is a second entry point rather than a parameter on the first because the midline is the right bound for every skill that aims at one side, so the plain call has to stay the one that reads as ordinary. Both go through one walk, so there is no second copy of the geometry — only a second answer to the one question the two differ on. Which of them a caster gets is skill.Side's CrossesSides, not a decision made here: this package knows what a side is and nothing about what a skill aims at.

func (Pattern) Validate

func (p Pattern) Validate(maxTargets int) error

Validate rejects a shape that cannot be resolved or that covers more cells than the design allows.

Jump to

Keyboard shortcuts

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