@@ -37,22 +37,31 @@ const Dot = ({x, y, type, floating}) => (
37
37
)
38
38
39
39
const Levels = ( { current} ) => {
40
- return < div style = { {
41
- position : 'absolute' ,
42
- left : `-${ width / colors . length + 10 } px` ,
43
- top : 0 ,
44
- display : 'flex' ,
45
- flexDirection : 'column-reverse'
46
- } } >
47
- { colors . map ( ( c , i ) => {
48
- return < div key = { c } style = { {
49
- background : c ,
50
- opacity : current >= i ? 1 : 0.2 ,
51
- width : `${ width / colors . length } px` ,
52
- height : `${ width / colors . length } px`
53
- } } />
54
- } ) }
55
- </ div >
40
+ return (
41
+ < div
42
+ style = { {
43
+ position : 'absolute' ,
44
+ left : `-${ width / colors . length + 10 } px` ,
45
+ top : 0 ,
46
+ display : 'flex' ,
47
+ flexDirection : 'column-reverse'
48
+ } }
49
+ >
50
+ { colors . map ( ( c , i ) => {
51
+ return (
52
+ < div
53
+ key = { c }
54
+ style = { {
55
+ background : c ,
56
+ opacity : current >= i ? 1 : 0.2 ,
57
+ width : `${ width / colors . length } px` ,
58
+ height : `${ width / colors . length } px`
59
+ } }
60
+ />
61
+ )
62
+ } ) }
63
+ </ div >
64
+ )
56
65
}
57
66
58
67
class Page extends React . Component {
@@ -152,19 +161,24 @@ class Page extends React.Component {
152
161
for ( let j = - 1 ; j < 7 ; j ++ ) {
153
162
const l = checkTile ( map [ i ] [ j ] )
154
163
if ( l . length > 2 ) {
155
- const newColoredDot = l . reduce ( ( min , d ) => {
156
- if ( d . y > min . y ) return d
157
- if ( d . y === min . y && d . x < min . x ) return d
158
- return min
159
- } , { x : 10 , y : - 2 } )
164
+ const newColoredDot = l . reduce (
165
+ ( min , d ) => {
166
+ if ( d . y > min . y ) return d
167
+ if ( d . y === min . y && d . x < min . x ) return d
168
+ return min
169
+ } ,
170
+ { x : 10 , y : - 2 }
171
+ )
160
172
161
- freshDots . push (
162
- this . newDotAt (
163
- newColoredDot . x ,
164
- newColoredDot . y ,
165
- newColoredDot . type + 1
173
+ if ( newColoredDot . type !== colors . length - 1 ) {
174
+ freshDots . push (
175
+ this . newDotAt (
176
+ newColoredDot . x ,
177
+ newColoredDot . y ,
178
+ newColoredDot . type + 1
179
+ )
166
180
)
167
- )
181
+ }
168
182
l . forEach ( ( d , i ) => {
169
183
keep [ d . x ] [ d . y ] = false
170
184
} )
@@ -392,18 +406,20 @@ class Page extends React.Component {
392
406
background : '#fff'
393
407
} }
394
408
>
395
- < div style = { {
396
- display : this . state . gameover ? 'block' : 'none' ,
397
- position : 'absolute' ,
398
- left : '50%' ,
399
- top : '50%' ,
400
- transform : 'translate(-50%, -50%)' ,
401
- fontSize : '50px' ,
402
- fontFamily : 'Open sans, sans-serif' ,
403
- whiteSpace : 'nowrap' ,
404
- color : '#d50000' ,
405
- fontWeight : 'bold'
406
- } } >
409
+ < div
410
+ style = { {
411
+ display : this . state . gameover ? 'block' : 'none' ,
412
+ position : 'absolute' ,
413
+ left : '50%' ,
414
+ top : '50%' ,
415
+ transform : 'translate(-50%, -50%)' ,
416
+ fontSize : '50px' ,
417
+ fontFamily : 'Open sans, sans-serif' ,
418
+ whiteSpace : 'nowrap' ,
419
+ color : '#d50000' ,
420
+ fontWeight : 'bold'
421
+ } }
422
+ >
407
423
GAME OVER
408
424
</ div >
409
425
< Levels current = { this . state . level } />
@@ -427,3 +443,4 @@ class Page extends React.Component {
427
443
}
428
444
429
445
export default ( ) => < Page />
446
+
0 commit comments