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) {
if (this.gameStatus.letter == "") {
const letter = letterList[RandomInt(letterList.length)]; const letter = letterList[RandomInt(letterList.length)];
this.gameStatus.letter = letter; this.gameStatus.letter = letter;
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_playerRoll", type: "SERVER_playerRoll",
letter: letter, letter: letter,
}); });
}
} else { } else {
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_playerWin", type: "SERVER_playerWin",
...@@ -127,6 +129,8 @@ export class GameServer { ...@@ -127,6 +129,8 @@ export class GameServer {
this.gameStatus.gameOver = true; this.gameStatus.gameOver = true;
} }
} else if (data.type == "right") { } else if (data.type == "right") {
if (this.gameStatus.letter != "") {
this.gameStatus.letter = "";
this.gameStatus[data.color] = data.idx; this.gameStatus[data.color] = data.idx;
const letterList = this.getLetterList(); const letterList = this.getLetterList();
console.log("letterList = " + JSON.stringify(letterList)); console.log("letterList = " + JSON.stringify(letterList));
...@@ -145,7 +149,10 @@ export class GameServer { ...@@ -145,7 +149,10 @@ export class GameServer {
}); });
this.gameStatus.gameOver = true; this.gameStatus.gameOver = true;
} }
}
} else if (data.type == "wrong") { } else if (data.type == "wrong") {
if (this.gameStatus.letter != "") {
this.gameStatus.letter = "";
console.log("data = " + JSON.stringify(data)); console.log("data = " + JSON.stringify(data));
// this.gameStatus[data.color] = data.idx; // this.gameStatus[data.color] = data.idx;
this.changeSide(); this.changeSide();
...@@ -154,6 +161,7 @@ export class GameServer { ...@@ -154,6 +161,7 @@ export class GameServer {
uuid: data.uuid, uuid: data.uuid,
color: data.color, 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