Skip to content

Commit

Permalink
✨ 增加了取消棋子连接效果的开关
Browse files Browse the repository at this point in the history
  • Loading branch information
Littlefean committed Sep 19, 2023
1 parent 182f4bc commit aaa9fd8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>围棋大变种</h1>

<div class="shapeSelect">
<button class="normal">正方形网络</button>
<button class="triangle wip">三角形</button>
<button class="triangle">三角形</button>
<button class="hexagon wip">六边形</button>
</div>

Expand Down Expand Up @@ -57,6 +57,7 @@ <h1>围棋大变种</h1>
<button class="autoPlayRandom10">自动随机10步</button>
<button class="animationSwitch-boardShake">落子棋盘振特效:false</button>
<button class="animationSwitch-shockWave">吃子震荡波特效:true</button>
<button class="animationSwitch-connect">棋子连接效果:true</button>
<div class="table"></div>
</div>
</body>
Expand Down
52 changes: 28 additions & 24 deletions js/normalGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class NormalGame extends Game {
this.animationSwitch = {
"boardShake": false, // 棋盘抖动
"shockWave": true, // 触发吃子时的 落子位置 震荡波
connect: true, // 棋子连接
}
}

Expand Down Expand Up @@ -72,12 +73,14 @@ class NormalGame extends Game {
$(".animationSwitch-boardShake").onclick = function () {
self.animationSwitch.boardShake = !self.animationSwitch.boardShake;
this.innerText = this.innerText.split(":")[0] + ":" + self.animationSwitch.boardShake;
console.log(123)
}
$(".animationSwitch-shockWave").onclick = function () {
self.animationSwitch.shockWave = !self.animationSwitch.shockWave;
this.innerText = this.innerText.split(":")[0] + ":" + self.animationSwitch.shockWave;
console.log(456)
}
$(".animationSwitch-connect").onclick = function () {
self.animationSwitch.connect = !self.animationSwitch.connect;
this.innerText = this.innerText.split(":")[0] + ":" + self.animationSwitch.connect;
}
}

Expand Down Expand Up @@ -621,28 +624,29 @@ class NormalGame extends Game {
if (GameObject.isPlayer(n)) {
block.classList.add("playerBlock");
block.style.backgroundColor = this.colorList[n - GameObject.BasePlayerNumber];
// 连接生动效果
let up = point.up();
let down = point.down();
let left = point.left();
let right = point.right();


if (up.outOfBoard(this.width, this.height) || this._get(up) === n) {
block.style.borderTopLeftRadius = "0";
block.style.borderTopRightRadius = "0";
}
if (down.outOfBoard(this.width, this.height) || this._get(down) === n) {
block.style.borderBottomLeftRadius = "0";
block.style.borderBottomRightRadius = "0";
}
if (left.outOfBoard(this.width, this.height) || this._get(left) === n) {
block.style.borderBottomLeftRadius = "0";
block.style.borderTopLeftRadius = "0";
}
if (right.outOfBoard(this.width, this.height) || this._get(right) === n) {
block.style.borderBottomRightRadius = "0";
block.style.borderTopRightRadius = "0";
// 是否开启棋子连接特效的开关
if (this.animationSwitch.connect) {
// 连接生动效果
let up = point.up();
let down = point.down();
let left = point.left();
let right = point.right();
if (up.outOfBoard(this.width, this.height) || this._get(up) === n) {
block.style.borderTopLeftRadius = "0";
block.style.borderTopRightRadius = "0";
}
if (down.outOfBoard(this.width, this.height) || this._get(down) === n) {
block.style.borderBottomLeftRadius = "0";
block.style.borderBottomRightRadius = "0";
}
if (left.outOfBoard(this.width, this.height) || this._get(left) === n) {
block.style.borderBottomLeftRadius = "0";
block.style.borderTopLeftRadius = "0";
}
if (right.outOfBoard(this.width, this.height) || this._get(right) === n) {
block.style.borderBottomRightRadius = "0";
block.style.borderTopRightRadius = "0";
}
}
} else {
block.classList.add(GameObject.eval(n));
Expand Down

0 comments on commit aaa9fd8

Please sign in to comment.