package player

Package player names the players of a map: the twelve colours, the two neutral owners and "everyone". A player is a number to the game, but a script never writes the number: it says player.Red, player.NeutralAggressive or player.Everyone.

A variable of your own may be called player: inside its scope it hides this package, which only matters if you need player.Red there too.

import "w4/player"

Types

ID

type ID int

ID is one player, a neutral owner, or Everyone. It is what Unit.Owner returns and what the calls that spawn units or show something to players take.

const (
	Red ID = iota + 1
	Blue
	Teal
	Purple
	Yellow
	Orange
	Green
	Pink
	Gray
	LightBlue
	DarkGreen
	Brown
)

The players 1 to 12, in the order of the editor's Players module. A map can rename them, the numbers stay.

const (
	// Neutral owns what takes no side: shops, critters, scenery. It never attacks and is never
	// attacked.
	Neutral ID = 0
	// NeutralAggressive owns the creeps: an enemy of every player, who attacks them on sight.
	NeutralAggressive ID = -1
	// Everyone is not an owner. It is for calls that show something to players: an interface
	// element or a floating text for Everyone is shown to all of them. Giving it to
	// game.SpawnUnit spawns nothing.
	Everyone ID = -2
)

ID.CanOwn

func (p ID) CanOwn() bool

CanOwn is whether p can own a unit: one of the twelve players or a neutral owner.

ID.IsPlayer

func (p ID) IsPlayer() bool

IsPlayer is whether p is one of the twelve players, as opposed to a neutral owner or Everyone.

ID.String

func (p ID) String() string

String is the player's colour name, or Neutral, Neutral Aggressive or Everyone.