import { Block } from './element/block/block.class' ; import { Ground } from './element/block/ground.class' ; import { Creature } from './element/creature/creature.class' ; export class Cave { grid : Block [ ] = [ ] ; width = 0 ; height = 0 ; /**
     * Ensures correct order
     */ * units ( ) { for ( const tile of this . grid . filter ( ( t ) => t instanceof Ground && ( t as Ground ) . occupant ) ) { yield ( tile as Ground ) . occupant ; } } toString ( ) { let repr = '' ; for ( let y = 0 ; y < this . height ; y ++ ) { let row = '' ; for ( let x = 0 ; x < this . width ; x ++ ) { row += this . grid [ y * this . height + x ] . toString ( ) ; } repr += row + '\n' ; } return repr ; } }