build new pet proto

This commit is contained in:
yuexin 2020-12-03 19:58:56 +08:00
parent b595957a5d
commit 19d1dbb560
4 changed files with 45 additions and 20 deletions

View File

@ -1,3 +1,7 @@
import { EffectCardCfg } from "cfg/parsers/EffectCardCfg";
import { HeroCfg } from "cfg/parsers/HeroCfg";
import { SkillCfg } from "cfg/parsers/SkillCfg";
import { UnitCfg } from "cfg/parsers/UnitCfg";
import { BaseConst } from "../../constants/BaseConst"; import { BaseConst } from "../../constants/BaseConst";
import { EnhanceEffectType } from "./skill/SkillConst"; import { EnhanceEffectType } from "./skill/SkillConst";
@ -7,19 +11,19 @@ let CfgMan = {
*playerid: numer *playerid: numer
*/ */
findPlayerCfg(playerid: number){ findPlayerCfg(playerid: number): HeroCfg{
return global.$cfg.get(BaseConst.HERO).get(playerid); return global.$cfg.get(BaseConst.HERO).get(playerid);
}, },
findUnitCfg(unitid: number){ findUnitCfg(unitid: number): UnitCfg{
return global.$cfg.get(BaseConst.UNIT).get(unitid); return global.$cfg.get(BaseConst.UNIT).get(unitid);
}, },
findSkillCfg(skillid: number){ findSkillCfg(skillid: number): SkillCfg{
return global.$cfg.get(BaseConst.SKILL).get(skillid); return global.$cfg.get(BaseConst.SKILL).get(skillid);
}, },
findEffCardCfg(cardid: number){ findEffCardCfg(cardid: number): EffectCardCfg{
return global.$cfg.get(BaseConst.EFFECTCARD).get(cardid); return global.$cfg.get(BaseConst.EFFECTCARD).get(cardid);
}, },

View File

@ -13,7 +13,8 @@ export class BattleHandler {
private _cs: CardGameState; private _cs: CardGameState;
private _players: Map<Player, PlayerHandler> = new Map(); private _players: Map<Player, PlayerHandler> = new Map();
private _room: Room;
_room: Room;
public init(cs: CardGameState, room: Room){ public init(cs: CardGameState, room: Room){
this._cs = cs; this._cs = cs;
@ -41,6 +42,9 @@ export class BattleHandler {
public getTargetPlayer(){ public getTargetPlayer(){
}; };
/** /**
* 使 * 使
* @param obj * @param obj

View File

@ -7,6 +7,7 @@ import SkillMan from "../skill/SkillMan";
import { EnhanceEffectType, PowerValueType } from "../skill/SkillConst"; import { EnhanceEffectType, PowerValueType } from "../skill/SkillConst";
import { PlayerHandler } from "./PlayerHandler"; import { PlayerHandler } from "./PlayerHandler";
import { PetInfoMsg } from "message/PetInfo";
export class PetHandler { export class PetHandler {
_pet: Pet; _pet: Pet;
@ -21,12 +22,15 @@ export class PetHandler {
_baseap: number; // 基础 _baseap: number; // 基础
_haloap: number = 0; // 光环 _exap: number = 0; // 额外
_exredhurt: number; _exredhurt: number;
_isHero: boolean = false; _isHero: boolean = false;
_selfskills: number[];
_exskills: number[];
public init(apet: Pet, owner: PlayerHandler){ public init(apet: Pet, owner: PlayerHandler){
this._pet = apet; this._pet = apet;
this._owner = owner; this._owner = owner;
@ -56,7 +60,7 @@ export class PetHandler {
this.addSkill(this._cfg.base_skill3id); this.addSkill(this._cfg.base_skill3id);
obj.exskillid && obj.exskillid.forEach((skillid: number)=>{ obj.exskillid && obj.exskillid.forEach((skillid: number)=>{
this.addSkill(skillid, true); this.addSkill(skillid);
}); });
}; };
@ -68,7 +72,7 @@ export class PetHandler {
this._halos.push(halo); this._halos.push(halo);
}; };
public addSkill(skillid: number, isExSkill?: boolean){ public addSkill(skillid: number){
if(skillid > 0){ if(skillid > 0){
let obj = this._skills.get(skillid); let obj = this._skills.get(skillid);
if(!obj){ if(!obj){
@ -76,9 +80,7 @@ export class PetHandler {
if(obj){ if(obj){
obj.setOwner(this); obj.setOwner(this);
this._skills.set(skillid, obj); this._skills.set(skillid, obj);
if(isExSkill){ this._selfskills.push(skillid);
obj.isExSkill = true;
}
if(obj.isBornSkill()){ if(obj.isBornSkill()){
this._bornSkills.push(obj); this._bornSkills.push(obj);
}else if(obj.isDieSkill()){ }else if(obj.isDieSkill()){
@ -117,10 +119,10 @@ export class PetHandler {
}; };
public addAP(value: number){ public addAP(value: number){
this._haloap += value; this._exap += value;
if(this._haloap < 0){ if(this._exap < 0){
this._baseap += this._haloap; this._baseap += this._exap;
this._haloap = 0; this._exap = 0;
} }
if(this._baseap < 0){ if(this._baseap < 0){
this.die(); this.die();
@ -128,7 +130,7 @@ export class PetHandler {
}; };
public totalAP(){ public totalAP(){
return this._baseap + this._haloap; return this._baseap + this._exap;
}; };
public beHurt(value: number){ public beHurt(value: number){
@ -156,4 +158,17 @@ export class PetHandler {
}); });
}; };
public exportData(): PetInfoMsg{
let obj = new PetInfoMsg({
id: this._id,
isHero: this._isHero,
ap: this._baseap,
extAp: this._exap,
harmReduce: this._exredhurt,
skills: this._selfskills,
extSkills: this._exskills
});
return obj;
};
} }

View File

@ -82,18 +82,20 @@ export class PlayerHandler {
return false; return false;
} }
if(cfg.typeId == EffectCardType.NPC){ if(cfg.type_id == EffectCardType.NPC){
let pet = this.newPet(); let pet = this.newPet();
if(!pet){ if(!pet){
return false; return false;
} }
pet.setParam({id: cfg.eff1Id, ap:obj.cardpoint, effcnt: obj.eff_cnt, exskillid: pet.setParam({id: cfg.stageunit_id, ap:obj.cardpoint, effcnt: obj.eff_cnt, exskillid:
[cfg.eff2Id, cfg.eff3Id, cfg.eff4Id, cfg.eff5Id]}); [cfg.quoteskill1id, cfg.quoteskill2id, cfg.quoteskill3id, cfg.quoteskill4id]});
//todo: build pet init json -> client //todo: build pet init json -> client
this._owner._room.bAddPet(pet.exportData());
pet.born(obj); pet.born(obj);
}else if(cfg.typeId == EffectCardType.MAGIC){ }else if(cfg.type_id == EffectCardType.MAGIC){
} }
}; };