battles

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Battle

type Battle struct {
	ID                  uuid.UUID              `json:"id"`
	WikiID              int                    `json:"wikiID"`
	URL                 string                 `json:"url"`
	Name                string                 `json:"name"`
	PartOf              string                 `json:"partOf"`
	Summary             string                 `json:"summary"`
	StartDate           dates.Historic         `json:"startDate"`
	EndDate             dates.Historic         `json:"endDate"`
	Location            locations.Location     `json:"location"`
	Result              string                 `json:"result"`
	TerritorialChanges  string                 `json:"territorialChanges"`
	Strength            statistics.SideNumbers `json:"strength"`
	Casualties          statistics.SideNumbers `json:"casualties"`
	Factions            FactionsBySide         `json:"factions"`
	Commanders          CommandersBySide       `json:"commanders"`
	CommandersByFaction CommandersByFaction    `json:"commandersByFaction"`
}

Battle represents an armed encounter between two or more commanders belonging to different factions that occurred at some point, somewhere in history

type CommandersByFaction

type CommandersByFaction map[uuid.UUID][]uuid.UUID

CommandersByFaction is a map that indexes the IDs of commanders according to the faction to which they belong during a specific battle

type CommandersBySide

type CommandersBySide struct {
	A []commanders.Commander `json:"a"`
	B []commanders.Commander `json:"b"`
}

CommandersBySide groups all of the commanders that participated in a battle into the two opposing sides. These sides are A and B

type CreationInput

type CreationInput struct {
	WikiID              int    `validate:"required"`
	URL                 string `validate:"required,url"`
	Name                string `validate:"required"`
	PartOf              string
	Summary             string         `validate:"required"`
	StartDate           dates.Historic `validate:"required"`
	EndDate             dates.Historic `validate:"required"`
	Location            locations.Location
	Result              string `validate:"required"`
	TerritorialChanges  string
	Strength            statistics.SideNumbers
	Casualties          statistics.SideNumbers
	FactionsBySide      IDsBySide
	CommandersBySide    IDsBySide
	CommandersByFaction CommandersByFaction
}

CreationInput is a struct that contains all of the data required to create a battle. This includes annotations required by validations

type FactionsBySide

type FactionsBySide struct {
	A []factions.Faction `json:"a"`
	B []factions.Faction `json:"b"`
}

FactionsBySide groups all of the factions that participated in a battle into the two opposing sides. These sides are A and B

type FindManyQuery

type FindManyQuery struct {
	FactionID   uuid.UUID
	CommanderID uuid.UUID
	Name        string
	Summary     string
	Place       string
	Result      string
	FromDate    dates.Historic
	ToDate      dates.Historic
}

FindManyQuery is used to refine the filters when finding many battles

type FindOneQuery

type FindOneQuery struct {
	ID   uuid.UUID
	Name string
	URL  string
}

FindOneQuery is used to refine the filters when finding one battle

type IDsBySide

type IDsBySide struct {
	A []uuid.UUID `json:"a"`
	B []uuid.UUID `json:"b"`
}

IDsBySide groups the IDs of the factions or commanders that participated in a battle into the two opposing sides. These sides are A and B

type Reader

type Reader interface {
	FindOne(query FindOneQuery) (Battle, error)
	FindMany(query FindManyQuery, page int) ([]Battle, int, error)
}

Reader is the interface through which battles may be read

type Repository

type Repository interface {
	Reader
	Writer
}

Repository is the interface through which battles may be read and written

type Writer

type Writer interface {
	CreateOne(data CreationInput) (uuid.UUID, error)
}

Writer is the interface through which battles may be written

Jump to

Keyboard shortcuts

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