修改英雄卡组
This commit is contained in:
parent
a6363d30fa
commit
708bc37b72
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user