Commit a8be6d42 authored by 范雪寒's avatar 范雪寒

fix: 连点问题

parent fe3b3169
...@@ -192,7 +192,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -192,7 +192,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
btn.on("click", async () => { btn.on("click", async () => {
const idx = RandomInt(6); const idx = RandomInt(6);
await this.rollTheDice(idx); await this.rollTheDice(idx);
console.log("汪汪汪 194");
this._status.letter = ["A", "B", "C", "D", "E", "F"][idx]; this._status.letter = ["A", "B", "C", "D", "E", "F"][idx];
}); });
...@@ -318,6 +317,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -318,6 +317,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (node["cantMove"]) { if (node["cantMove"]) {
return; return;
} }
node["cantMove"] = true;
if (this.checkNodeInRightBlock(node, color)) { if (this.checkNodeInRightBlock(node, color)) {
const idx = this.getNextRightIdx(); const idx = this.getNextRightIdx();
const playerMe = this.allPlayerList.find( const playerMe = this.allPlayerList.find(
...@@ -330,7 +330,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -330,7 +330,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
color: playerMe.color, color: playerMe.color,
}); });
} else { } else {
node["cantMove"] = true;
const playerMe = this.allPlayerList.find( const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId (player) => player.uuid == this.playerId
); );
......
...@@ -261,6 +261,7 @@ export class NetworkHelper { ...@@ -261,6 +261,7 @@ export class NetworkHelper {
} }
sendFrame(data: any) { sendFrame(data: any) {
console.log('sendFrame: ' + JSON.stringify(data));
this.room.sendFrame({ data }, (err) => { this.room.sendFrame({ data }, (err) => {
if (err.code != 0) { if (err.code != 0) {
console.log("err", err); console.log("err", err);
......
...@@ -113,12 +113,14 @@ export class GameServer { ...@@ -113,12 +113,14 @@ export class GameServer {
if (data.type == "roll") { if (data.type == "roll") {
const letterList = this.getLetterList(); const letterList = this.getLetterList();
if (letterList.length > 0) { if (letterList.length > 0) {
const letter = letterList[RandomInt(letterList.length)]; if (this.gameStatus.letter == "") {
this.gameStatus.letter = letter; const letter = letterList[RandomInt(letterList.length)];
this.networkHelper.sendFrame({ this.gameStatus.letter = letter;
type: "SERVER_playerRoll", this.networkHelper.sendFrame({
letter: letter, type: "SERVER_playerRoll",
}); letter: letter,
});
}
} else { } else {
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_playerWin", type: "SERVER_playerWin",
...@@ -127,33 +129,39 @@ export class GameServer { ...@@ -127,33 +129,39 @@ export class GameServer {
this.gameStatus.gameOver = true; this.gameStatus.gameOver = true;
} }
} else if (data.type == "right") { } else if (data.type == "right") {
this.gameStatus[data.color] = data.idx; if (this.gameStatus.letter != "") {
const letterList = this.getLetterList(); this.gameStatus.letter = "";
console.log("letterList = " + JSON.stringify(letterList)); this.gameStatus[data.color] = data.idx;
if (letterList.length > 0) { const letterList = this.getLetterList();
console.log("letterList = " + JSON.stringify(letterList));
if (letterList.length > 0) {
this.changeSide();
this.networkHelper.sendFrame({
type: "SERVER_playerRight",
idx: data.idx,
uuid: data.uuid,
color: data.color,
});
} else {
this.networkHelper.sendFrame({
type: "SERVER_playerWin",
color: this.gameStatus.current,
});
this.gameStatus.gameOver = true;
}
}
} else if (data.type == "wrong") {
if (this.gameStatus.letter != "") {
this.gameStatus.letter = "";
console.log("data = " + JSON.stringify(data));
// this.gameStatus[data.color] = data.idx;
this.changeSide(); this.changeSide();
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_playerRight", type: "SERVER_playerWrong",
idx: data.idx,
uuid: data.uuid, uuid: data.uuid,
color: data.color, color: data.color,
}); });
} else {
this.networkHelper.sendFrame({
type: "SERVER_playerWin",
color: this.gameStatus.current,
});
this.gameStatus.gameOver = true;
} }
} else if (data.type == "wrong") {
console.log("data = " + JSON.stringify(data));
// this.gameStatus[data.color] = data.idx;
this.changeSide();
this.networkHelper.sendFrame({
type: "SERVER_playerWrong",
uuid: data.uuid,
color: data.color,
});
} else { } else {
this._aiPlayerList.forEach((ai: AI) => { this._aiPlayerList.forEach((ai: AI) => {
ai.onFrameEvent(data); ai.onFrameEvent(data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment