根据配表,设置英雄unit

This commit is contained in:
zhl 2020-12-04 17:43:17 +08:00
parent 7740507c3c
commit 315499b6b1
4 changed files with 18 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import {PlayerStateConst} from "../../constants/PlayerStateConst";
import {BeginGameCommand} from "./BeginGameCommand";
import {BattleHandler} from "../logic/Handler/BattleHandler";
import {BaseConst} from "../../constants/BaseConst";
import {error} from "../../common/Debug";
/**
*
@ -17,8 +18,20 @@ export class SelectHeroCommand extends Command<CardGameState, {client: Client, h
this.room.sSelectHero(client, {errcode: 1, errmsg: '无法找到对应英雄的配置'});
return;
}
const heroData = heroMap.get(heroId);
player.heroId = heroId;
const unitMap = global.$cfg.get(BaseConst.UNIT);
const unitData = unitMap.get(heroData.herounit_id);
if (!unitData) {
error(`未找到英雄的Unit配置: ${heroId}`);
}
player.state = PlayerStateConst.PLAYER_SELECT_HERO;
player.hp = unitData.hero_hp;
let heroPet = player.pets.get('0');
heroPet.ap = unitData.powernum;
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);
this.room.battleMan.addPlayer(player);
this.room.bSelectHero({errocode: 0, errmsg: '', player: client.sessionId, heroId: heroId});
let readyCount = 0;

View File

@ -16,7 +16,7 @@ export class Pet extends Schema {
harmReduce?: number;
@type(["number"])
skills = new ArraySchema<number>();
skills: number[] = new ArraySchema<number>();
@type(["number"])
extSkills = new ArraySchema<number>()

View File

@ -3,6 +3,7 @@ import {Pet} from "./Pet";
import {Card} from "./Card";
import {singleton} from "../../common/Singleton";
import {GameEnv} from "../../cfg/GameEnv";
import {PlayerStateConst} from "../../constants/PlayerStateConst";
export class Player extends Schema {
@ -51,8 +52,8 @@ export class Player extends Schema {
constructor(id: string, heroId: number, team: number) {
super();
this.id = id;
this.state = 0;
this.hp = 200;
this.state = PlayerStateConst.PLAYER_NORMAL;
this.hp = 0;
this.heroId = heroId;
this.team = team;
for (let i = 0; i < singleton(GameEnv).maxPlayerPetCount + 1; i++) {

View File

@ -201,7 +201,7 @@ let gameUtil = {
* @param player
*/
calcTotalAp(player: Player) {
let result = player.ap;
let result = 0;
for (let [pid, pet] of player.pets) {
result += pet.ap;
}