修改英雄卡组

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

View File

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

View File

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