Commit c67bfeb5 authored by Tt's avatar Tt

完成

parent 26b6f182
This diff is collapsed.
...@@ -8,7 +8,7 @@ export class AI { ...@@ -8,7 +8,7 @@ export class AI {
Red: 0, Red: 0,
Blue: 0, Blue: 0,
letter: "", letter: "",
current: "Blue", current: "Red",
}; };
constructor(networkHelper: NetworkHelper, playerData: any) { constructor(networkHelper: NetworkHelper, playerData: any) {
...@@ -49,12 +49,21 @@ export class AI { ...@@ -49,12 +49,21 @@ export class AI {
//调试加速 2 Math.random() * 3 + 4 //调试加速 2 Math.random() * 3 + 4
await asyncDelay(Math.random() * 3 + 4); await asyncDelay(Math.random() * 3 + 4);
const idx = this.getNextRightIdx(); const idx = this.getNextRightIdx();
this.networkHelper.sendFrame({
type: "right", if (Math.random() < 0.8) {
idx: idx, this.networkHelper.sendFrame({
uuid: this.playerData.uuid, type: "right",
color: this.playerData.color, idx: idx,
}); uuid: this.playerData.uuid,
color: this.playerData.color,
});
} else {
this.networkHelper.sendFrame({
type: "wrong",
uuid: this.playerData.uuid,
color: this.playerData.color,
});
}
} }
} }
} }
......
...@@ -58,7 +58,7 @@ export class GameServer { ...@@ -58,7 +58,7 @@ export class GameServer {
name: this.nameList.splice(0, 1)[0], name: this.nameList.splice(0, 1)[0],
uuid: player.uuid, uuid: player.uuid,
color: color:
player.uuid == this.networkHelper.room.roomInfo.owner ? "Blue" : "Red", player.uuid == this.networkHelper.room.roomInfo.owner ? "Red" : "Blue",
isAI: player.isAI, isAI: player.isAI,
headUrl: this.headUrls.splice(0, 1)[0], headUrl: this.headUrls.splice(0, 1)[0],
}); });
...@@ -82,7 +82,7 @@ export class GameServer { ...@@ -82,7 +82,7 @@ export class GameServer {
Red: 0, Red: 0,
Blue: 0, Blue: 0,
letter: "", letter: "",
current: "Blue", current: "Red",
}; };
startGame() { startGame() {
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
...@@ -108,13 +108,13 @@ export class GameServer { ...@@ -108,13 +108,13 @@ export class GameServer {
const playerInfo = { const playerInfo = {
uuid: "ai_" + i, uuid: "ai_" + i,
isAI: true, isAI: true,
color: "Red", color: "Blue",
}; };
this._aiPlayerList.push(new AI(this.networkHelper, playerInfo)); this._aiPlayerList.push(new AI(this.networkHelper, playerInfo));
this.addPlayer(playerInfo); this.addPlayer(playerInfo);
} }
//TODO:调试加速 //TODO:调试加速
}, 1000)//RandomInt(10000, 15000) }, 10000)//RandomInt(10000, 15000)
); );
} }
} }
...@@ -128,9 +128,9 @@ export class GameServer { ...@@ -128,9 +128,9 @@ export class GameServer {
console.log('letterList: ', letterList); console.log('letterList: ', letterList);
if (letterList.length > 0) { if (letterList.length > 0) {
if (this.gameStatus.letter == "") { if (this.gameStatus.letter == "") {
// let max = Math.max(letterList.length - 2, 0); // let max = Math.max(9, 0);
// let letter = letterList[max];//[RandomInt(letterList.length) % 3];//转盘只有1-3 // let letter = letterList[max];//[RandomInt(letterList.length) % 3];//转盘只有1-3
// if (this.gameStatus.current != 'Blue') { // if (this.gameStatus.current == 'Blue') {
// letter = letterList[0] // letter = letterList[0]
// } // }
let letter = letterList[RandomInt(letterList.length) % 3]; let letter = letterList[RandomInt(letterList.length) % 3];
......
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