冲锋/反击逻辑处理

This commit is contained in:
y.x 2020-12-22 03:51:23 +08:00
parent aa22797838
commit 9c0d9f7cce
7 changed files with 117 additions and 23 deletions

Binary file not shown.

View File

@ -226,9 +226,11 @@ export class BattleHandler {
}
break;
case GameCampType.FRIEND:
let obj = this.getFriend(src);
if(obj && obj.isAlive()){
lst.push(obj);
{
let obj = this.getFriend(src);
if(obj && obj.isAlive()){
lst.push(obj);
}
}
break;
case GameCampType.MYTEAM:
@ -295,6 +297,13 @@ export class BattleHandler {
}
}
break;
case GameCampType.ALL_EXSELF:
for(let [key, obj] of this._players){
if(obj && obj.isAlive() && obj != src){
lst.push(obj);
}
}
break;
default:
break;
}

View File

@ -260,11 +260,17 @@ export class PetHandler {
};
public beHurt(value: number): number{
let res = value - value * this._exredhurt;
if(res < 0){
let rv = value - value * this._exredhurt;
if(rv < 0){
return 0;
}
return this.subAP(res);
let res = this.subAP(rv);
if(res != 0){
this._owner.onBeHurt(this, res);
}
return res;
};
public addHP(value: number){
@ -316,17 +322,18 @@ export class PetHandler {
this._owner.onPetDied(this);
};
public attack(apet: PetHandler, param: SkillParam){
//todo:
return 0;
};
public attack(apet: PetHandler, param: SkillParam, ev: number = 0, isAtkBack: boolean = false){
!isAtkBack && this._owner.onAttackBefore(this, param);
beforeAttack(){
//todo:
};
let myap = this.totalAP();
myap += myap*ev;
// let otherap = apet.totalAP();
afterAttack(){
//todo:
let n = apet.beHurt(myap);
!isAtkBack && this._owner.onBeAttack(apet, param);
return n;
};
public reborn(){

View File

@ -267,8 +267,8 @@ export class PlayerHandler {
return this._self.addEM(value);
};
public getEM(): number{
return this._totalem;
public getEMRatio(): number{
return this._totalem/100;
};
public onEMChanged(value: number){
@ -299,7 +299,7 @@ export class PlayerHandler {
};
public attack(apet: PetHandler, param: SkillParam, ev: number){
return this._self.attack(apet, param);
return this._self.attack(apet, param, ev);
};
public beSilent(count: number){
@ -403,6 +403,18 @@ export class PlayerHandler {
this._owner.onUpdatePetsNotify(lst);
};
onAttackBefore(apet: PetHandler, sp?: SkillParam){
this.singleCheckSkills(apet, TriggerType.BEFORE_ATTACK, null, sp);
};
onBeAttack(apet: PetHandler, sp?: SkillParam){
this.singleCheckSkills(apet, TriggerType.BE_ATTACK, null, sp);
};
onBeHurt(apet: PetHandler, value: number){
this.singleCheckSkills(apet, TriggerType.BE_HURT, value);
};
public isMyPet(apet: PetHandler){
if(apet == this._self){
return true;
@ -542,6 +554,24 @@ export class PlayerHandler {
this._owner.onSkillResultNotify(reslst);
};
singleCheckSkills(apet: PetHandler, tgttype: TriggerType, tgtvalue?: any, tgtsp?: SkillParam){
let sp = tgtsp;
if(!sp){
sp = new SkillParam(0, 0, 0, this, apet, null, null);
}
let reslst: SkillTarget[] = [];
apet.checkSkills(tgttype, tgtvalue, sp, (skill: Skill, ap: SkillParam, res: SkillTarget[])=>{
if(res){
reslst = reslst.concat(res);
}else{
let st = new SkillTarget(skill);
st.LoadParam(sp);
reslst.push(st);
}
});
this._owner.onSkillResultNotify(reslst);
};
simpleCheckSkills(skills: Skill[], apet?: PetHandler, param?: SkillParam): SkillTarget[]{
let ps = param? param: new SkillParam(0, 0, 0, this, apet, this, apet);
let reslst: SkillTarget[] = [];

View File

@ -216,7 +216,21 @@ export class Skill {
_triggerSubSkill(param: SkillParam, cb?: any){
if(this._data.quoteskillid && !this._subskill){
this._subskill = this._owner.newSkill(this._data.quoteskillid);
}
if(this._subskill){
let subparam = this._data.skill_users? param.clone(): param;
if(this._data.skill_users){
subparam.srcplayer = subparam.dstplayer;
subparam.srcpet = subparam.dstpet;
}
let ncount = this.getFinalValue(this._data.quotecard_times,
this._data.quotecard_timesmax, param.edd_cnt, param.cardpoint);
if(ncount == 0){
ncount = 1;
}
for(let i=0; i<ncount;i++){
this._subskill._trigger(subparam, cb);
}
}
};
@ -344,8 +358,9 @@ export class Skill {
break;
case SkillEffectType.HURT_POWER:
case SkillEffectType.HURT_ALL:
let effv = this.EMV(effvalue);
if(tgt.dsttype != GameUnitType.NONE && tgt.dsttype != GameUnitType.PLAYER){
let n = (tgt.dst as PetHandler).beHurt(effvalue);
let n = (tgt.dst as PetHandler).beHurt(effv);
tgt.success(efftype, n);
}else{
tgt.fail(efftype, -1);
@ -359,7 +374,8 @@ export class Skill {
handleHP(effvalue: number, tgt: SkillTarget){
let efftype = SkillEffectType.HURT_HP;
if(tgt.dsttype == GameUnitType.PLAYER || tgt.dsttype == GameUnitType.HERO){
let n = tgt.dst.addHP(effvalue);
let effv = this.EMV(effvalue);
let n = tgt.dst.addHP(effv);
tgt.success(efftype, n);
}else{
tgt.fail(efftype, -1);
@ -407,8 +423,13 @@ export class Skill {
if(ncount == 0){
ncount = 1;
}
let obj = tgt.srcpet? tgt.srcpet: tgt.srcplayer;
let n = obj.addSkill(this._data.getskillid, ncount);
let obj;
if(this._data.skill_owners){
obj = tgt.dst;
}else{
obj = tgt.srcpet? tgt.srcpet: tgt.srcplayer;
}
let n = obj? obj.addSkill(this._data.getskillid, ncount): 0;
if(n){
tgt.success(efftype, this._data.getskillid);
}else{
@ -460,6 +481,12 @@ export class Skill {
}
};
EMV(effvalue: number){
let ev = effvalue;
ev *= this._owner.getEMRatio();
return effvalue + ev;
};
reborn(tgt: SkillTarget){
let efftype = SkillEffectType.REBORN;
if(tgt.dsttype != GameUnitType.NONE){
@ -496,6 +523,18 @@ export class Skill {
let res = obj.attack((tgt.dst as PetHandler), param, v);
if(res){
tgt.success(efftype, res);
if(this._data.quoteskillid == 40112){
let dp = this._data.skill_users? param.clone(): param;
if(this._data.skill_users){
dp.srcpet = param.dstpet;
dp.srcplayer = param.dstplayer;
}
let pet = tgt.srcpet;
if(!pet && tgt.srcplayer){
pet = tgt.srcplayer._self;
}
(tgt.dst as PetHandler).attack(pet, dp);
}
}else{
tgt.fail(efftype, -1);
}

View File

@ -72,6 +72,8 @@ export const enum TriggerType
BE_HURT = 11,
BEFORE_ATTACK = 12,
BE_ATTACK = 13,
};
// 技能大类
@ -248,6 +250,7 @@ export const enum GameUnitType {
* 7.
* 8.
* 9.
* 10.+
*/
export const enum GameCampType {
NONE = 0,
@ -260,6 +263,7 @@ export const enum GameCampType {
RANDOM_US = 7,
RANDOM_ENEMY = 8,
FACE_ENEMY = 9,
ALL_EXSELF = 10,
};
// 战力参数数值

View File

@ -24,6 +24,11 @@ export class SkillParam{
this.dstplayer = dstplayer;
this.dstpet = dstpet;
};
clone(){
return new SkillParam(this.cardid, this.cardpoint, this.edd_cnt,
this.srcplayer, this.srcpet, this.dstplayer, this.dstpet);
};
};
export class SkillResult{