增加接口
This commit is contained in:
parent
e10852fc94
commit
acfe8c7e50
@ -32,6 +32,13 @@ export class BattleHandler {
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
@ -156,6 +163,7 @@ export class BattleHandler {
|
||||
return lst;
|
||||
};
|
||||
|
||||
//--------------------对外接口(外部调用)----------------------------
|
||||
/**
|
||||
* 使用卡片
|
||||
* @param obj
|
||||
@ -285,6 +293,19 @@ export class BattleHandler {
|
||||
ph && ph.onRoundEnd();
|
||||
};
|
||||
|
||||
/**
|
||||
* 玩家死亡
|
||||
* @param aplayer
|
||||
*/
|
||||
public onPlayerDead(aplayer: Player){
|
||||
let ph = this.getPlayer(aplayer);
|
||||
ph && ph.die();
|
||||
};
|
||||
|
||||
// end--------------------------------------------------
|
||||
|
||||
|
||||
// --------------------调用外部接口函数--------------------------
|
||||
public onAddPetNotify(apet: PetHandler){
|
||||
return this._room.bAddPet(apet.exportData());
|
||||
};
|
||||
@ -293,15 +314,15 @@ export class BattleHandler {
|
||||
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);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
public onSkillResult(skillres: SkillTarget[]){
|
||||
public onSkillResultNotify(skillres: SkillTarget[]){
|
||||
if(!skillres || skillres.length <= 0){
|
||||
return;
|
||||
}
|
||||
@ -310,5 +331,10 @@ export class BattleHandler {
|
||||
lst.push(item.exportData());
|
||||
});
|
||||
this._room.bMsgQueue(lst);
|
||||
};
|
||||
|
||||
public onPlayerAddHPNotify(aplayer: PlayerHandler, addhp: number){
|
||||
return addhp;
|
||||
}
|
||||
//end------------------------------------------------
|
||||
}
|
||||
|
@ -189,23 +189,19 @@ export class PlayerHandler {
|
||||
};
|
||||
|
||||
public addCard(count: number){
|
||||
return this._owner.onPlayerAddCard(this, count, 0);
|
||||
return this._owner.onPlayerAddCardNotify(this, count, 0);
|
||||
};
|
||||
|
||||
public addCardLimit(maxcount: number){
|
||||
return this._owner.onPlayerAddCard(this, 0, maxcount);
|
||||
return this._owner.onPlayerAddCardNotify(this, 0, maxcount);
|
||||
};
|
||||
|
||||
public stealCard(dstplayer: PlayerHandler, count: number){
|
||||
return this._owner.onPlayerStealCard(this, dstplayer, count);
|
||||
return this._owner.onPlayerStealCardNotify(this, dstplayer, count);
|
||||
};
|
||||
|
||||
public addHP(value: number){
|
||||
this._player.hp += value;
|
||||
if(value < 0){
|
||||
this.die();
|
||||
}
|
||||
return value;
|
||||
return this._owner.onPlayerAddHPNotify(this, value);
|
||||
};
|
||||
|
||||
public getHP(){
|
||||
@ -230,6 +226,11 @@ export class PlayerHandler {
|
||||
|
||||
public die(){
|
||||
//todo:
|
||||
|
||||
};
|
||||
|
||||
public isDead(){
|
||||
this._player.state == 2;
|
||||
};
|
||||
|
||||
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){
|
||||
@ -270,7 +271,7 @@ export class PlayerHandler {
|
||||
});
|
||||
});
|
||||
|
||||
this._owner.onSkillResult(reslst);
|
||||
this._owner.onSkillResultNotify(reslst);
|
||||
};
|
||||
|
||||
public onHaloChanged(apet: PetHandler){
|
||||
@ -353,7 +354,7 @@ export class PlayerHandler {
|
||||
});
|
||||
});
|
||||
|
||||
this._owner.onSkillResult(reslst);
|
||||
this._owner.onSkillResultNotify(reslst);
|
||||
};
|
||||
|
||||
resetTotalCard(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user