This commit is contained in:
yuexin 2020-12-04 18:06:27 +08:00
commit f32117aa05
4 changed files with 20 additions and 11 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 {
@ -23,11 +24,7 @@ export class Player extends Schema {
*/
@type("number")
hp: number;
/**
*
*/
@type("number")
ap: number;
/**
*
* 0: 正常状态
@ -55,12 +52,11 @@ export class Player extends Schema {
constructor(id: string, heroId: number, team: number) {
super();
this.id = id;
this.state = 0;
this.hp = 200;
this.ap = 30;
this.state = PlayerStateConst.PLAYER_NORMAL;
this.hp = 0;
this.heroId = heroId;
this.team = team;
for (let i = 0; i < singleton(GameEnv).maxPlayerPetCount; i++) {
for (let i = 0; i < singleton(GameEnv).maxPlayerPetCount + 1; i++) {
this.pets.set(i+'', new Pet());
}
}

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;
}