File tree Expand file tree Collapse file tree 1 file changed +7
-17
lines changed
workspaces/simon-game/src/app/components Expand file tree Collapse file tree 1 file changed +7
-17
lines changed Original file line number Diff line number Diff line change @@ -109,23 +109,13 @@ export function App() {
109
109
color = { box . color }
110
110
onClick = { ( ) => {
111
111
playNote ( box . frequency ) ;
112
- setPlayerMoves ( ( ) => {
113
- const newPlayerMoves = [ ...playerMoves , index ] ;
114
- const isSequenceCorrect = isPrefixCorrect (
115
- newPlayerMoves ,
116
- correctMoves ,
117
- ) ;
118
- if ( ! isSequenceCorrect ) {
119
- setGameState ( "game-over" ) ;
120
- return newPlayerMoves ;
121
- }
122
- if ( newPlayerMoves . length === correctMoves . length ) {
123
- setGameState ( "cpu-turn" ) ;
124
- return [ ] ;
125
- }
126
- setGameState ( "player-turn" ) ;
127
- return newPlayerMoves ;
128
- } ) ;
112
+ const newPlayerMoves = [ ...playerMoves , index ] ;
113
+ setPlayerMoves ( newPlayerMoves ) ;
114
+ if ( ! isPrefixCorrect ( newPlayerMoves , correctMoves ) ) {
115
+ setGameState ( "game-over" ) ;
116
+ } else if ( newPlayerMoves . length === correctMoves . length ) {
117
+ setGameState ( "cpu-turn" ) ;
118
+ }
129
119
} }
130
120
/>
131
121
) ) }
You can’t perform that action at this time.
0 commit comments