Skip to content

Commit 412f119

Browse files
committed
Resolve #2
Deep Copyを使うことでimportもとに影響を与えなくなりました。やったね!
1 parent 9d36220 commit 412f119

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Script/script.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const dest_sync = field_type => [1].includes(field_type);
3131
const update_cell = (y,x) =>
3232
[PUZ_BOARD_BONE[y][x].querySelector("img.object").src,PUZ_BOARD_BONE[y][x].querySelector("img.field").src] =
3333
[`Pictures/Orbs/${DATA.board.obj[y][x][0]}.svg`,`Pictures/Fields/${DATA.board.field[y][x][1]}.svg`];
34+
const object_copy = x => JSON.parse(JSON.stringify(x));
3435

3536
function update_display(){
3637
for(let i=0;i<DATA.size.Height;i++)for(let j=0;j<DATA.size.Width;j++)update_cell(i,j);
@@ -149,7 +150,7 @@ function chain_toggler(cell){
149150
adj_list=chain_yx=[];
150151
if(DATA.target.hand<=0){
151152
alert(`ゲームオーバー! スコアは${DATA.target.score}でした!`);
152-
import(DATALINK).then(x => {DATA = x.default ; board_init()});
153+
import(DATALINK).then(x => {DATA = object_copy(x.default) ; board_init()});
153154
}
154155
}else if(CELL_COLOR>0){//チェイン開始の処理
155156
chain_now=true;
@@ -165,7 +166,7 @@ function board_init(){
165166
adj_list=chain_yx=[];
166167
update_display();
167168
}
168-
import(DATALINK).then(x => {DATA = x.default ; board_init()});
169+
import(DATALINK).then(x => {DATA = object_copy(x.default) ; board_init()});
169170
//1~:オーブ
170171
//0:無空間
171172
//~-1:妨害ブロック

0 commit comments

Comments
 (0)