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

fix: 连点问题

parent fe3b3169
......@@ -192,7 +192,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
btn.on("click", async () => {
const idx = RandomInt(6);
await this.rollTheDice(idx);
console.log("汪汪汪 194");
this._status.letter = ["A", "B", "C", "D", "E", "F"][idx];
});
......@@ -318,6 +317,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (node["cantMove"]) {
return;
}
node["cantMove"] = true;
if (this.checkNodeInRightBlock(node, color)) {
const idx = this.getNextRightIdx();
const playerMe = this.allPlayerList.find(
......@@ -330,7 +330,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
color: playerMe.color,
});
} else {
node["cantMove"] = true;
const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId
);
......
......@@ -261,6 +261,7 @@ export class NetworkHelper {
}
sendFrame(data: any) {
console.log('sendFrame: ' + JSON.stringify(data));
this.room.sendFrame({ data }, (err) => {
if (err.code != 0) {
console.log("err", err);
......
......@@ -113,12 +113,14 @@ export class GameServer {
if (data.type == "roll") {
const letterList = this.getLetterList();
if (letterList.length > 0) {
const letter = letterList[RandomInt(letterList.length)];
this.gameStatus.letter = letter;
this.networkHelper.sendFrame({
type: "SERVER_playerRoll",
letter: letter,
});
if (this.gameStatus.letter == "") {
const letter = letterList[RandomInt(letterList.length)];
this.gameStatus.letter = letter;
this.networkHelper.sendFrame({
type: "SERVER_playerRoll",
letter: letter,
});
}
} else {
this.networkHelper.sendFrame({
type: "SERVER_playerWin",
......@@ -127,33 +129,39 @@ export class GameServer {
this.gameStatus.gameOver = true;
}
} else if (data.type == "right") {
this.gameStatus[data.color] = data.idx;
const letterList = this.getLetterList();
console.log("letterList = " + JSON.stringify(letterList));
if (letterList.length > 0) {
if (this.gameStatus.letter != "") {
this.gameStatus.letter = "";
this.gameStatus[data.color] = data.idx;
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.networkHelper.sendFrame({
type: "SERVER_playerRight",
idx: data.idx,
type: "SERVER_playerWrong",
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") {
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 {
this._aiPlayerList.forEach((ai: AI) => {
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