超时没选英雄时, 根据玩家可用英雄随机
This commit is contained in:
parent
c0391829be
commit
5435b67daa
@ -44,9 +44,10 @@ export class OnJoinCommand extends Command<CardGameState, {
|
||||
// end of set seat and team
|
||||
let player = new Player(client.sessionId, idx, team);
|
||||
this.state.players.set(client.sessionId, player);
|
||||
let uinfo: {nickname: string, avatar: string, score: number, accountid: string}
|
||||
let uinfo: {nickname: string, avatar: string, score: number, accountid: string, heros: number[]}
|
||||
if (accountId && accountId != 'robot') {
|
||||
uinfo = await getUserInfo(accountId, !!this.room.match)
|
||||
player.heros = uinfo.heros.map(o => parseInt(o+''))
|
||||
} else {
|
||||
const fc = global.$cfg.get(BaseConst.FORMULA);
|
||||
let low = (this.room.score * fc.get(70034).number / 100) | 0;
|
||||
|
@ -44,11 +44,17 @@ export class PlayReadyCommand extends Command<CardGameState, {
|
||||
let pickHeroTimeOut = function () {
|
||||
for (let [, curPlayer] of self.state.players) {
|
||||
if (curPlayer.state == PlayerStateConst.PLAYER_READY ) {
|
||||
let heroMap: Map<number, HeroCfg> = global.$cfg.get(BaseConst.HERO);
|
||||
let heroArr: HeroCfg[] = [...heroMap.values()];
|
||||
let hero: HeroCfg = heroArr.randomOne();
|
||||
let heroId: number
|
||||
if (curPlayer.heros) {
|
||||
heroId = curPlayer.heros.randomOne()
|
||||
} else {
|
||||
let heroMap: Map<number, HeroCfg> = global.$cfg.get(BaseConst.HERO);
|
||||
let heroArr: HeroCfg[] = [...heroMap.values()];
|
||||
let hero: HeroCfg = heroArr.randomOne();
|
||||
heroId = hero.id
|
||||
}
|
||||
let targetClient = self.room.getClient(curPlayer);
|
||||
self.room.dispatcher.dispatch(new SelectHeroCommand(), {client: targetClient, heroId: hero.id});
|
||||
self.room.dispatcher.dispatch(new SelectHeroCommand(), {client: targetClient, heroId});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,8 @@ export class Player extends Schema {
|
||||
*/
|
||||
petData: Map<number, number> = new Map();
|
||||
|
||||
heros: number[];
|
||||
|
||||
/**
|
||||
* 英雄绑定的卡组, 选好英雄后, 从默认配置或玩家卡组(待实现)中获取
|
||||
* key = 效果卡id
|
||||
|
Loading…
x
Reference in New Issue
Block a user