stmm-games-doc  0.32.0
Classes | Public Member Functions | Protected Member Functions | List of all members
stmg::Level Class Reference

The level is the container for board, events and blocks. More...

Classes

struct  Init
 
class  LevelBlockCreator
 Factory interface for level blocks. More...
 

Public Member Functions

 Level (Game *p0Game, int32_t nLevel, const shared_ptr< AppPreferences > &refPreferences, const Init &oInit) noexcept
 Construct level instance. More...
 
void addEvent (unique_ptr< Event > refEvent) noexcept
 Adds an event to the level (deactivated). More...
 
void addEvent (const std::string &sId, unique_ptr< Event > refEvent) noexcept
 Adds an event (identifiable by a string id) to the level (deactivated). More...
 
bool hasEvent (Event const *p0Event) const noexcept
 Tells whether the event was added to the level. More...
 
EventgetEventById (const std::string &sId) noexcept
 Get an event by id. More...
 
const AppPreferencesprefs () const noexcept
 The preferences. More...
 
GameProxygame () noexcept
 The game proxy. More...
 
const GameProxygame () const noexcept
 The game proxy. More...
 
int32_t getLevel () const noexcept
 The level identifier within the game. More...
 
int32_t getTotLevelPlayers () const noexcept
 The number of players in the level. More...
 
int32_t getTotLevelTeams () const noexcept
 The number of teams in the level. More...
 
const std::vector< std::pair< int32_t, int32_t > > & getActiveHumanPlayers () noexcept
 The currently active human players. More...
 
LevelShowshowGet () noexcept
 The level show of the level. More...
 
bool subshowMode () const noexcept
 Whether each level player has a subshow. More...
 
LevelShowsubshowGet (int32_t nLevelTeam, int32_t nMate) noexcept
 The subshow of a level player. More...
 
LevelShowsubshowGet (int32_t nLevelPlayer) noexcept
 The subshow of a level player. More...
 
int32_t getNrTileAniAttrs () const noexcept
 The number of tile animations for both brick and board cell tiles. More...
 
bool boabloUnfreeze (const Coords &oCoords, LevelBlockCreator &oCreator, LevelBlock::MGMT_TYPE eMgmtType) noexcept
 Creates a block from the board. More...
 
bool blockAdd (LevelBlock *p0LevelBlock, LevelBlock::MGMT_TYPE eMgmtType) noexcept
 Adds a level block to the level. More...
 
void blockCycleControl (int32_t nPlayer) noexcept
 
void blockCycleControl (int32_t nPlayer, LevelBlock *p0Preferred) noexcept
 
void blockCycleControl (LevelBlock *p0LevelBlock) noexcept
 
void blockCycleControl (LevelBlock *p0LevelBlock, LevelBlock *p0Preferred) noexcept
 Gives the player control of another level block. More...
 
void blockSetControllable (LevelBlock *p0LevelBlock, bool bPlayerControllable, int32_t nControllerTeam) noexcept
 Set the controllability of a level block. More...
 
bool blockCanPlaceOnBoard (const LevelBlock &oLevelBlock, bool bStrict) const noexcept
 Tells whether block can be placed on board. More...
 
void boabloOwnerBlockSet (LevelBlock &oLevelBlock) noexcept
 Sets the owner of the cells occupied by the block's visible bricks of its current shape. More...
 
void boabloOwnerBlockClear (LevelBlock &oLevelBlock) noexcept
 Clears the owner of the cells occupied by the block's visible bricks of its current shape. More...
 
bool blockIntersectsArea (const LevelBlock &oLevelBlock, int32_t nX, int32_t nY, int32_t nW, int32_t nH) const noexcept
 Whether any of the block's visible bricks of its current shape are within a rectangle. More...
 
bool blockIntersectsArea (const LevelBlock &oLevelBlock, NRect oArea) const noexcept
 Whether any of the block's visible bricks of its current shape are within a rectangle. More...
 
bool blockMoveIsWithinArea (const LevelBlock &oLevelBlock, int32_t nMoveX, int32_t nMoveY, int32_t nX, int32_t nY, int32_t nW, int32_t nH) const noexcept
 Whether all of the the block's visible bricks of its current shape are within a rectangle after a move. More...
 
bool blockMoveIsWithinArea (const LevelBlock &oLevelBlock, int32_t nMoveX, int32_t nMoveY, NRect oArea) const noexcept
 Whether all of the the block's visible bricks of its current shape are within a rectangle after a move. More...
 
void blocksAddListener (BlocksListener *p0Listener) noexcept
 Adds a a blocks listener. More...
 
void blocksRemoveListener (BlocksListener *p0Listener) noexcept
 Removes a a blocks listener. More...
 
void blocksAddBricksIdListener (BlocksBricksIdListener *p0Listener) noexcept
 Adds a block's bricks change listener. More...
 
void blocksRemoveBricksIdListener (BlocksBricksIdListener *p0Listener) noexcept
 Removes a block's bricks change listener. More...
 
void blocksAddPlayerChangeListener (BlocksPlayerChangeListener *p0Listener) noexcept
 Adds a block's player change listener. More...
 
void blocksRemovePlayerChangeListener (BlocksPlayerChangeListener *p0Listener) noexcept
 Removes a block's player change listener. More...
 
LevelBlockblocksGet (int32_t nId) noexcept
 Get the level block by id. More...
 
std::vector< int32_t > blocksGetAllIds () noexcept
 All the ids if the active level blocks. More...
 
std::vector< LevelBlock * > blocksGetAll () noexcept
 All the active level blocks. More...
 
bool othersAddListener (Event *p0OthersListener) noexcept
 Add a listener to events from other levels. More...
 
bool othersRemoveListener (Event *p0OthersListener) noexcept
 Removes a listener to events from other levels. More...
 
int32_t boardWidth () const noexcept
 The width of the board in tiles. More...
 
int32_t boardHeight () const noexcept
 The height of the board in tiles. More...
 
NSize boardSize () const noexcept
 The size of the board in tiles. More...
 
void boardSetTile (int32_t nX, int32_t nY, const Tile &oTile) noexcept
 Sets the tile of a board cell. More...
 
void boardSetTile (NPoint oXY, const Tile &oTile) noexcept
 Sets the tile of a board cell. More...
 
const TileboardGetTile (int32_t nX, int32_t nY) const noexcept
 Returns the tile of a board cell. More...
 
const TileboardGetTile (NPoint oXY) const noexcept
 Returns the tile of a board cell. More...
 
void boardSetOwner (int32_t nX, int32_t nY, LevelBlock *p0LevelBlock) noexcept
 Sets the level block owner of a board's cell. More...
 
void boardSetOwner (NPoint oXY, LevelBlock *p0LevelBlock) noexcept
 Sets the level block owner of a board's cell. More...
 
LevelBlockboardGetOwner (int32_t nX, int32_t nY) const noexcept
 Returns the level block owner of a board cell. More...
 
LevelBlockboardGetOwner (NPoint oXY) const noexcept
 Returns the level block owner of a board cell. More...
 
double boardGetTileAniElapsed (int32_t nX, int32_t nY, int32_t nIdxTileAni, int32_t nViewTick=0, int32_t nTotViewTicks=1) const noexcept
 Get the elapsed unary time of a certain tile animation of a cell. More...
 
double boardGetTileAniElapsed (NPoint oXY, int32_t nIdxTileAni, int32_t nViewTick=0, int32_t nTotViewTicks=1) const noexcept
 Get the elapsed unary time of a certain tile animation of a cell. More...
 
void boardSetTileAnimator (int32_t nX, int32_t nY, int32_t nIdxTileAni, TileAnimator *p0TileAnimator, int32_t nHash) noexcept
 Set the tile animator of a cell for a certain tile animation. More...
 
void boardSetTileAnimator (NPoint oXY, int32_t nIdxTileAni, TileAnimator *p0TileAnimator, int32_t nHash) noexcept
 Set the tile animator of a cell for a certain tile animation. More...
 
const TileAnimatorboardGetTileAnimator (int32_t nX, int32_t nY, int32_t nIdxTileAni) const noexcept
 Returns the TileAnimator for a certain tile animation. More...
 
const TileAnimatorboardGetTileAnimator (NPoint oXY, int32_t nIdxTileAni) const noexcept
 Returns the TileAnimator for a certain tile animation. More...
 
void boardScrollAddListener (BoardScrollListener *p0Listener) noexcept
 Adds a listener to board scrolls. More...
 
void boardScrollRemoveListener (BoardScrollListener *p0Listener) noexcept
 Removes a listener to board scrolls. More...
 
void boardAddListener (BoardListener *p0Listener) noexcept
 Adds a listener to board modifications. More...
 
void boardRemoveListener (BoardListener *p0Listener) noexcept
 Removes a listener to board modifications. More...
 
void boardScroll (Direction::VALUE eDir, const shared_ptr< TileRect > &refTiles) noexcept
 Scrolls the board contents in a certain direction. More...
 
void boardInsert (Direction::VALUE eDir, NRect oArea, const shared_ptr< TileRect > &refTiles) noexcept
 Inserts a row or column in a rectangle area. More...
 
void boardModify (const TileCoords &oTileCoords) noexcept
 Modify the cells of given area. More...
 
void boardDestroy (const Coords &oCoords) noexcept
 Destroy single tiles of the board. More...
 
const Variablevariable (int32_t nId, int32_t nLevelTeam, int32_t nMate) const noexcept
 Get existing variable. More...
 
Variablevariable (int32_t nId, int32_t nLevelTeam, int32_t nMate) noexcept
 Get existing variable. More...
 
shared_ptr< GameWidgetwidgetsGet (const std::string &sWidgetName, int32_t nLevelTeam, int32_t nMate) noexcept
 Get a named widget. More...
 
void animationAdd (const shared_ptr< LevelAnimation > &refLevelAnimation, LevelAnimation::REFSYS eRefSys, double fDelayMillisec) noexcept
 Adds a level animation. More...
 
void animationAdd (const shared_ptr< LevelAnimation > &refLevelAnimation, LevelAnimation::REFSYS eRefSys) noexcept
 Shortcut for animationAdd(refLevelAnimation, eRefSys, 0.0). More...
 
void animationAddScrolled (const shared_ptr< LevelAnimation > &refLevelAnimation, double fDelayMillisec) noexcept
 Adds a scrolled level animation. More...
 
void animationAddScrolled (const shared_ptr< LevelAnimation > &refLevelAnimation) noexcept
 Shortcut for animationAddScrolled(refLevelAnimation, 0.0). More...
 
void animationRemove (const shared_ptr< LevelAnimation > &refLevelAnimation) noexcept
 Remove a level animation. More...
 
void boardAnimateTiles (NRect oArea) noexcept
 Tells the view it should animate the tiles of an area. More...
 
void boardAnimateTile (NPoint oXY) noexcept
 Tells the view it should animate a tile. More...
 
void activateEvent (Event *p0Event, int32_t nStart) noexcept
 Activate event. More...
 
void deactivateEvent (Event *p0Event) noexcept
 Deactivate event. More...
 
void triggerEvent (Event *p0Event, int32_t nMsg, int32_t nValue, Event *p0TriggeringEvent) noexcept
 Calls the trigger function of an event. More...
 
int32_t getFallEachTicks () noexcept
 Gets the fall rate of level blocks for this level. More...
 
void setFallEachTicks (int32_t nFallEachTicks) noexcept
 Sets the fall rate of level blocks for this level. More...
 
double getInterval () noexcept
 Get the requested interval for the level. More...
 
void setInterval (double fMillisec) noexcept
 Set the requested game interval for the level. More...
 
bool gameStatusPlayerOut (int32_t nLevelTeam, int32_t nMate, bool bForceOtherCompleted, bool bCreateTexts) noexcept
 Declare player dead. More...
 
bool gameStatusCompleted (int32_t nLevelTeam, bool bForceOthersFailed, bool bCreateTexts) noexcept
 Declare team completed the game. More...
 
bool gameStatusFailed (int32_t nLevelTeam, bool bForceOtherCompleted, bool bCreateTexts) noexcept
 Declare team failed the game. More...
 
void gameStatusTechnical (const std::vector< std::string > &aIssue) noexcept
 Technical game over. More...
 
NamedgetNamed () noexcept
 
const NamedgetNamed () const noexcept
 
int32_t gameElapsed () const noexcept
 The elapsed time since the game start in intervals. More...
 
void dump (bool bDumpBoard, bool bDumpLevelBlocks, bool bDumpTileAni, bool bDumpCharNames, bool bDumpColorNames, bool bDumpFontNames) const noexcept
 

Protected Member Functions

void reInit (Game *p0Game, int32_t nLevel, const shared_ptr< AppPreferences > &refPreferences, const Init &oInit) noexcept
 Reinitializes the level instance. More...
 
void gameStart () noexcept
 Signals the start of the game. More...
 
std::vector< unique_ptr< Event > > extractAllEvents () noexcept
 Extracts all events from the level. More...
 
void setLevelView (LevelView *p0View) noexcept
 Set the level view. More...
 

Detailed Description

The level is the container for board, events and blocks.

Constructor & Destructor Documentation

◆ Level()

stmg::Level::Level ( Game p0Game,
int32_t  nLevel,
const shared_ptr< AppPreferences > &  refPreferences,
const Init oInit 
)
noexcept

Construct level instance.

Parameters
p0GameThe game. Cannot be null.
nLevelThe number to identify the level within the game.
refPreferencesThe preferences. Cannot be null.
oInitInitialization data.

Member Function Documentation

◆ activateEvent()

void stmg::Level::activateEvent ( Event p0Event,
int32_t  nStart 
)
noexcept

Activate event.

If nStart is smaller than the current game tick (see Game::gameElapsed() function), the event is started in the current game tick. This is a way to trigger an event before events with higher priority.

Parameters
p0EventThe event. Cannot be null.
nStartThe triggering time in game ticks. Must be >= 0.

◆ addEvent() [1/2]

void stmg::Level::addEvent ( unique_ptr< Event refEvent)
noexcept

Adds an event to the level (deactivated).

Parameters
refEventThe event. Cannot be null.

◆ addEvent() [2/2]

void stmg::Level::addEvent ( const std::string &  sId,
unique_ptr< Event refEvent 
)
noexcept

Adds an event (identifiable by a string id) to the level (deactivated).

Parameters
sIdThe event id. If empty or name is already present the event is unnamed.
refEventThe event. Cannot be null.

◆ animationAdd() [1/2]

void stmg::Level::animationAdd ( const shared_ptr< LevelAnimation > &  refLevelAnimation,
LevelAnimation::REFSYS  eRefSys,
double  fDelayMillisec 
)
noexcept

Adds a level animation.

If present this function calls the view's animationCreate.

Parameters
refLevelAnimationThe animation. Cannot be null.
eRefSysThe reference system.
fDelayMillisecThe delay in milliseconds. Must be >= 0.

◆ animationAdd() [2/2]

void stmg::Level::animationAdd ( const shared_ptr< LevelAnimation > &  refLevelAnimation,
LevelAnimation::REFSYS  eRefSys 
)
inlinenoexcept

Shortcut for animationAdd(refLevelAnimation, eRefSys, 0.0).

◆ animationAddScrolled() [1/2]

void stmg::Level::animationAddScrolled ( const shared_ptr< LevelAnimation > &  refLevelAnimation,
double  fDelayMillisec 
)
noexcept

Adds a scrolled level animation.

If present this function calls the view's animationCreate.

Parameters
refLevelAnimationThe animation. Cannot be null.
fDelayMillisecThe delay in milliseconds. Must be >= 0.

◆ animationAddScrolled() [2/2]

void stmg::Level::animationAddScrolled ( const shared_ptr< LevelAnimation > &  refLevelAnimation)
inlinenoexcept

Shortcut for animationAddScrolled(refLevelAnimation, 0.0).

◆ animationRemove()

void stmg::Level::animationRemove ( const shared_ptr< LevelAnimation > &  refLevelAnimation)
noexcept

Remove a level animation.

If the animation (scrolled or not) was already removed this function does nothing.

Parameters
refLevelAnimationThe animation. Cannot be null.

◆ blockAdd()

bool stmg::Level::blockAdd ( LevelBlock p0LevelBlock,
LevelBlock::MGMT_TYPE  eMgmtType 
)
noexcept

Adds a level block to the level.

Whether the block could be added to the level depends on the eMgmtType and the current state of the board.

Parameters
p0LevelBlockThe level block. Cannot be null.
eMgmtTypeHow the level block is handled.
Returns
Whether the block could be added.

◆ blockCanPlaceOnBoard()

bool stmg::Level::blockCanPlaceOnBoard ( const LevelBlock oLevelBlock,
bool  bStrict 
) const
noexcept

Tells whether block can be placed on board.

Parameters
oLevelBlockThe level block.
bStrictWhether to ensure that the corresponding board cells are empty.
Returns
Whether the block could be placed.

◆ blockCycleControl() [1/4]

void stmg::Level::blockCycleControl ( int32_t  nPlayer)
noexcept

◆ blockCycleControl() [2/4]

void stmg::Level::blockCycleControl ( int32_t  nPlayer,
LevelBlock p0Preferred 
)
noexcept

◆ blockCycleControl() [3/4]

void stmg::Level::blockCycleControl ( LevelBlock p0LevelBlock)
noexcept

◆ blockCycleControl() [4/4]

void stmg::Level::blockCycleControl ( LevelBlock p0LevelBlock,
LevelBlock p0Preferred 
)
noexcept

Gives the player control of another level block.

If the level block is not controlled by a player or if there is no other level block the player can control this function does nothing.

If the preferred player is null or not available the next level block is usually the next in a chain of level blocks ordered by their x position.

Parameters
p0LevelBlockThe level block the player currently controls. Cannot be null.
p0PreferredThe preferred level block the player should control next. Can be null.

◆ blockIntersectsArea() [1/2]

bool stmg::Level::blockIntersectsArea ( const LevelBlock oLevelBlock,
int32_t  nX,
int32_t  nY,
int32_t  nW,
int32_t  nH 
) const
noexcept

Whether any of the block's visible bricks of its current shape are within a rectangle.

Parameters
oLevelBlockThe level block.
nXThe x of the rectangle (in tiles).
nYThe y of the rectangle (in tiles).
nWThe width of the rectangle (in tiles).
nHThe height of the rectangle (in tiles).
Returns
Whether block intersects with rectangle.

◆ blockIntersectsArea() [2/2]

bool stmg::Level::blockIntersectsArea ( const LevelBlock oLevelBlock,
NRect  oArea 
) const
inlinenoexcept

Whether any of the block's visible bricks of its current shape are within a rectangle.

Parameters
oLevelBlockThe level block.
oAreaThe rectangle (in tiles).
Returns
Whether block intersects with rectangle.

◆ blockMoveIsWithinArea() [1/2]

bool stmg::Level::blockMoveIsWithinArea ( const LevelBlock oLevelBlock,
int32_t  nMoveX,
int32_t  nMoveY,
int32_t  nX,
int32_t  nY,
int32_t  nW,
int32_t  nH 
) const
noexcept

Whether all of the the block's visible bricks of its current shape are within a rectangle after a move.

Parameters
oLevelBlockThe level block.
nMoveXThe move in the x axis (in tiles).
nMoveYThe move in the y axis (in tiles).
nXThe x of the rectangle (in tiles).
nYThe y of the rectangle (in tiles).
nWThe width of the rectangle (in tiles).
nHThe height of the rectangle (in tiles).
Returns
Whether block within rectangle after move.

◆ blockMoveIsWithinArea() [2/2]

bool stmg::Level::blockMoveIsWithinArea ( const LevelBlock oLevelBlock,
int32_t  nMoveX,
int32_t  nMoveY,
NRect  oArea 
) const
inlinenoexcept

Whether all of the the block's visible bricks of its current shape are within a rectangle after a move.

Parameters
oLevelBlockThe level block.
nMoveXThe move in the x axis (in tiles).
nMoveYThe move in the y axis (in tiles).
oAreaThe rectangle (in tiles).
Returns
Whether block within rectangle after move.

◆ blocksAddBricksIdListener()

void stmg::Level::blocksAddBricksIdListener ( BlocksBricksIdListener p0Listener)
noexcept

Adds a block's bricks change listener.

Parameters
p0ListenerThe listener. Cannot be null.

◆ blocksAddListener()

void stmg::Level::blocksAddListener ( BlocksListener p0Listener)
noexcept

Adds a a blocks listener.

Parameters
p0ListenerThe listener. Cannot be null.

◆ blocksAddPlayerChangeListener()

void stmg::Level::blocksAddPlayerChangeListener ( BlocksPlayerChangeListener p0Listener)
noexcept

Adds a block's player change listener.

Parameters
p0ListenerThe listener. Cannot be null.

◆ blockSetControllable()

void stmg::Level::blockSetControllable ( LevelBlock p0LevelBlock,
bool  bPlayerControllable,
int32_t  nControllerTeam 
)
noexcept

Set the controllability of a level block.

Parameters
p0LevelBlockThe level block. Cannot be null.
bPlayerControllableWhether players can control the level block.
nControllerTeamThe level team allowed to control the block or -1 if any.

◆ blocksGet()

LevelBlock* stmg::Level::blocksGet ( int32_t  nId)
noexcept

Get the level block by id.

Parameters
nIdThe id.
Returns
The level block or null if not active (was removed).

◆ blocksGetAll()

std::vector<LevelBlock*> stmg::Level::blocksGetAll ( )
noexcept

All the active level blocks.

This is supposed to be called once and then changes tracked by installing a BlocksListener.

Returns
The level blocks. Are all non null.

◆ blocksGetAllIds()

std::vector<int32_t> stmg::Level::blocksGetAllIds ( )
noexcept

All the ids if the active level blocks.

Returns
The ids.

◆ blocksRemoveBricksIdListener()

void stmg::Level::blocksRemoveBricksIdListener ( BlocksBricksIdListener p0Listener)
noexcept

Removes a block's bricks change listener.

Parameters
p0ListenerThe listener. Cannot be null.

◆ blocksRemoveListener()

void stmg::Level::blocksRemoveListener ( BlocksListener p0Listener)
noexcept

Removes a a blocks listener.

Parameters
p0ListenerThe listener. Cannot be null.

◆ blocksRemovePlayerChangeListener()

void stmg::Level::blocksRemovePlayerChangeListener ( BlocksPlayerChangeListener p0Listener)
noexcept

Removes a block's player change listener.

Parameters
p0ListenerThe listener. Cannot be null. Must exist.

◆ boabloOwnerBlockClear()

void stmg::Level::boabloOwnerBlockClear ( LevelBlock oLevelBlock)
noexcept

Clears the owner of the cells occupied by the block's visible bricks of its current shape.

If a cell is owned, it has to be owned by oLevelBlock.

Parameters
oLevelBlockThe level block.

◆ boabloOwnerBlockSet()

void stmg::Level::boabloOwnerBlockSet ( LevelBlock oLevelBlock)
noexcept

Sets the owner of the cells occupied by the block's visible bricks of its current shape.

The owner is the block itself. If a cell already has an owner it is overwritten.

Parameters
oLevelBlockThe level block.

◆ boabloUnfreeze()

bool stmg::Level::boabloUnfreeze ( const Coords oCoords,
LevelBlockCreator oCreator,
LevelBlock::MGMT_TYPE  eMgmtType 
)
noexcept

Creates a block from the board.

The board cells cannot be empty when the block is created. The board cells used to build the block will be empty after the call.

Parameters
oCoordsThe coords of the cells on the board used to make the block. Cannot be empty.
oCreatorThe level block creator factory.
eMgmtTypeThe level block type.
Returns
Whether the block could be created.

◆ boardAddListener()

void stmg::Level::boardAddListener ( BoardListener p0Listener)
noexcept

Adds a listener to board modifications.

Parameters
p0ListenerThe listener. Cannot be null.

◆ boardAnimateTile()

void stmg::Level::boardAnimateTile ( NPoint  oXY)
inlinenoexcept

Tells the view it should animate a tile.

The tile will be animated during the view ticks following the current game tick by calling the tile animator of the tile if present or just redrawing it.

Parameters
oXYThe position to animate. Must be within board.

◆ boardAnimateTiles()

void stmg::Level::boardAnimateTiles ( NRect  oArea)
inlinenoexcept

Tells the view it should animate the tiles of an area.

See boardAnimateTile(NPoint oXY).

Parameters
oAreaThe area to animate.

◆ boardDestroy()

void stmg::Level::boardDestroy ( const Coords oCoords)
noexcept

Destroy single tiles of the board.

The tiles are set to empty. Calls BoardListener::boardPreDestroy and BoardListener::boardPostDestroy.

The tile animations and block ownership are left unchanged.

The difference with modifying the tiles to empty tiles is that the view can automatically create explosions.

Parameters
oCoordsThe coords of the board cells. Must be within the board.

◆ boardGetOwner() [1/2]

LevelBlock* stmg::Level::boardGetOwner ( int32_t  nX,
int32_t  nY 
) const
noexcept

Returns the level block owner of a board cell.

Parameters
nXThe x (in tiles). Must be >= 0 and < boardWidth().
nYThe y (in tiles). Must be >= 0 and < boardHeight().
Returns
The level block. Can be null.

◆ boardGetOwner() [2/2]

LevelBlock* stmg::Level::boardGetOwner ( NPoint  oXY) const
inlinenoexcept

Returns the level block owner of a board cell.

Parameters
oXYThe position (in tiles). Must be within the board.
Returns
The level block. Can be null.

◆ boardGetTile() [1/2]

const Tile& stmg::Level::boardGetTile ( int32_t  nX,
int32_t  nY 
) const
noexcept

Returns the tile of a board cell.

Parameters
nXThe x (in tiles). Must be >= 0 and < boardWidth().
nYThe y (in tiles). Must be >= 0 and < boardHeight().
Returns
The tile.

◆ boardGetTile() [2/2]

const Tile& stmg::Level::boardGetTile ( NPoint  oXY) const
inlinenoexcept

Returns the tile of a board cell.

Parameters
oXYThe position (in tiles). Must be within the board.
Returns
The tile.

◆ boardGetTileAniElapsed() [1/2]

double stmg::Level::boardGetTileAniElapsed ( int32_t  nX,
int32_t  nY,
int32_t  nIdxTileAni,
int32_t  nViewTick = 0,
int32_t  nTotViewTicks = 1 
) const
noexcept

Get the elapsed unary time of a certain tile animation of a cell.

This function calls the tile animator of the cell.

Parameters
nXThe x (in tiles). Must be >= 0 and < boardWidth().
nYThe y (in tiles). Must be >= 0 and < boardHeight().
nIdxTileAniThe tile animation. Must be >= 0 and < getNrTileAniAttrs().
nViewTickThe view tick. Must be >= 0 and < nTotTicks.
nTotViewTicksThe number of view ticks. Must be >= 1.
Returns
A number from 0.0 to 1.0 or -1.0 if no tile animator is defined or tile animation not active.

◆ boardGetTileAniElapsed() [2/2]

double stmg::Level::boardGetTileAniElapsed ( NPoint  oXY,
int32_t  nIdxTileAni,
int32_t  nViewTick = 0,
int32_t  nTotViewTicks = 1 
) const
inlinenoexcept

Get the elapsed unary time of a certain tile animation of a cell.

This function calls the tile animator of the cell.

Parameters
oXYThe position (in tiles). Must be within the board.
nIdxTileAniThe tile animation. Must be >= 0 and < getNrTileAniAttrs().
nViewTickThe view tick. Must be >= 0 and < nTotTicks.
nTotViewTicksThe number of view ticks. Must be >= 1.
Returns
A number from 0.0 to 1.0 or -1.0 if no tile animator is defined or tile animation not active.

◆ boardGetTileAnimator() [1/2]

const TileAnimator* stmg::Level::boardGetTileAnimator ( int32_t  nX,
int32_t  nY,
int32_t  nIdxTileAni 
) const
noexcept

Returns the TileAnimator for a certain tile animation.

Parameters
nXThe x (in tiles). Must be >= 0 and < boardWidth().
nYThe y (in tiles). Must be >= 0 and < boardHeight().
nIdxTileAniThe tile animation. Must be >= 0 and < getNrTileAniAttrs().
Returns
The tile animator. Can be null.

◆ boardGetTileAnimator() [2/2]

const TileAnimator* stmg::Level::boardGetTileAnimator ( NPoint  oXY,
int32_t  nIdxTileAni 
) const
inlinenoexcept

Returns the TileAnimator for a certain tile animation.

Parameters
oXYThe position (in tiles). Must be within the board.
nIdxTileAniThe tile animation. Must be >= 0 and < getNrTileAniAttrs().
Returns
The tile animator. Can be null.

◆ boardHeight()

int32_t stmg::Level::boardHeight ( ) const
noexcept

The height of the board in tiles.

Returns
The height.

◆ boardInsert()

void stmg::Level::boardInsert ( Direction::VALUE  eDir,
NRect  oArea,
const shared_ptr< TileRect > &  refTiles 
)
noexcept

Inserts a row or column in a rectangle area.

Calls BoardListener::boardPreInsert and BoardListener::boardPostInsert.

If refTiles is null empty tiles are inserted. If it isn't it's size must be equal or bigger than (oArea.m_nW, oArea.m_nH).

Doesn't change the rectangle's cells' owner (level block). The tile animations move (and get removed) with the cell tile.

Examples:

   0123456789    0123456789
 0 |--------|    |--------|
 1 |        |    |        |
 2 |  AaAA  |    |  XxXX  |   boardInsert(DOWN, {3,2,4,5}, {XxXX})
 3 |  BbBB  |    |  AaAA  |
 4 |  CcCC  |    |  BbBB  |     TileAnis of EeEE are removed,
 5 |  DdDD  |    |  CcCC  |     the others moved down
 6 |  EeEE  |    |  DdDD  |
 7 |        |    |        |
 8 |        |    |        |
 9 |--------|    |--------|

   0123456789
 0 |--------|
 1 |        |
 2 |  BbBB  |   boardInsert(UP, {3,2,4,5}, {XxXX})
 3 |  CcCC  |
 4 |  DdDD  |     TileAnis of AaAA are removed,
 5 |  EeEE  |     the others moved up
 6 |  XxXX  |
 7 |        |
 8 |        |
 9 |--------|

   0123456789
 0 |--------|
 1 |        |
 2 |  XAaA  |   boardInsert(RIGHT, {3,2,4,5}, {XxXXX})
 3 |  xBbB  |
 4 |  XCcC  |     TileAnis of ABCDE (row x=6) are removed,
 5 |  XDdD  |     the others moved right
 6 |  XEeE  |
 7 |        |
 8 |        |
 9 |--------|

   0123456789
 0 |--------|
 1 |        |
 2 |  aAAX  |   boardInsert(LEFT, {3,2,4,5}, {XxXXX})
 3 |  bBBx  |
 4 |  cCCX  |     TileAnis of ABCDE (row x=3) are removed,
 5 |  dDDX  |     the others moved left
 6 |  eEEX  |
 7 |        |
 8 |        |
 9 |--------|
Parameters
eDirThe direction of the insertion.
oAreaThe rectangle. Must be completely within the board and have positive width and height.
refTilesThe tiles to be inserted. Can be null.

◆ boardModify()

void stmg::Level::boardModify ( const TileCoords oTileCoords)
noexcept

Modify the cells of given area.

Calls BoardListener::boardPreModify and BoardListener::boardPostModify.

The tile animations and ownership are left unchanged.

Parameters
oTileCoordsThe modified tiles and their position. Must be all within the board.

◆ boardRemoveListener()

void stmg::Level::boardRemoveListener ( BoardListener p0Listener)
noexcept

Removes a listener to board modifications.

Parameters
p0ListenerThe listener. Cannot be null.

◆ boardScroll()

void stmg::Level::boardScroll ( Direction::VALUE  eDir,
const shared_ptr< TileRect > &  refTiles 
)
noexcept

Scrolls the board contents in a certain direction.

Same as boardInsert with params nX=0, nY=0, nW=boardWidth(), nH=boardHeight() but with a different meaning. It moves the auto scrolled level blocks in the direction of the scroll. In the same way it also moves animations tied to the board. It calls BoardScrollListener listeners.

If a LevelBlock that owns a cell that is about to be scrolled out of the board, it should do something in its BoardScrollListener::boardPreScroll function (provided it is a listener), otherwise it will either be frozen, destroyed or removed.

The caller of this function should expect listeners might keep a reference to the buffer.

A null buffer means all new tiles are empty.

Parameters
eDirThe direction of the scroll.
refTilesThe tiles to be inserted. Can be null.

◆ boardScrollAddListener()

void stmg::Level::boardScrollAddListener ( BoardScrollListener p0Listener)
noexcept

Adds a listener to board scrolls.

Parameters
p0ListenerThe listener. Cannot be null.

◆ boardScrollRemoveListener()

void stmg::Level::boardScrollRemoveListener ( BoardScrollListener p0Listener)
noexcept

Removes a listener to board scrolls.

Parameters
p0ListenerThe listener. Cannot be null.

◆ boardSetOwner() [1/2]

void stmg::Level::boardSetOwner ( int32_t  nX,
int32_t  nY,
LevelBlock p0LevelBlock 
)
noexcept

Sets the level block owner of a board's cell.

Parameters
nXThe x (in tiles). Must be >= 0 and < boardWidth().
nYThe y (in tiles). Must be >= 0 and < boardHeight().
p0LevelBlockThe level block. Can be null.

◆ boardSetOwner() [2/2]

void stmg::Level::boardSetOwner ( NPoint  oXY,
LevelBlock p0LevelBlock 
)
inlinenoexcept

Sets the level block owner of a board's cell.

Parameters
oXYThe position (in tiles). Must be within the board.
p0LevelBlockThe level block. Can be null.

◆ boardSetTile() [1/2]

void stmg::Level::boardSetTile ( int32_t  nX,
int32_t  nY,
const Tile oTile 
)
noexcept

Sets the tile of a board cell.

Parameters
nXThe x (in tiles). Must be >= 0 and < boardWidth().
nYThe y (in tiles). Must be >= 0 and < boardHeight().
oTileThe tile.

◆ boardSetTile() [2/2]

void stmg::Level::boardSetTile ( NPoint  oXY,
const Tile oTile 
)
inlinenoexcept

Sets the tile of a board cell.

Parameters
oXYThe position (in tiles). Must be within the board.
oTileThe tile.

◆ boardSetTileAnimator() [1/2]

void stmg::Level::boardSetTileAnimator ( int32_t  nX,
int32_t  nY,
int32_t  nIdxTileAni,
TileAnimator p0TileAnimator,
int32_t  nHash 
)
noexcept

Set the tile animator of a cell for a certain tile animation.

Parameters
nXThe x (in tiles). Must be >= 0 and < boardWidth().
nYThe y (in tiles). Must be >= 0 and < boardHeight().
nIdxTileAniThe tile animation. Must be >= 0 and < getNrTileAniAttrs().
p0TileAnimatorThe tile animator. Can be null.
nHashA number that is passed to the TileAnimator when boardGetTileAniElapsed() calls it.

◆ boardSetTileAnimator() [2/2]

void stmg::Level::boardSetTileAnimator ( NPoint  oXY,
int32_t  nIdxTileAni,
TileAnimator p0TileAnimator,
int32_t  nHash 
)
inlinenoexcept

Set the tile animator of a cell for a certain tile animation.

Parameters
oXYThe position (in tiles). Must be within the board.
nIdxTileAniThe tile animation. Must be >= 0 and < getNrTileAniAttrs().
p0TileAnimatorThe tile animator. Can be null.
nHashA number that is passed to the TileAnimator when boardGetTileAniElapsed() calls it.

◆ boardSize()

NSize stmg::Level::boardSize ( ) const
noexcept

The size of the board in tiles.

Returns
The size.

◆ boardWidth()

int32_t stmg::Level::boardWidth ( ) const
noexcept

The width of the board in tiles.

Returns
The width.

◆ deactivateEvent()

void stmg::Level::deactivateEvent ( Event p0Event)
noexcept

Deactivate event.

Parameters
p0EventThe event. Cannot be null.

◆ dump()

void stmg::Level::dump ( bool  bDumpBoard,
bool  bDumpLevelBlocks,
bool  bDumpTileAni,
bool  bDumpCharNames,
bool  bDumpColorNames,
bool  bDumpFontNames 
) const
noexcept

◆ extractAllEvents()

std::vector< unique_ptr<Event> > stmg::Level::extractAllEvents ( )
protectednoexcept

Extracts all events from the level.

This can be used for recycling.

Returns
The owning vector of event

◆ game() [1/2]

GameProxy& stmg::Level::game ( )
noexcept

The game proxy.

Returns
The game.

◆ game() [2/2]

const GameProxy& stmg::Level::game ( ) const
noexcept

The game proxy.

Returns
The const game.

◆ gameElapsed()

int32_t stmg::Level::gameElapsed ( ) const
inlinenoexcept

The elapsed time since the game start in intervals.

This a shortcut of game().gameElapsed().

Returns
The elapsed time (game ticks).

◆ gameStart()

void stmg::Level::gameStart ( )
protectednoexcept

Signals the start of the game.

This function is called by Game when a new game is started.

◆ gameStatusCompleted()

bool stmg::Level::gameStatusCompleted ( int32_t  nLevelTeam,
bool  bForceOthersFailed,
bool  bCreateTexts 
)
noexcept

Declare team completed the game.

Parameters
nLevelTeamThe level team that completed the level.
bForceOthersFailedWhether other teams should fail immediately or go on playing.
bCreateTextsWhether to create standard text animations.
Returns
Whether it succeeded.

◆ gameStatusFailed()

bool stmg::Level::gameStatusFailed ( int32_t  nLevelTeam,
bool  bForceOtherCompleted,
bool  bCreateTexts 
)
noexcept

Declare team failed the game.

Parameters
nLevelTeamThe team that failed.
bForceOtherCompletedIf only one other team still playing declare it completed the game.
bCreateTextsWhether to create standard text animations.
Returns
Whether it succeeded.

◆ gameStatusPlayerOut()

bool stmg::Level::gameStatusPlayerOut ( int32_t  nLevelTeam,
int32_t  nMate,
bool  bForceOtherCompleted,
bool  bCreateTexts 
)
noexcept

Declare player dead.

If it was the last mate of the team gameStatusFailed() for the team is called.

Parameters
nLevelTeamThe team of the player.
nMateThe mate number of the player.
bForceOtherCompletedIf last of a failed team declare the only other team completed the game.
bCreateTextsWhether to create standard text animations.
Returns
Whether it succeeded.

◆ gameStatusTechnical()

void stmg::Level::gameStatusTechnical ( const std::vector< std::string > &  aIssue)
noexcept

Technical game over.

Parameters
aIssueProblem description text.

◆ getActiveHumanPlayers()

const std::vector< std::pair<int32_t, int32_t> >& stmg::Level::getActiveHumanPlayers ( )
noexcept

The currently active human players.

Returns
Vector of <nLevelTeam, nMate> pairs.

◆ getEventById()

Event* stmg::Level::getEventById ( const std::string &  sId)
noexcept

Get an event by id.

Parameters
sIdThe string id.
Returns
The event or null if not found.

◆ getFallEachTicks()

int32_t stmg::Level::getFallEachTicks ( )
noexcept

Gets the fall rate of level blocks for this level.

Returns
The interval in game ticks between level block fall.

◆ getInterval()

double stmg::Level::getInterval ( )
noexcept

Get the requested interval for the level.

This function is called by the game to calculate the next game interval.

Returns
The (next) interval im milliseconds.

◆ getLevel()

int32_t stmg::Level::getLevel ( ) const
noexcept

The level identifier within the game.

Returns
The level number.

◆ getNamed() [1/2]

Named& stmg::Level::getNamed ( )
inlinenoexcept

◆ getNamed() [2/2]

const Named& stmg::Level::getNamed ( ) const
inlinenoexcept

◆ getNrTileAniAttrs()

int32_t stmg::Level::getNrTileAniAttrs ( ) const
noexcept

The number of tile animations for both brick and board cell tiles.

This number is determined when the game is started and corresponds to the size of game().getNamed().tileAnis() at that time.

Returns
The number of tile animations.

◆ getTotLevelPlayers()

int32_t stmg::Level::getTotLevelPlayers ( ) const
noexcept

The number of players in the level.

Returns
How many players in the level.

◆ getTotLevelTeams()

int32_t stmg::Level::getTotLevelTeams ( ) const
noexcept

The number of teams in the level.

Returns
How many teams in the level.

◆ hasEvent()

bool stmg::Level::hasEvent ( Event const *  p0Event) const
noexcept

Tells whether the event was added to the level.

Parameters
p0EventThe event. Cannot be null.
Returns
Whether event part of level.

◆ othersAddListener()

bool stmg::Level::othersAddListener ( Event p0OthersListener)
noexcept

Add a listener to events from other levels.

If the listener already is added this function does nothing.

Parameters
p0OthersListenerThe listener. Cannot be null.
Returns
False if listener already added.

◆ othersRemoveListener()

bool stmg::Level::othersRemoveListener ( Event p0OthersListener)
noexcept

Removes a listener to events from other levels.

If the listener is not present this function does nothing.

Parameters
p0OthersListenerThe listener. Cannot be null.
Returns
False if listener not found.

◆ prefs()

const AppPreferences& stmg::Level::prefs ( ) const
inlinenoexcept

The preferences.

Returns
The const preferences.

◆ reInit()

void stmg::Level::reInit ( Game p0Game,
int32_t  nLevel,
const shared_ptr< AppPreferences > &  refPreferences,
const Init oInit 
)
protectednoexcept

Reinitializes the level instance.

The level view is set to null.

Parameters
p0GameThe game. Cannot be null.
nLevelThe number to identify the level within the game.
refPreferencesThe preferences. Cannot be null.
oInitInitialization data.

◆ setFallEachTicks()

void stmg::Level::setFallEachTicks ( int32_t  nFallEachTicks)
noexcept

Sets the fall rate of level blocks for this level.

The LevelBlock::fall() function is called each nFallEachTicks game ticks.

The new value has only effect in the next game tick.

Parameters
nFallEachTicksThe new interval in game ticks between level block fall.

◆ setInterval()

void stmg::Level::setInterval ( double  fMillisec)
noexcept

Set the requested game interval for the level.

Parameters
fMillisecThe new interval im milliseconds.

◆ setLevelView()

void stmg::Level::setLevelView ( LevelView p0View)
protectednoexcept

Set the level view.

Parameters
p0ViewThe view. Can be null.

◆ showGet()

LevelShow& stmg::Level::showGet ( )
noexcept

The level show of the level.

Returns
The level show.

◆ subshowGet() [1/2]

LevelShow& stmg::Level::subshowGet ( int32_t  nLevelTeam,
int32_t  nMate 
)
noexcept

The subshow of a level player.

Call this function only if subshowMode() is true.

Parameters
nLevelTeamThe level team.
nMateThe mate of the team.
Returns
The player's subshow.

◆ subshowGet() [2/2]

LevelShow& stmg::Level::subshowGet ( int32_t  nLevelPlayer)
noexcept

The subshow of a level player.

Call this function only if subshowMode() is true.

Parameters
nLevelPlayerThe level player.
Returns
The player's subshow.

◆ subshowMode()

bool stmg::Level::subshowMode ( ) const
inlinenoexcept

Whether each level player has a subshow.

Returns
Whether in subshow mode.

◆ triggerEvent()

void stmg::Level::triggerEvent ( Event p0Event,
int32_t  nMsg,
int32_t  nValue,
Event p0TriggeringEvent 
)
noexcept

Calls the trigger function of an event.

The triggering event must be owned by the same level of this event. This function deactivates the event without setting its trigger time to -1, so that the event's trigger function can find out whether it was supposed to trigger later.

Parameters
p0EventThe event. Cannot be null.
nMsgThe message. Must be >= -1.
nValueThe value.
p0TriggeringEventThe triggering event or null.

◆ variable() [1/2]

const Variable& stmg::Level::variable ( int32_t  nId,
int32_t  nLevelTeam,
int32_t  nMate 
) const
noexcept

Get existing variable.

The variable must exist! Use game().hasVariableId() to find out.

Parameters
nIdThe variable id.
nLevelTeamThe level team or -1 if game variable.
nMateThe mate or -1 if team or game variable.
Returns
The const variable. Its address is stable throughout a game.

◆ variable() [2/2]

Variable& stmg::Level::variable ( int32_t  nId,
int32_t  nLevelTeam,
int32_t  nMate 
)
noexcept

Get existing variable.

The variable must exist! Use game().hasVariableId() to find out.

Parameters
nIdThe variable id.
nLevelTeamThe level team or -1 if game variable.
nMateThe mate or -1 if team or game variable.
Returns
The variable. Its address is stable throughout a game.

◆ widgetsGet()

shared_ptr<GameWidget> stmg::Level::widgetsGet ( const std::string &  sWidgetName,
int32_t  nLevelTeam,
int32_t  nMate 
)
noexcept

Get a named widget.

Parameters
sWidgetNameThe name of the widget. Cannot be empty.
nLevelTeamThe level team or -1 if a game widget.
nMateThe mate or .1 if a game or team widget.
Returns
The widget or null if not found.