真人进入房间后, 从gamesvr获取真实的score
This commit is contained in:
parent
c300d8cdbb
commit
4a887bbf00
@ -35,8 +35,9 @@ export function getUserInfo(accountid: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export function randomUserInfo() {
|
||||
return axios.get(`${ config.info_svr }/randomrobot`)
|
||||
export function randomUserInfo(min: number, max: number) {
|
||||
const data = {min, max}
|
||||
return axios.post(`${ config.info_svr }/randomrobot`, data)
|
||||
.then(function (response) {
|
||||
let res = response.data
|
||||
if (res.errcode) {
|
||||
|
@ -23,11 +23,15 @@ export class OnJoinCommand extends Command<CardGameState, {
|
||||
return;
|
||||
}
|
||||
let isRobot = false;
|
||||
let uinfo: {nickname: string, avatar: string}
|
||||
let uinfo: {nickname: string, avatar: string, score: number}
|
||||
if (accountId && accountId != 'robot') {
|
||||
uinfo = await getUserInfo(accountId)
|
||||
} else {
|
||||
uinfo = await randomUserInfo()
|
||||
const fc = global.$cfg.get(BaseConst.FORMULA);
|
||||
let low = (this.room.score * fc.get(70034).number / 100) | 0;
|
||||
let high = (this.room.score * fc.get(70035).number / 100) | 0;
|
||||
|
||||
uinfo = await randomUserInfo(low, high)
|
||||
}
|
||||
if (accountId && accountId == 'robot') {
|
||||
isRobot = true;
|
||||
@ -35,6 +39,7 @@ export class OnJoinCommand extends Command<CardGameState, {
|
||||
} else if (!accountId) {
|
||||
accountId = `player_${client.sessionId}`;
|
||||
}
|
||||
// begin of set seat and team
|
||||
let idx = count;
|
||||
let seatSet = new Set([0,1,2,3])
|
||||
for (let [,p] of this.state.players) {
|
||||
@ -51,6 +56,7 @@ export class OnJoinCommand extends Command<CardGameState, {
|
||||
idx = seatSet.values().next().value
|
||||
}
|
||||
const team = (idx == 1 || idx == 2) ? 1 : 0;
|
||||
// end of set seat and team
|
||||
let player = new Player(client.sessionId, idx, team);
|
||||
player.accountId = accountId;
|
||||
player.nickname = uinfo.nickname
|
||||
@ -60,9 +66,9 @@ export class OnJoinCommand extends Command<CardGameState, {
|
||||
let low = fc.get(70034).number;
|
||||
let high = fc.get(70035).number;
|
||||
let random = getRandom(high, low) / 100 ;
|
||||
player.score = this.room.score * random | 0;
|
||||
player.score = this.room.score * random || 0;
|
||||
} else {
|
||||
player.score = score;
|
||||
player.score = uinfo.score;
|
||||
}
|
||||
this.state.players.set(client.sessionId, player);
|
||||
this.room.addAssistClient(client.sessionId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user