placement

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: 7 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 placement is what a character becomes when somebody fields it.

A character is a **definition** — a curve, a learnset, an evolution line — and a placement is a decision made about one: which level, which form, which four of the skills it knows, which trait, and where it stands. The two are kept apart so that one character can stand in a dozen encounters at a dozen levels without being written down a dozen times.

A Squad is a named list of placements, one side's worth. It has no side of its own: the same squad can be fielded as either half of a battle, which is what lets one be measured against several opponents, and against itself.

The package is pure. It parses bytes handed to it and never touches the filesystem — internal/seed hands it the copy go:embed baked in, and internal/forge hands it the file an author is editing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(squads []Squad) ([]byte, error)

Marshal writes squads back in the shape Parse reads.

Types

type Placement

type Placement struct {
	// ID is what this unit is called in a log, and it is unique within a squad
	// rather than globally: the side is prefixed when the squad takes the field,
	// so a squad fought against a copy of itself still has two distinguishable
	// halves.
	ID string `json:"id"`
	// Character names an entry in the cast book. A placement is always a
	// reference — the flat form, where a stat line is written out in place,
	// belongs to the seed roster and to the engine's own fixtures.
	Character string `json:"character"`
	Level     int    `json:"level"`
	// Stage is the form this placement fielded, and it is a *choice*: a level
	// allows a form rather than dictating one. Absent means the furthest the
	// level reaches, which is what a placement meant before it could choose —
	// and on a line that forks there is no such thing, so one has to be named.
	Stage string `json:"stage,omitempty"`
	// Slot is the cell in this side's own 3x3 formation, authored from that
	// side's point of view. hex.Place maps it onto the shared board.
	Slot     hex.Offset `json:"slot"`
	Skills   []string   `json:"skills"`
	Passives []string   `json:"passives,omitempty"`
}

Placement is one unit as it takes the field.

func (Placement) Clone

func (p Placement) Clone() Placement

Clone is a deep copy of one placement.

func (Placement) Equal

func (p Placement) Equal(other Placement) bool

Equal reports whether two placements field the same unit the same way.

A nil list and an empty one are one answer here, which is what slices.Equal says: having chosen nothing and having chosen nothing yet are the same squad on the field, and Take refuses both for the same reason.

type Squad

type Squad struct {
	ID    string      `json:"id"`
	Name  string      `json:"name,omitempty"`
	Units []Placement `json:"units"`
}

Squad is one side's worth of placements under a name.

func Parse

func Parse(raw []byte) ([]Squad, error)

Parse reads a squad declaration and checks everything that can be checked without a cast book: the ids, the sizes, and the slots.

The cast book is what turns a squad into units, and Take is where that happens. Splitting the two is what lets an authoring tool hold a squad that does not resolve yet — a unit half-chosen is a normal state to be in while building one, and a parser that refused it would make the file unwritable until it was finished.

func (Squad) Clone

func (s Squad) Clone() Squad

Clone is a deep copy, so a builder editing a squad cannot reach through a shared slice into whatever is holding the saved one.

func (Squad) Equal

func (s Squad) Equal(other Squad) bool

Equal reports whether two squads are the same squad: every field of the squad and of every member, in the order the members are written down.

Order is part of the answer rather than an artefact of how it is computed. A kit's order is the kit, and a squad's order is what the turn queue breaks a tie by, so two squads holding the same names in a different order are two different squads and a comparison that sorted first would call them one.

It lives beside Clone because both answer the same question — what a squad is made of. A caller that wrote its own comparison would be a second declaration of that list, and the copy is the one that goes stale the day a field is added, silently: a missed field compares equal and the difference is thrown away with nobody asked about it.

func (Squad) Take

func (s Squad) Take(side hex.Side, characters *cast.Book) ([]battle.Roster, error)

Take resolves the squad into the engine's shape, as one side of a battle.

The side is a parameter rather than a field because a squad is not written down as somebody's enemy: the same one is fielded as either half, which is what lets it be measured against several opponents — and against a copy of itself, which is why the ids come back prefixed with the side. Two halves of a mirror have to be told apart in a log, and nothing else in a squad can do it.

func (Squad) Validate

func (s Squad) Validate() error

Validate is everything about a squad that does not need the cast book.

⚠️ It deliberately does **not** ask whether a unit has chosen its four skills. A squad being built has units in every state of half-finished, and a file that refused to hold one could not be saved and come back to. What refuses an unfinished unit is Take, at the moment the squad is asked to fight.

Jump to

Keyboard shortcuts

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