Galaxy
in package
Table of Contents
Constants
- SQL = 'game_id = :game_id AND galaxy_id = :galaxy_id'
- TYPE_NEUTRAL = 'Neutral'
- TYPE_PLANET = 'Planet'
- TYPE_RACIAL = 'Racial'
- TYPES = [self::TYPE_RACIAL, self::TYPE_NEUTRAL, self::TYPE_PLANET]
Properties
- $SQLID : array{game_id: int, galaxy_id: int}
- $CACHE_GALAXIES : array<int, array<int, self>>
- $CACHE_GAME_GALAXIES : array<int, array<int, self>>
- $galaxyID : int
- $galaxyType : string
- $gameID : int
- $hasChanged : bool
- $height : int
- $isNew : bool
- $maxForceTime : int
- $name : string
- $startSector : int
- $width : int
Methods
- clearCache() : void
- contains() : bool
- Check if the galaxy contains a specific sector.
- createGalaxy() : self
- equals() : bool
- generateSectors() : void
- getConnectivity() : float
- Returns the sector connectivity of the galaxy as a percent.
- getDisplayName() : string
- Returns the galaxy name, suitable for HTML display.
- getEndSector() : int
- getForces() : array<int, array<int, Force>>
- getGalaxy() : self
- getGalaxyContaining() : self
- getGalaxyID() : int
- getGalaxyMapHREF() : string
- getGalaxyType() : string
- getGameGalaxies() : array<int, self>
- getGameID() : int
- getHeight() : int
- getLocations() : array<int, array<int, Location>>
- getMapSectors() : array<int, array<int, Sector>>
- Returns a 2D array of sectors in the galaxy.
- getMaxForceTime() : int
- getName() : string
- Returns the galaxy name.
- getPlanets() : array<int, Planet>
- getPlayers() : array<int, array<int, Player>>
- getPorts() : array<int, Port>
- getSectors() : array<int, Sector>
- getSize() : int
- getStartSector() : int
- getWidth() : int
- save() : void
- saveGalaxies() : void
- setConnectivity() : bool
- Randomly set the connections between all galaxy sectors.
- setGalaxyType() : void
- setHeight() : void
- setMaxForceTime() : void
- setName() : void
- setWidth() : void
- __construct() : mixed
Constants
SQL
public
mixed
SQL
= 'game_id = :game_id AND galaxy_id = :galaxy_id'
TYPE_NEUTRAL
public
mixed
TYPE_NEUTRAL
= 'Neutral'
TYPE_PLANET
public
mixed
TYPE_PLANET
= 'Planet'
TYPE_RACIAL
public
mixed
TYPE_RACIAL
= 'Racial'
TYPES
public
mixed
TYPES
= [self::TYPE_RACIAL, self::TYPE_NEUTRAL, self::TYPE_PLANET]
Properties
$SQLID read-only
public
array{game_id: int, galaxy_id: int}
$SQLID
$CACHE_GALAXIES
protected
static array<int, array<int, self>>
$CACHE_GALAXIES
= []
$CACHE_GAME_GALAXIES
protected
static array<int, array<int, self>>
$CACHE_GAME_GALAXIES
= []
$galaxyID read-only
protected
int
$galaxyID
$galaxyType
protected
string
$galaxyType
$gameID read-only
protected
int
$gameID
$hasChanged
protected
bool
$hasChanged
= false
$height
protected
int
$height
$isNew
protected
bool
$isNew
= true
$maxForceTime
protected
int
$maxForceTime
$name
protected
string
$name
$startSector
protected
int
$startSector
$width
protected
int
$width
Methods
clearCache()
public
static clearCache() : void
contains()
Check if the galaxy contains a specific sector.
public
contains(int|Sector $sectorID) : bool
Parameters
- $sectorID : int|Sector
Return values
boolcreateGalaxy()
public
static createGalaxy(int $gameID, int $galaxyID) : self
Parameters
- $gameID : int
- $galaxyID : int
Return values
selfequals()
public
equals(Galaxy $otherGalaxy) : bool
Parameters
- $otherGalaxy : Galaxy
Return values
boolgenerateSectors()
public
generateSectors() : void
getConnectivity()
Returns the sector connectivity of the galaxy as a percent.
public
getConnectivity() : float
Return values
floatgetDisplayName()
Returns the galaxy name, suitable for HTML display.
public
getDisplayName() : string
Return values
stringgetEndSector()
public
getEndSector() : int
Return values
intgetForces()
public
getForces() : array<int, array<int, Force>>
Return values
array<int, array<int, Force>>getGalaxy()
public
static getGalaxy(int $gameID, int $galaxyID[, bool $forceUpdate = false ][, DatabaseRecord|null $dbRecord = null ]) : self
Parameters
- $gameID : int
- $galaxyID : int
- $forceUpdate : bool = false
- $dbRecord : DatabaseRecord|null = null
Return values
selfgetGalaxyContaining()
public
static getGalaxyContaining(int $gameID, int $sectorID) : self
Parameters
- $gameID : int
- $sectorID : int
Return values
selfgetGalaxyID()
public
getGalaxyID() : int
Return values
intgetGalaxyMapHREF()
public
getGalaxyMapHREF() : string
Return values
stringgetGalaxyType()
public
getGalaxyType() : string
Return values
stringgetGameGalaxies()
public
static getGameGalaxies(int $gameID[, bool $forceUpdate = false ]) : array<int, self>
Parameters
- $gameID : int
- $forceUpdate : bool = false
Return values
array<int, self>getGameID()
public
getGameID() : int
Return values
intgetHeight()
public
getHeight() : int
Return values
intgetLocations()
public
getLocations() : array<int, array<int, Location>>
Return values
array<int, array<int, Location>>getMapSectors()
Returns a 2D array of sectors in the galaxy.
public
getMapSectors([int|null $centerSectorID = null ][, int|null $dist = null ]) : array<int, array<int, Sector>>
If $centerSectorID is specified, it will be in the center of the array. If $dist is also specified, only include sectors $dist away from center.
NOTE: This routine queries sectors inefficiently. You may want to construct the cache efficiently before calling this.
Parameters
- $centerSectorID : int|null = null
- $dist : int|null = null
Return values
array<int, array<int, Sector>>getMaxForceTime()
public
getMaxForceTime() : int
Return values
intgetName()
Returns the galaxy name.
public
getName() : string
Use getDisplayName for an HTML-safe version.
Return values
stringgetPlanets()
public
getPlanets() : array<int, Planet>
Return values
array<int, Planet>getPlayers()
public
getPlayers() : array<int, array<int, Player>>
Return values
array<int, array<int, Player>>getPorts()
public
getPorts() : array<int, Port>
Return values
array<int, Port>getSectors()
public
getSectors() : array<int, Sector>
Return values
array<int, Sector>getSize()
public
getSize() : int
Return values
intgetStartSector()
public
getStartSector() : int
Return values
intgetWidth()
public
getWidth() : int
Return values
intsave()
public
save() : void
saveGalaxies()
public
static saveGalaxies() : void
setConnectivity()
Randomly set the connections between all galaxy sectors.
public
setConnectivity(float $connectivity) : bool
$connectivity = (average) percent of connections to enable.
Parameters
- $connectivity : float
Return values
boolsetGalaxyType()
public
setGalaxyType(string $galaxyType) : void
Parameters
- $galaxyType : string
setHeight()
public
setHeight(int $height) : void
Parameters
- $height : int
setMaxForceTime()
public
setMaxForceTime(int $maxForceTime) : void
Parameters
- $maxForceTime : int
setName()
public
setName(string $name) : void
Parameters
- $name : string
setWidth()
public
setWidth(int $width) : void
Parameters
- $width : int
__construct()
protected
__construct(int $gameID, int $galaxyID[, bool $create = false ][, DatabaseRecord|null $dbRecord = null ]) : mixed
Parameters
- $gameID : int
- $galaxyID : int
- $create : bool = false
- $dbRecord : DatabaseRecord|null = null