修改英雄卡组

This commit is contained in:
zhl 2020-12-22 14:41:31 +08:00
parent a6363d30fa
commit 708bc37b72
4 changed files with 7 additions and 17 deletions

View File

@ -38,13 +38,11 @@ export class SelectHeroCommand extends Command<CardGameState, { client: Client,
if (unitData.base_skill1id) heroPet.skills.push(unitData.base_skill1id);
if (unitData.base_skill2id) heroPet.skills.push(unitData.base_skill2id);
if (unitData.base_skill3id) heroPet.skills.push(unitData.base_skill3id);
let petInitData: number[][] = [];
const effectMap = global.$cfg.get(BaseConst.EFFECTCARD);
for (let i = 1; i < 10; i++) {
if (!heroData[`follower${i}id`]) {
break;
}
let subData: number[] = [];
let unitId = heroData[`follower${i}id`];
let weight = 0;
@ -59,11 +57,8 @@ export class SelectHeroCommand extends Command<CardGameState, { client: Client,
if (!effectId) {
error(`未找到效果卡的配置: ${unitId}`);
}
subData.push(effectId);
subData.push(weight);
petInitData.push(subData);
player.unitCfgs.set(effectId+'', weight);
}
player.unitCfgs = petInitData;
this.room.battleMan.addPlayer(player);
this.room.bSelectHero({errocode: 0, errmsg: '', player: client.sessionId, heroId: heroId});
let readyCount = 0;

View File

@ -72,9 +72,11 @@ export class Player extends Schema {
/**
* , , ()
* [id, ]
* key = id
* val = weight
*/
unitCfgs: number[][];
@type({ map: "number" })
unitCfgs = new MapSchema<number>();
constructor(id: string, heroId: number, team: number) {
super();

View File

@ -150,14 +150,7 @@ let assistantUtil = {
// 优先取随从
for (let card of cards) {
let effect = effectMap.get(card.effect);
let hasCard = false;
for (let [id, weight] of dstPlayer.unitCfgs) {
if (id === card.effect) {
hasCard = true;
break;
}
}
if (effect.type_id == 1 && hasCard) {
if (effect.type_id == 1 && dstPlayer.unitCfgs.has(card.effect + '')) {
result = card;
break;
} else if (card.type == 1) {

View File

@ -64,7 +64,7 @@ let gameUtil = {
let tmpArr: number[][] = [];
for (let [id, weight] of player.unitCfgs) {
total += weight;
tmpArr.push([id, total]);
tmpArr.push([parseInt(id), total]);
}
let num = Math.random() * total;
let result;