@@ -47,6 +47,14 @@ const table = document.getElementById("game-board");
4747
4848//盤面をBoardに従って変更する関数達(Boardを変更したら実行する)
4949function renderBoard ( ) {
50+ // bodyを中央配置に設定
51+ document . body . style . display = "flex" ;
52+ document . body . style . justifyContent = "center" ;
53+ document . body . style . alignItems = "center" ;
54+ document . body . style . minHeight = "100vh" ;
55+ document . body . style . margin = "0" ;
56+ document . body . style . padding = "0" ;
57+
5058 // 初回の盤面生成
5159 table . innerHTML = "" ;
5260 for ( let i = 0 ; i < boardSize ; i ++ ) {
@@ -85,7 +93,6 @@ function renderBoard() {
8593 }
8694 rerender ( ) ;
8795 generationChange ( 0 ) ;
88- stop ( ) ;
8996 } else {
9097 window . parent . postMessage (
9198 {
@@ -101,7 +108,7 @@ function renderBoard() {
101108 e . preventDefault ( ) ;
102109 if ( ! isPlacingTemplate ) {
103110 isDragging = true ;
104- board [ i ] [ j ] = ! board [ i ] [ j ] ;
111+ board [ i ] [ j ] = board [ i ] [ j ] ? 0 : 1 ;
105112 dragMode = board [ i ] [ j ] ;
106113 button . style . backgroundColor = board [ i ] [ j ] ? "black" : "white" ;
107114 if ( generationFigure > 1 ) {
@@ -168,14 +175,6 @@ function rerender() {
168175 if ( currentCellColor !== expectedCellColor ) {
169176 button . style . backgroundColor = expectedCellColor ;
170177 }
171-
172- // セルサイズの更新
173- const currentCellsize = button . style . width ;
174- const expectedCellsize = `${ cellSize } px` ;
175- if ( currentCellsize !== expectedCellsize ) {
176- button . style . width = expectedCellsize ;
177- button . style . height = expectedCellsize ;
178- }
179178 }
180179 }
181180}
@@ -185,7 +184,6 @@ document.addEventListener("mouseup", () => {
185184} ) ;
186185
187186renderBoard ( ) ;
188- progressBoard ( ) ;
189187
190188function scoreReset ( ) {
191189 if ( score === 0 ) return ;
@@ -254,7 +252,6 @@ function progressBoard() {
254252 "All cells on the board have been cleared. Game over! Score:" + score ,
255253 ) ;
256254 window . parent . postMessage ( { type : "timer_change" , data : false } , "*" ) ;
257- stop ( ) ;
258255 previousBoard = [ ] ;
259256 }
260257
@@ -263,7 +260,6 @@ function progressBoard() {
263260 if ( previousBoard . some ( ( prevBoard ) => JSON . stringify ( prevBoard ) === newBoardString ) ) {
264261 showToast ( "ループ発生 終了! スコア:" + score , "Loop detected! End! Score:" + score ) ;
265262 window . parent . postMessage ( { type : "timer_change" , data : false } , "*" ) ;
266- stop ( ) ;
267263 previousBoard = [ ] ;
268264 }
269265
@@ -318,7 +314,6 @@ on.place_template = (template) => {
318314 patternWidth = patternShape [ 0 ] . length ;
319315 isPlacingTemplate = true ;
320316 table . style . cursor = "crosshair" ;
321- stop ( ) ;
322317} ;
323318
324319on . save_board = async ( ) => {
@@ -329,7 +324,6 @@ on.apply_board = (newBoard) => {
329324 board = newBoard ;
330325 renderBoard ( ) ;
331326 generationChange ( 0 ) ;
332- stop ( ) ;
333327 scoreReset ( ) ;
334328} ;
335329
0 commit comments