增加接口

This commit is contained in:
y.x 2020-12-08 12:57:26 +08:00
parent e10852fc94
commit acfe8c7e50
2 changed files with 41 additions and 14 deletions

View File

@ -32,6 +32,13 @@ export class BattleHandler {
}; };
public delPlayer(aplayer: Player){ public delPlayer(aplayer: Player){
let ph = this.getPlayer(aplayer);
this._players.forEach((item: PlayerHandler) =>{
if(item._friend == ph){
item._friend = null;
}
});
this._players.delete(aplayer); this._players.delete(aplayer);
}; };
@ -156,6 +163,7 @@ export class BattleHandler {
return lst; return lst;
}; };
//--------------------对外接口(外部调用)----------------------------
/** /**
* 使 * 使
* @param obj * @param obj
@ -285,6 +293,19 @@ export class BattleHandler {
ph && ph.onRoundEnd(); ph && ph.onRoundEnd();
}; };
/**
*
* @param aplayer
*/
public onPlayerDead(aplayer: Player){
let ph = this.getPlayer(aplayer);
ph && ph.die();
};
// end--------------------------------------------------
// --------------------调用外部接口函数--------------------------
public onAddPetNotify(apet: PetHandler){ public onAddPetNotify(apet: PetHandler){
return this._room.bAddPet(apet.exportData()); return this._room.bAddPet(apet.exportData());
}; };
@ -293,15 +314,15 @@ export class BattleHandler {
return this._room.bRemovePet(apet.exportRemoveData()); return this._room.bRemovePet(apet.exportRemoveData());
}; };
public onPlayerAddCard(aplayer: PlayerHandler, count: number, maxcount: number){ public onPlayerAddCardNotify(aplayer: PlayerHandler, count: number, maxcount: number){
return this._room.addCard(aplayer.getId(), count, maxcount); return this._room.addCard(aplayer.getId(), count, maxcount);
}; };
public onPlayerStealCard(srcplayer: PlayerHandler, dstplayer: PlayerHandler, count: number){ public onPlayerStealCardNotify(srcplayer: PlayerHandler, dstplayer: PlayerHandler, count: number){
return this._room.drawCardFromPlayer(srcplayer.getId(), dstplayer.getId(), count); return this._room.drawCardFromPlayer(srcplayer.getId(), dstplayer.getId(), count);
}; };
public onSkillResult(skillres: SkillTarget[]){ public onSkillResultNotify(skillres: SkillTarget[]){
if(!skillres || skillres.length <= 0){ if(!skillres || skillres.length <= 0){
return; return;
} }
@ -310,5 +331,10 @@ export class BattleHandler {
lst.push(item.exportData()); lst.push(item.exportData());
}); });
this._room.bMsgQueue(lst); this._room.bMsgQueue(lst);
};
public onPlayerAddHPNotify(aplayer: PlayerHandler, addhp: number){
return addhp;
} }
//end------------------------------------------------
} }

View File

@ -189,23 +189,19 @@ export class PlayerHandler {
}; };
public addCard(count: number){ public addCard(count: number){
return this._owner.onPlayerAddCard(this, count, 0); return this._owner.onPlayerAddCardNotify(this, count, 0);
}; };
public addCardLimit(maxcount: number){ public addCardLimit(maxcount: number){
return this._owner.onPlayerAddCard(this, 0, maxcount); return this._owner.onPlayerAddCardNotify(this, 0, maxcount);
}; };
public stealCard(dstplayer: PlayerHandler, count: number){ public stealCard(dstplayer: PlayerHandler, count: number){
return this._owner.onPlayerStealCard(this, dstplayer, count); return this._owner.onPlayerStealCardNotify(this, dstplayer, count);
}; };
public addHP(value: number){ public addHP(value: number){
this._player.hp += value; return this._owner.onPlayerAddHPNotify(this, value);
if(value < 0){
this.die();
}
return value;
}; };
public getHP(){ public getHP(){
@ -230,6 +226,11 @@ export class PlayerHandler {
public die(){ public die(){
//todo: //todo:
};
public isDead(){
this._player.state == 2;
}; };
public onPetBorned(apet: PetHandler, param: SkillParam){ public onPetBorned(apet: PetHandler, param: SkillParam){
@ -249,7 +250,7 @@ export class PlayerHandler {
}); });
}); });
this._owner.onSkillResult(reslst); this._owner.onSkillResultNotify(reslst);
}; };
public onPetDied(apet: PetHandler){ public onPetDied(apet: PetHandler){
@ -270,7 +271,7 @@ export class PlayerHandler {
}); });
}); });
this._owner.onSkillResult(reslst); this._owner.onSkillResultNotify(reslst);
}; };
public onHaloChanged(apet: PetHandler){ public onHaloChanged(apet: PetHandler){
@ -353,7 +354,7 @@ export class PlayerHandler {
}); });
}); });
this._owner.onSkillResult(reslst); this._owner.onSkillResultNotify(reslst);
}; };
resetTotalCard(){ resetTotalCard(){