68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
// Learn cc.Class:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
|
|
// Learn Attribute:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
import { PlayerHandler } from "../Handler/PlayerHandler";
|
|
import { CondType, CondDecideType } from "./SkillConst";
|
|
|
|
export class Condition {
|
|
public _type: number;
|
|
public _cdt: CondDecideType;
|
|
public _v: number;
|
|
|
|
public init(cond_type: CondType, cond_dt: CondDecideType, cond_value: number){
|
|
this._type = cond_type;
|
|
this._cdt = cond_dt;
|
|
this._v = cond_value;
|
|
};
|
|
|
|
public isOK(tg_value: any, tg_owner: PlayerHandler){
|
|
if(this._type == CondType.NO_COND){
|
|
return true;
|
|
}
|
|
let v;
|
|
switch (this._type) {
|
|
case CondType.CARD_COUNT_CURR:
|
|
v = tg_owner.getCurrCardCount();
|
|
return this._isok(v,this._v,this._cdt);
|
|
case CondType.CARD_COUNT_TOTAL:
|
|
v = tg_owner.getTotalCardCount(this._cdt, this._v);
|
|
return this._isok(v,this._v,this._cdt);
|
|
case CondType.CARD_ACTION_LINK_OTHER:
|
|
return !!tg_value;
|
|
case CondType.CARD_ACTION_LINK_SELF:
|
|
return !tg_value;
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
};
|
|
|
|
private _isok(realv: number, cfgv: number, dt: CondDecideType){
|
|
switch(dt){
|
|
case CondDecideType.NO_DECIDE:
|
|
return true;
|
|
case CondDecideType.LESS:
|
|
return realv < cfgv;
|
|
case CondDecideType.GREATER:
|
|
return realv > cfgv;
|
|
case CondDecideType.EQUAL:
|
|
return realv == cfgv;
|
|
default:
|
|
return false;
|
|
}
|
|
};
|
|
|
|
public isTempTotalCard(){
|
|
return this._type == CondType.CARD_COUNT_TOTAL;
|
|
};
|
|
};
|
|
|
|
// module.exports = Condition;
|