牌组未初始化时, 如有人抽牌, 则返回0

This commit is contained in:
zhl 2021-01-29 14:03:25 +08:00
parent c423e715a3
commit 21b9af6a28
2 changed files with 10 additions and 1 deletions

View File

@ -75,6 +75,10 @@ Object.defineProperties(Room.prototype, {
*/
addCard: {
value: function ( dstplayer: string, count: number, max_count: number, source: number = 0, fromplayer?: string, extData?: {}): number {
if (this.state.cardQueue.length == 0) {
error("牌组还没初始化, 谁来抽卡??????");
return 0;
}
let maxCountCfg = new GameEnv().maxCardNum;
let maxCount = Math.min(maxCountCfg, max_count);
let player = this.state.players.get(dstplayer);

View File

@ -219,15 +219,20 @@ let gameUtil = {
},
pushInPlayerCards(player: Player, cards: Card[]) {
const effectMap = global.$cfg.get(BaseConst.EFFECTCARD);
cardLog(`add: ${player.id} ${cards.map(o => [o.id, o.effect, o.type])}`)
let realCards: Card[] = []
for (let card of cards) {
if (!card) {
continue
}
// 如果card的type == 11, 说明是自选随从卡, 则替换成玩家牌组中的卡
if (card.type == CardType.variable_unit && effectMap.get(card.effect).type_id == EffectType.variable_unit) {
card.effect = this.getRandomServant(player);
}
realCards.push(card)
player.cards.set(card.id + '', card);
player.cardSet.add(card.id + '');
}
cardLog(`add: ${player.id} ${realCards.map(o => [o.id, o.effect, o.type])}`)
},
/**
*