@@ -148,17 +148,19 @@ export const ViewOnlyOthello = memo(({ game }: { game: GameModelAPI }): ReactEle
148148 const boardsByTurn = useMemo ( ( ) => {
149149 return log . reduce < GameState [ ] > (
150150 ( boards , entry ) => {
151- const lastState = boards . at ( - 1 ) ! ;
152- const nextBoard = cloneBoard ( lastState . board ) ;
153- if ( entry . action === 'play' ) playOnBoard ( nextBoard , entry . turn , ...entry . ctx ! ) ;
154- const playedAt = new Date ( entry . time ) ;
155- const nextState : GameState = {
156- board : nextBoard ,
157- sinceLast : playedAt . getTime ( ) - lastState . at . getTime ( ) ,
158- at : playedAt ,
159- score : getScore ( nextBoard ) ,
160- } ;
161- boards . push ( nextState ) ;
151+ if ( entry . action === 'play' ) {
152+ const lastState = boards . at ( - 1 ) ! ;
153+ const nextBoard = cloneBoard ( lastState . board ) ;
154+ playOnBoard ( nextBoard , entry . turn , ...entry . ctx ! ) ;
155+ const playedAt = new Date ( entry . time ) ;
156+ const nextState : GameState = {
157+ board : nextBoard ,
158+ sinceLast : playedAt . getTime ( ) - lastState . at . getTime ( ) ,
159+ at : playedAt ,
160+ score : getScore ( nextBoard ) ,
161+ } ;
162+ boards . push ( nextState ) ;
163+ }
162164 return boards ;
163165 } ,
164166 [ { board : getInitialBoard ( ) , sinceLast : null , at : new Date ( game . started ) , score : { W : 0 , B : 0 } } ]
0 commit comments