File tree Expand file tree Collapse file tree 3 files changed +10
-36
lines changed Expand file tree Collapse file tree 3 files changed +10
-36
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,12 @@ const HONEY_SOUND = 'honey';
1313const NECTAR_SOUND = 'nectar' ;
1414
1515module . exports = class Bee extends Gatherer {
16- constructor ( maze , config ) {
16+ constructor ( maze , config = { } ) {
1717 super ( maze , config ) ;
18+ const { level} = config ;
1819
19- this . defaultFlowerColor_ = ( config . level . flowerType === 'redWithNectar' ?
20- 'red' : 'purple' ) ;
21- if ( this . defaultFlowerColor_ === 'purple' &&
22- config . level . flowerType !== 'purpleNectarHidden' ) {
23- throw new Error ( `bad flowerType for Bee: ${ config . level . flowerType } ` ) ;
24- }
20+ this . defaultFlowerColor_ = level && level . flowerType === 'redWithNectar' ?
21+ 'red' : 'purple' ;
2522
2623 // at each location, tracks whether user checked to see if it was a flower or
2724 // honeycomb using an if block
Original file line number Diff line number Diff line change @@ -31,13 +31,12 @@ const TILE_SHAPES = {
3131} ;
3232
3333module . exports = class Subtype extends EventEmitter {
34- constructor ( maze , config ) {
34+ constructor ( maze , { skin , level } = { } ) {
3535 super ( ) ;
3636
3737 this . maze_ = maze ;
38- this . skin_ = config . skin ;
39- this . level_ = config . level ;
40- this . startDirection = config . level . startDirection ;
38+ this . skin_ = skin ;
39+ this . startDirection = level ? level . startDirection : 0 ;
4140 }
4241
4342 /**
Original file line number Diff line number Diff line change 1+ /* global describe, it, expect */
2+
13import Bee from '../../src/bee' ;
24import BeeCell from '../../src/beeCell' ;
35import MazeMap from '../../src/mazeMap' ;
46
5- var baseLevel = {
7+ const baseLevel = {
68 honeyGoal : 1 ,
79 map : [
810 [ 0 ]
@@ -15,30 +17,6 @@ var baseLevel = {
1517} ;
1618
1719describe ( "Bee" , function ( ) {
18- it ( "fails if no flowerType" , function ( ) {
19- var maze = { } ;
20- var config = {
21- level : baseLevel
22- } ;
23- delete config . level . flowerType ;
24- expect ( ( ) => {
25- new Bee ( maze , config ) ;
26- } ) . toThrowError ( / b a d f l o w e r T y p e f o r B e e / ) ;
27- } ) ;
28-
29-
30- it ( "fails if invalid flowerType" , function ( ) {
31- var maze = { } ;
32- var config = {
33- level : Object . assign ( baseLevel , {
34- flowerType : 'invalid'
35- } )
36- } ;
37- expect ( ( ) => {
38- new Bee ( maze , config ) ;
39- } ) . toThrowError ( / b a d f l o w e r T y p e f o r B e e / ) ;
40- } ) ;
41-
4220 describe ( "isRedFlower" , function ( ) {
4321 /**
4422 * Shim a 1x1 maze with the given values and validate that we get the
You can’t perform that action at this time.
0 commit comments