1- const Cell = require ( './cell' )
2- const DirtDrawer = require ( './dirtDrawer' )
1+ const Cell = require ( './cell' ) ;
2+ const DirtDrawer = require ( './dirtDrawer' ) ;
33
44const SquareType = require ( './tiles' ) . SquareType ;
55const EventEmitter = require ( 'events' ) . EventEmitter ; // provided by webpack's node-libs-browser
@@ -30,6 +30,9 @@ const TILE_SHAPES = {
3030 'null4' : [ 1 , 3 ] ,
3131} ;
3232
33+ // Chance of showing a random wall tile other than the default.
34+ const RANDOM_TILE_RATE = 0.2 ;
35+
3336module . exports = class Subtype extends EventEmitter {
3437 constructor ( maze , config ) {
3538 super ( ) ;
@@ -137,10 +140,10 @@ module.exports = class Subtype extends EventEmitter {
137140 ) ;
138141 }
139142
140- getEmptyTile ( x , y , adjacentToPath ) {
143+ getEmptyTile ( x , y , adjacentToPath , innerCorner ) {
141144 let tile ;
142145 // Empty square. Use null0 for large areas, with null1-4 for borders.
143- if ( ! adjacentToPath && Math . random ( ) > 0.3 ) {
146+ if ( innerCorner || ( ! adjacentToPath && Math . random ( ) > RANDOM_TILE_RATE ) ) {
144147 this . wallMap [ y ] [ x ] = 0 ;
145148 tile = 'null0' ;
146149 } else {
@@ -149,11 +152,6 @@ module.exports = class Subtype extends EventEmitter {
149152 tile = 'null' + wallIdx ;
150153 }
151154
152- // For the first 3 levels in maze, only show the null0 image.
153- if ( [ '2_1' , '2_2' , '2_3' ] . includes ( this . level_ . id ) ) {
154- this . wallMap [ y ] [ x ] = 0 ;
155- tile = 'null0' ;
156- }
157155 return tile ;
158156 }
159157
@@ -172,12 +170,14 @@ module.exports = class Subtype extends EventEmitter {
172170 this . isOnPathStr_ ( col , row + 1 ) + // South.
173171 this . isOnPathStr_ ( col - 1 , row ) ; // East.
174172
175- const adjacentToPath = ( tile !== '00000' ) ;
176-
177173 // Draw the tile.
178174 if ( ! TILE_SHAPES [ tile ] ) {
175+ const adjacentToPath = tile !== '00000' ;
176+ // Any block with 2, 3 or 4 orthogonal paths.
177+ const innerCorner = adjacentToPath && tile . split ( '1' ) . length > 2 ;
178+
179179 // We have an empty square. Handle it differently based on skin.
180- tile = this . getEmptyTile ( col , row , adjacentToPath ) ;
180+ tile = this . getEmptyTile ( col , row , adjacentToPath , innerCorner ) ;
181181 }
182182
183183 this . drawTile ( svg , TILE_SHAPES [ tile ] , row , col , tileId ) ;
0 commit comments