187 lines
3.4 KiB
TypeScript
187 lines
3.4 KiB
TypeScript
import LivingThing from "./LivingThing";
|
|
import SKDataUtil from "../gear/SKDataUtil";
|
|
import GameUtil from "../core/GameUtil";
|
|
import {EAttrTypeL1, Operate} from "../role/EEnum";
|
|
import SKLogger from "../gear/SKLogger";
|
|
import SKCxfUtil from "../gear/SKCxfUtil";
|
|
import PlayerMgr from "../object/PlayerMgr";
|
|
import PaiHangMgr from "../core/PaiHangMgr";
|
|
|
|
export default class BattleObj extends LivingThing {
|
|
roleid: number;
|
|
dataid: number;
|
|
hp: number;
|
|
mp: number;
|
|
maxhp: number;
|
|
maxmp: number;
|
|
exp: number=0;
|
|
maxexp: number;
|
|
level: number;
|
|
relive: number;
|
|
atk: number;
|
|
spd: number;
|
|
attr1: {[key:string]:number};
|
|
addattr1: any;
|
|
addattr2: any;
|
|
qianneng: number;
|
|
skill_list: any={};
|
|
buff_list: any;
|
|
ownid: number;
|
|
default_btl_skill: number;
|
|
nFuBenID: any;
|
|
bangid: any;
|
|
|
|
constructor() {
|
|
super();
|
|
this.dataid = 0;
|
|
// 血 蓝
|
|
this.hp = 0;
|
|
this.mp = 0;
|
|
this.maxhp = 0;
|
|
this.maxmp = 0;
|
|
// 经验
|
|
this.exp = 0;
|
|
this.maxexp = 0;
|
|
this.level = 0;
|
|
this.relive = 0;//转生
|
|
// 攻击 速度
|
|
this.atk = 0;
|
|
this.spd = 0;
|
|
// 属性
|
|
this.attr1 = {};
|
|
this.addattr1 = {};
|
|
for (let key in EAttrTypeL1) {
|
|
let value = SKDataUtil.numberBy(key);
|
|
if (isNaN(value)) {
|
|
continue;
|
|
}
|
|
this.attr1[value] = 0;
|
|
this.addattr1[value] = 0;
|
|
}
|
|
// 潜能二级属性
|
|
this.addattr2 = {};
|
|
for (let key in EAttrTypeL1) {
|
|
let value = SKDataUtil.numberBy(key);
|
|
if (isNaN(value)) {
|
|
continue;
|
|
}
|
|
this.addattr2[value] = 0;
|
|
}
|
|
// 潜能
|
|
this.qianneng = 0;
|
|
// 技能列表
|
|
this.skill_list = {};
|
|
// buff列表
|
|
this.buff_list = {};
|
|
// 从属关系
|
|
this.ownid = 0;
|
|
// 战斗默认技能
|
|
this.default_btl_skill = 0;
|
|
this.roleid = 0;
|
|
}
|
|
|
|
setAttr1(attrtype: any, num: any) {
|
|
this.attr1[attrtype] = num;
|
|
}
|
|
|
|
getAttr1(attrtype: any): any {
|
|
return this.attr1[attrtype];
|
|
}
|
|
|
|
setAddAttr2(attrtype: any, num: any) {
|
|
this.addattr2[attrtype] = num;
|
|
}
|
|
|
|
getAddAttr2(attrtype: any): any {
|
|
return this.addattr2[attrtype];
|
|
}
|
|
|
|
getBtlAttr(): any {
|
|
try {
|
|
SKDataUtil.clone(this.attr1)
|
|
}catch (error){
|
|
SKLogger.warn(`战斗数据错误:[${this.attr1}]`);
|
|
}
|
|
return SKDataUtil.clone(this.attr1);
|
|
}
|
|
|
|
getSkillList(): any {
|
|
return this.skill_list;
|
|
}
|
|
|
|
addExp(exp: number) {
|
|
let fexp = this.exp + exp;
|
|
if (this.maxexp > 0) {
|
|
while (fexp >= this.maxexp) {
|
|
fexp -= this.maxexp;
|
|
this.levelUp(fexp < this.maxexp);
|
|
}
|
|
}
|
|
this.exp = fexp;
|
|
}
|
|
|
|
setLevel(level: any, issend: any) {
|
|
this.level = level;
|
|
}
|
|
|
|
levelUp(issend: any) {
|
|
let nextlevel = this.level + 1;
|
|
this.setLevel(nextlevel, issend);
|
|
//cxf等级改变
|
|
SKCxfUtil.getCxfRecordOperate({
|
|
roleId: this.roleid,
|
|
roleName: this.name,
|
|
operateType: Operate.EXP,
|
|
operateDepict: "等级改变",
|
|
operateResSerial: "",
|
|
operateResName: "",
|
|
operateContent: `当前等级:${this.relive}转${this.level}级,经验为:${this.exp}`
|
|
});
|
|
|
|
if (this.relive >= 1){
|
|
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
|
|
if (player){
|
|
player.cxfSavePlayerAll();
|
|
}
|
|
}
|
|
}
|
|
|
|
calculatePointAttr() {
|
|
|
|
}
|
|
|
|
calculateEquipAttr() {
|
|
|
|
}
|
|
|
|
calculateLevel() {
|
|
|
|
}
|
|
|
|
calculateReliveAttr() {
|
|
|
|
}
|
|
|
|
calculateXiuAttr() {
|
|
|
|
}
|
|
|
|
calculateZhenfaAttr(){
|
|
|
|
}
|
|
|
|
calculateStarAttr(){
|
|
|
|
}
|
|
|
|
calculateAttr() {
|
|
GameUtil.clearAllAttr(this.attr1);
|
|
this.calculatePointAttr();
|
|
this.calculateEquipAttr();
|
|
this.calculateStarAttr();
|
|
this.calculateLevel();
|
|
this.calculateReliveAttr();
|
|
this.calculateXiuAttr();
|
|
this.calculateZhenfaAttr();
|
|
}
|
|
} |