Skip to content

Latest commit

 

History

History
218 lines (123 loc) · 4.86 KB

Backend_GameLogic_CaptureZoneGenerator.CaptureZoneGenerator.md

File metadata and controls

218 lines (123 loc) · 4.86 KB

Class: CaptureZoneGenerator

Backend/GameLogic/CaptureZoneGenerator.CaptureZoneGenerator

Given a game start block and a zone change block interval, decide when to generate new Capture Zones.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new CaptureZoneGenerator(gameManager, gameStartBlock, changeInterval)

Parameters

Name Type
gameManager default
gameStartBlock number
changeInterval number

Properties

capturablePlanets

Private capturablePlanets: Set<LocationId>


changeInterval

Private changeInterval: number


gameManager

Private gameManager: default


generated$

Readonly generated$: Monomitter<CaptureZonesGeneratedEvent>


lastChangeBlock

Private lastChangeBlock: number


nextChangeBlock

Private nextChangeBlock: number


zones

Private zones: Set<CaptureZone>

Accessors

gameObjects

Private get gameObjects(): GameObjects

Returns

GameObjects

Methods

_generate

Private _generate(blockNumber): Promise<Set<CaptureZone>>

Parameters

Name Type
blockNumber number

Returns

Promise<Set<CaptureZone>>


generate

generate(blockNumber): Promise<void>

Call when a new block is received to check if generation is needed.

Parameters

Name Type Description
blockNumber number Current block number.

Returns

Promise<void>


getNextChangeBlock

getNextChangeBlock(): number

The next block that will trigger a Capture Zone generation.

Returns

number


getZones

getZones(): Set<CaptureZone>

Returns

Set<CaptureZone>


isInZone

isInZone(locationId): boolean

Is the given planet inside of a Capture Zone.

Parameters

Name Type
locationId LocationId

Returns

boolean


onNewChunk

Private onNewChunk(chunk): void

Parameters

Name Type
chunk Chunk

Returns

void


setNextGenerationBlock

Private setNextGenerationBlock(blockNumber): void

Parameters

Name Type
blockNumber number

Returns

void


updateCapturablePlanets

Private updateCapturablePlanets(): void

Returns

void