diff --git a/src/utils/assistant.util.ts b/src/utils/assistant.util.ts index 170b406..ae6154e 100644 --- a/src/utils/assistant.util.ts +++ b/src/utils/assistant.util.ts @@ -152,26 +152,39 @@ let assistantUtil = { let result: Card; let effectMap: Map = global.$cfg.get(BaseConst.EFFECTCARD); let spellCards: Card[] = []; + let petCards: Card[] = []; + // 优先取随从 let petCount = 0; for (let [,pet] of dstPlayer.pets) { if (pet.state == 1 && !pet.isHero) petCount ++; } let noMorePet = petCount >= new GameEnv().maxPlayerPetCount; + let noPet = Math.random2(0, 100) > 70; + for (let card of cards) { - let effect = effectMap.get(card.effect); - // if (effect.type_id == EffectType.unit && dstPlayer.unitCfgs.has(card.effect + '')) { - if (card.type == CardType.variable_unit && !noMorePet && !noPet) { - result = card; - break; - } else if (effect.type_id == EffectType.skill) { + if (card.type == CardType.variable_unit) { + petCards.push(card); + } else if (card.type == CardType.general) { spellCards.push(card); } } - if (!result) { + if (!noMorePet && !noPet && petCards.length > 0) { + result = petCards.randomOne(); + } + + if (!result && spellCards.length > 0) { result = spellCards.randomOne(); } + let oldpos = -1; + if (!result && petCards.length > 0) { + result = petCards.randomOne(); + if (noMorePet) { + oldpos = 1; + } + } + if (!result) { error(`无法选择随从或法术, 随从数: ${petCount}, 法术牌数量: ${spellCards.length}`); return null; @@ -228,7 +241,8 @@ let assistantUtil = { card: result.id, player: targetPlayer?.id, pos: targetPos, - effCards + effCards, + oldpos } },