xy-server/game/object/EquipMgr.ts
2025-04-23 09:34:08 +08:00

779 lines
33 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import GameUtil from "../core/GameUtil";
import PlayerMgr from "./PlayerMgr";
import Player from "./Player";
import SKDataUtil from "../gear/SKDataUtil";
import SKLogger from "../gear/SKLogger";
import Equip from "./Equip";
import {EAttrTypeL1, EEquipPos, EEquipType, MsgCode} from "../role/EEnum";
import DB from "../utils/DB";
export default class EquipMgr {
static shared = new EquipMgr();
shenbingData: any;
xianqiData: any;
equipDBTimer: any;
xinshouData: any;
highData: any;
highAttrData: any;
lianhuaData: any;
equipObjs: any;
shopObjs: any;
lianhuaArr: any;
// uuidMap: Map<string,any>;
constructor() {
this.shenbingData = null;
this.xianqiData = null;
this.equipDBTimer = null;
// this.uuidMap = new Map<string, any>();
}
launch() {
this.shenbingData = GameUtil.require_ex('../../conf/prop_data/prop_shenbing');
this.xianqiData = GameUtil.require_ex('../../conf/prop_data/prop_xianqi');
let conf = GameUtil.game_conf.baldric;
for (let key in conf) {
this.xianqiData[key] = conf[key];
}
this.xinshouData = GameUtil.require_ex('../../conf/prop_data/prop_xinshou_equip');
this.highData = GameUtil.require_ex('../../conf/prop_data/prop_high_equip');
this.highAttrData = GameUtil.require_ex('../../conf/prop_data/prop_high_equip_attr');
this.lianhuaData = GameUtil.require_ex('../../conf/prop_data/prop_lianhua');
this.equipObjs = {};
this.shopObjs = {};
this.lianhuaArr = {};
for (let index = 0; index < 10; index++) {
this.lianhuaArr[index + 1] = [];
}
for (let key in this.lianhuaData) {
if (this.lianhuaData.hasOwnProperty(key)) {
let info = this.lianhuaData[key];
for (let index = 0; index < 10; index++) {
if (info[`pos${index + 1}`].length > 0) {
info.key = key;
this.lianhuaArr[index + 1].push(info);
}
}
}
}
// let callback = (ret: any, item: any) => {
// if (ret == MsgCode.SUCCESS) {
// for (let key in item) {
// this.uuidMap.set(item[key].EquipID, item[key].EquipID);
// }
// }
// callback = null;
// }
// DB.equipKey(callback);
SKLogger.debug('装备模块加载完毕!');
}
addEquip(equip: any) {
this.equipObjs[equip.EquipID] = equip;
}
delEquip(equipid: any) {
delete this.equipObjs[equipid];
}
getEquipByID(equipid: any) {
return this.equipObjs[equipid];
}
getXianQiBy(equipId: string) {
return this.xianqiData[equipId];
}
sellEquip(equipid: any) {
let equip = this.equipObjs[equipid];
if (equip) {
equip.state = 2;
this.shopObjs[equip.EquipID] = equip;
return true;
}
return false;
}
buyEquip(equipid: any) {
let equip = this.shopObjs[equipid];
if (equip) {
equip.state = 1;
delete this.shopObjs[equipid];
return true;
}
return false;
}
getSellList(): any {
let list = [];
for (const key in this.shopObjs) {
if (this.shopObjs.hasOwnProperty(key)) {
const equip = this.shopObjs[key];
list.push({
Shape: equip.Shape,
EquipID: equip.EquipID,
EIndex: equip.EIndex,
EName: equip.EName,
OwnerRoleId: equip.OwnerRoleId
});
}
}
return SKDataUtil.toJson(list,"[]");
}
save() {
for (let key in this.equipObjs) {
if (this.equipObjs.hasOwnProperty(key)) {
let equip = this.equipObjs[key];
equip.save();
}
}
}
// 获得佩饰基础属性-4条
getBaldricBaseAttr(pos: number, level: number): any[] {
// 基础属性:戒指・右同戒指・左
if (pos == 12) {
pos = 10;
}
let attr = this.lianhuaArr[pos];
let result: any[] = [];
if (attr == null) {
return result;
}
let factor = 0;
if (level == 1) factor = 0.3;
if (level == 2) factor = 0.5;
for (let index = 0; index < 4; index++) {
let info = attr[Math.floor(Math.random() * attr.length)];
let valuearr = info[`pos${pos}`].split(',');
let deltaValue = Number(valuearr[1]) - Number(valuearr[0]);
let randValue = Math.random() * deltaValue * 0.2 + deltaValue * factor;
let type = GameUtil.attrEquipTypeStr[info.key];
let fvalue = Number(valuearr[0]) + randValue;
let value = parseInt(String(fvalue));
let item: any = {};
item[type] = value;
result.push(item);
}
return result;
}
getLianhuaData(pos: any, level: any):any[]{
let lianhualist = [];
for(let i = 0; i < 6; i++){
let arr = this.lianhuaArr[pos];
let cnt = Math.floor(Math.random() * 5) + 1;
let lianhuaAttr = [];
let factor = 0;
if (level == 1) factor = 0.3;
if (level == 2) factor = 0.5;
for (let index = 0; index < cnt; index++) {
if (!arr) {
SKLogger.warn(`$警告:${pos},${level}`);
continue;
}
let info = arr[Math.floor(Math.random() * arr.length)];
let valuearr = info[`pos${pos}`].split(',');
let deltaValue = Number(valuearr[1]) - Number(valuearr[0]);
let randValue = Math.random() * deltaValue * 0.5 + deltaValue * factor;
let fvalue = Number(valuearr[0]) + randValue;
let attrtype = GameUtil.attrEquipTypeStr[info.key];
let oneinfo: any = {};
oneinfo[attrtype] = parseInt(String(fvalue));
lianhuaAttr.push(oneinfo);
}
lianhualist.push(lianhuaAttr)
}
return lianhualist;
}
/**翅膀炼化数据 */
getWingLianhuaData(): any[] {
let arr = ['PhyDef', 'VoidRate', 'AtkPercent', 'HpPer', 'Basecon', 'Wakan', 'Power', 'Agility'];
let cnt = 5;
let lianhuaAttr = [];
let factor = 0.8;
for (let index = 0; index < cnt; index++) {
let info = arr[Math.floor(Math.random() * arr.length)];
let valuearr1 = GameUtil.random(20, 40);
//值2
let valuearr2 = GameUtil.random(1, 20);
let deltaValue = valuearr1 - valuearr2;
let randValue = Math.random() * deltaValue * 0.5 + deltaValue * factor;
let fvalue = valuearr2 + randValue;
let attrtype = GameUtil.attrEquipTypeStr[info];
let oneinfo: any = {};
oneinfo[attrtype] = parseInt(String(fvalue));
lianhuaAttr.push(oneinfo);
}
return lianhuaAttr;
}
//超级九彩
getMaxLianhuaData(pos: any, level: any):any[]{
let arr = this.lianhuaArr[pos];
let cnt = 5;
let count = 0;
let kattr = 0;
let lianhuaAttr = [];
let factor = 0.8;
for (let index = 0; index < cnt; index++) {
if (!arr) {
SKLogger.warn(`$警告:${pos},${level}`);
continue;
}
let info = arr[Math.floor(Math.random() * arr.length)];
let valuearr = info[`pos${pos}`].split(',');
let deltaValue = Number(valuearr[1]) - Number(valuearr[0]);
let randValue = Math.random() * deltaValue * 0.5 + deltaValue * factor;
let fvalue = Number(valuearr[0]) + randValue;
let attrtype = GameUtil.attrEquipTypeStr[info.key];
if(kattr == 0){
kattr = attrtype;
}
count++;
if(count <= 3 && attrtype != kattr){
cnt++;
count--;
continue;
}
let oneinfo: any = {};
oneinfo[attrtype] = parseInt(String(fvalue));
lianhuaAttr.push(oneinfo);
}
return lianhuaAttr;
}
getBaldricRecast(equip: Equip): any {
let data = this.xianqiData[equip.Type];
if (data == null) {
return null;
}
let result = this.getEquipArr(data, equip.EquipType);
return result;
}
/**info
* type 装备类型0:新手装备1:高级装备2:神兵3:仙器
* resid 对应表里的Type默认0
* grade 等级默认0
* ower 装备角色
* pos 装备位置
*/
getRecastData(info: any) {
let p = info.role;
let dataAttr = null;
if (info.type == 1) {
dataAttr = this.highData;
}
else if (info.type == 3 || info.type == 5) {
dataAttr = this.xianqiData;
}
else {
//return;
return null;
}
// let recastInfo = null;
// let baseInfo: any = {};
let datalist = [];
for (let key in dataAttr) {
if (dataAttr.hasOwnProperty(key)) {
let data = dataAttr[key];
if (data.OwnerRoleId && data.OwnerRoleId > 0 && data.OwnerRoleId != p.resid) {
continue;
}
if ((data.Race == p.race || data.Race == 9) && (data.Sex == p.sex || data.Sex == 9) && (data.Index == info.pos || info.pos == 0) && data.Type != info.resid) {
if (info.grade != 0 && info.grade != data.Grade) {
continue;
}
// for(let i = 0; i < 4; i++){
// if(data.Race == 1){
// if(data.Index == 1){ //武器
// if(i < 2){
// let rand = Math.floor(Math.random() * 4);
// baseInfo[GameUtil.attrEquipRenHuShi[rand]] = this.getValueForRecast(GameUtil.attrEquipRenHuShi[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 8);
// baseInfo[GameUtil.attrEquipWeapon[rand]] = this.getValueForRecast(GameUtil.attrEquipWeapon[rand],data.Grade);
// }
// }
// if(data.Index == 3 || data.Index == 4){ //衣服或帽子
// if(i < 2){
// let rand = Math.floor(Math.random() * 4);
// baseInfo[GameUtil.attrEquipRenHuShi[rand]] = this.getValueForRecast(GameUtil.attrEquipRenHuShi[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 12);
// baseInfo[GameUtil.attrEquipKangXing[rand]] = this.getValueForRecast(GameUtil.attrEquipKangXing[rand],data.Grade);
// }
// }
// }
// if(data.Race == 2){ //仙族
// if(data.Index == 1){ //武器
// if(i < 2){
// let rand = Math.floor(Math.random() * 4);
// baseInfo[GameUtil.attrEquipXianHuShi[rand]] = this.getValueForRecast(GameUtil.attrEquipXianHuShi[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 8);
// baseInfo[GameUtil.attrEquipWeapon[rand]] = this.getValueForRecast(GameUtil.attrEquipWeapon[rand],data.Grade);
// }
// }
// if(data.Index == 3 || data.Index == 4){ //衣服或帽子
// if(i < 2){
// let rand = Math.floor(Math.random() * 4);
// baseInfo[GameUtil.attrEquipXianHuShi[rand]] = this.getValueForRecast(GameUtil.attrEquipXianHuShi[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 12);
// baseInfo[GameUtil.attrEquipKangXing[rand]] = this.getValueForRecast(GameUtil.attrEquipKangXing[rand],data.Grade);
// }
// }
// }
// if(data.Race == 3){ //魔族
// if(data.Index == 1){ //武器
// if(i < 2){
// let rand = Math.floor(Math.random() * 4);
// baseInfo[GameUtil.attrEquipMoHuShi[rand]] = this.getValueForRecast(GameUtil.attrEquipMoHuShi[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 8);
// baseInfo[GameUtil.attrEquipWeapon[rand]] = this.getValueForRecast(GameUtil.attrEquipWeapon[rand],data.Grade);
// }
// }
// if(data.Index == 3 || data.Index == 4){ //衣服或帽子
// if(i < 2){
// let rand = Math.floor(Math.random() * 4);
// baseInfo[GameUtil.attrEquipMoHuShi[rand]] = this.getValueForRecast(GameUtil.attrEquipMoHuShi[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 12);
// baseInfo[GameUtil.attrEquipKangXing[rand]] = this.getValueForRecast(GameUtil.attrEquipKangXing[rand],data.Grade);
// }
// }
// }
// if(data.Race == 4){ //鬼族
// if(data.Index == 1){ //武器
// if(i < 2){
// let rand = Math.floor(Math.random() * 3);
// baseInfo[GameUtil.attrEquipGuiHuShi[rand]] = this.getValueForRecast(GameUtil.attrEquipGuiHuShi[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 8);
// baseInfo[GameUtil.attrEquipWeapon[rand]] = this.getValueForRecast(GameUtil.attrEquipWeapon[rand],data.Grade);
// }
// }
// if(data.Index == 3 || data.Index == 4){ //衣服或帽子
// if(i < 2){
// let rand = Math.floor(Math.random() * 3);
// baseInfo[GameUtil.attrEquipGuiHuShi[rand]] = this.getValueForRecast(GameUtil.attrEquipGuiHuShi[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 12);
// baseInfo[GameUtil.attrEquipKangXing[rand]] = this.getValueForRecast(GameUtil.attrEquipKangXing[rand],data.Grade);
// }
// }
// }
// if(data.Race == 5){ //龙族
// if(data.Index == 1){ //武器
// if(i < 2){
// let rand = Math.floor(Math.random() * 4);
// baseInfo[GameUtil.attrEquipLong[rand]] = this.getValueForRecast(GameUtil.attrEquipLong[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 8);
// baseInfo[GameUtil.attrEquipWeapon[rand]] = this.getValueForRecast(GameUtil.attrEquipWeapon[rand],data.Grade);
// }
// }
// if(data.Index == 3 || data.Index == 4){ //衣服或帽子
// if(i < 2){
// let rand = Math.floor(Math.random() * 4);
// baseInfo[GameUtil.attrEquipLong[rand]] = this.getValueForRecast(GameUtil.attrEquipLong[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 12);
// baseInfo[GameUtil.attrEquipKangXing[rand]] = this.getValueForRecast(GameUtil.attrEquipKangXing[rand],data.Grade);
// }
// }
// }
// if(data.Race == 9){
// if(data.Index == 2){ //项链
// if(i > 1){
// let rand = Math.floor(Math.random() * 6);
// baseInfo[GameUtil.attrEquipTorque[rand]] = this.getValueForRecast(GameUtil.attrEquipTorque[rand],data.Grade);
// }else{
// let rand = Math.floor(Math.random() * 12);
// baseInfo[GameUtil.attrEquipKangXing[rand]] = this.getValueForRecast(GameUtil.attrEquipKangXing[rand],data.Grade);
// }
// }
// if(data.Index == 5){ //鞋
// if(i < 2){
// let rand = Math.floor(Math.random() * 14);
// baseInfo[GameUtil.attrEquipShose[rand]] = this.getValueForRecast(GameUtil.attrEquipShose[rand],data.Grade);
// }
// }
// }
// }
//recastInfo = data;
//break
datalist.push(data);
}
}
}
// if (recastInfo == null) {
// return null;
// }
// let result = this.getEquipArr(recastInfo, baseInfo, info.type);
// return result;
if (datalist.length == 0) {
return null;
}
let recastdata = datalist[Math.floor(Math.random() * datalist.length)];
let result = this.getEquipArr(recastdata, info.type);
return result;
}
/**info
* type 装备类型0:新手装备1:高级装备2:神兵3:仙器, 4:翅膀
* resid 对应表里的Type默认0
* index 装备位置默认0
* grade 等级默认0
*/
getEquipRes(info: any, resData: any, player: Player): any {
if (info.resid && info.resid != 0) {
let result = resData[info.resid];
if (result) {
return result;
}
}
let datalist = [];
for (let key in resData) {
if (resData.hasOwnProperty(key)) {
let data = resData[key];
if (player) {
if (data.OwnerRoleId && data.OwnerRoleId > 0 && data.OwnerRoleId != player.resid) {
continue;
}
if ((data.Race == player.race || data.Race == 9) && (data.Sex == player.sex || data.Sex == 9) && (data.Index == info.index || info.index == 0)) {
if (info.grade != 0 && info.grade != data.Grade) {
continue;
}
datalist.push(data);
}
}
}
}
if (datalist.length > 0) {
return datalist[Math.floor(Math.random() * datalist.length)];
}
else {
return null;
}
}
getXianQiList(info: any): any[] {
let player = PlayerMgr.shared.getPlayerByRoleId(info.roleid);
if (player == null) {
return null;
}
info.type = 3;
info.grade = 1;
let list = [];
for (let index = 0; index < 5; index++) {
info.index = index + 1;
list.push(this.getEquipData(info));
}
return list;
}
makeEquipAttr(equipInfo: any) {
if (equipInfo.resid == null) {
equipInfo.resid = 0;
}
if (equipInfo.grade == null) {
equipInfo.grade = 1;
}
let equipAttr: any = this.getEquipData(equipInfo);
if (!equipAttr) {
SKLogger.warn(`装备属性生成失败:${equipInfo.resid}`);
return null;
}
equipAttr.EquipID = this.getEquipID();
return equipAttr;
}
getEquipID() {
let flag = true;
let uuid: string = "";
let count = 0;
// while (flag) {
uuid = SKDataUtil.primaryKey() + SKDataUtil.rolePrimaryKey(10);
// // 判断主键是否存在,不存在则返回
// let value = this.uuidMap.get(uuid);
// if (value == undefined || value == null) {
// flag = false;
// this.uuidMap.set(uuid, uuid);
// }
// // 连续五次重复自动根据随机数加字符生成主键
// else if(count > 5){
// flag = false;
// uuid = Math.random().toString(16).substr(2);
// this.uuidMap.set(uuid, uuid);
// SKLogger.info(`生成UUID失败本次生成主键${uuid}`);
// }
// }
return uuid;
}
getEquipData(info: any): any {
let player = null;
if (info.roleid != null) {
player = PlayerMgr.shared.getPlayerByRoleId(info.roleid);
if (player == null) {
SKLogger.warn(`装备数据:玩家${info.roleid}不存在`);
return null;
}
}
let equipInfo = null;
// 装备类型0:新手装备1:高级装备2:神兵3:仙器 4:翅膀, 5:配饰
if (info.type == EEquipType.XinShou) { //新手装备
equipInfo = this.getEquipRes(info, this.xinshouData, player);
} else if (info.type == EEquipType.HIGH) {//高级装备
equipInfo = this.getEquipRes(info, this.highData, player);
} else if (info.type == EEquipType.ShenBing) {//神兵
equipInfo = this.getEquipRes(info, this.shenbingData, player);
} else if (info.type == EEquipType.XianQi) {//仙器
equipInfo = this.getEquipRes(info, this.xianqiData, player);
} else if (info.type == EEquipType.WING) { // 翅膀
equipInfo = this.getEquipRes(info, this.xianqiData, player);
} else if (info.type == EEquipType.BALDRIC) { // 佩饰
equipInfo = this.getEquipRes(info, this.xianqiData, player);
} else {
SKLogger.warn(`$警告:获得装备数据类型错误:${info.type}`);
}
if (!equipInfo) {
return null;
}
let result = this.getEquipArr(equipInfo, info.type);
return result;
}
getHighRndRange(rangestr: any) {
if (rangestr == null) {
return 1;
}
if (rangestr.endsWith(';')) {
rangestr = rangestr.substr(0, rangestr.length - 1);
}
let rangelist = rangestr.split(';');
let rndvalue = Math.random() * 100;//用来计算阶梯概率
if (rangelist.length == 0) {
return 1;
}
let rangevaluelist = [];//每条记录里存三个数,最小,最大,阶梯概率
for (const valuestr of rangelist) {
if (valuestr.split(',').length != 3) {
return 1;
}
rangevaluelist.push(valuestr.split(','));
}
let minrndvalue = 1;//当前概率的最小值
let maxrndvalue = 100;//当前概率的最大值
let startvalue = 0;//阶梯概率初始位置
for (let index = 0; index < rangevaluelist.length; index++) {
let v = Number(rangevaluelist[index][2]);
if (rndvalue >= startvalue && rndvalue <= startvalue + v) {
minrndvalue = Number(rangevaluelist[index][0]);
maxrndvalue = Number(rangevaluelist[index][1]);
break;
}
startvalue += v;
}
return minrndvalue + Math.floor(Math.random() * (maxrndvalue - minrndvalue));
}
getHighBaseArr(lib: any, factor: any) { //获得高级装备的基础属性
let baseAttr: any = {};
let libarr = lib.split(',');
for (const lib of libarr) {
if (this.highAttrData[lib] == null) {
continue;
}
let basestr = this.highAttrData[lib].BaseAttr;
if (!baseAttr) {
continue;
}
if (basestr.endsWith(';')) {
basestr = basestr.substr(0, basestr.length - 1);
}
let baselist = basestr.split(';');
if (baselist.length == 0) {
continue;
}
let curbase = baselist[Math.floor(Math.random() * baselist.length)];
let curbasearr = curbase.split(',');
if (curbasearr.length != 3) {
continue;
}
let curkey = curbasearr[0];
let curminvalue = Number(curbasearr[1]);
let curmaxvalue = Number(curbasearr[2]);
let rndrange = this.getHighRndRange(this.highAttrData[lib].RndRange);
let curvalue = curminvalue + Math.floor(rndrange * (curmaxvalue - curminvalue) / 100);
baseAttr[GameUtil.attrEquipTypeStr[curkey]] = Math.floor(curvalue * factor);
}
return baseAttr;
}
// 获得装备属性
getEquipArr(equipInfo: any, type: number): any {
let result: any = {};
result['BaseAttr'] = '{}';
result['Shuxingxuqiu'] = '{}';
result['BaseScore'] = 0;
result['EDesc'] = '';
result['Detail'] = '';
result['Dynamic'] = 0;
result['Grade'] = 0;
result['EIndex'] = 0;
result['JiLv'] = 0;
result['MaxEmbedGemCnt'] = 0;
result['MaxEndure'] = 0;
result['EName'] = '';
result['NeedGrade'] = 0;
result['NeedRei'] = 0;
result['NextType'] = 0;
result['Overlap'] = 0;
result['Quan'] = '';
result['Race'] = 0;
result['Rarity'] = 0;
result['RndRange'] = '';
result['RndWeight'] = 0;
result['Sex'] = 0;
result['Shape'] = '';
result['Type'] = 0;
result['OwnerRoleId'] = 0;
result['EquipType'] = type;
if (type == EEquipType.HIGH) {
if (equipInfo.AttrLib && equipInfo.AttrFactor) {
result['BaseAttr'] = SKDataUtil.toJson(this.getHighBaseArr(equipInfo.AttrLib, equipInfo.AttrFactor),"{}");
}
} else if (type == EEquipType.BALDRIC) {
result['BaseAttr'] = SKDataUtil.toJson(this.getBaldricBaseAttr(equipInfo.Index, equipInfo.Grade - 1),"{}");
} else {
// if (baseData) {
// result['BaseAttr'] = SKDataUtil.toJson(baseData,"{}");
// }
if (equipInfo.BaseAttr) {
let baseInfo: any = {};
let baseAttr = equipInfo.BaseAttr.split(';');
for (const item of baseAttr) {
let itemAttr = item.split(':');
if (itemAttr.length == 2 && GameUtil.attrEquipTypeStr[itemAttr[0]] != null) {
baseInfo[GameUtil.attrEquipTypeStr[itemAttr[0]]] = itemAttr[1];
}
}
result['BaseAttr'] = SKDataUtil.toJson(baseInfo,"{}");
}
}
if (equipInfo.Shuxingxuqiu) {
let xuqiuinfo: any = {};
let xuqiuarr = equipInfo.Shuxingxuqiu.split(':');
if (xuqiuarr.length == 2 && GameUtil.attrEquipTypeStr[xuqiuarr[0]] != null) {
xuqiuinfo[GameUtil.attrEquipTypeStr[xuqiuarr[0]]] = xuqiuarr[1];
}
result['Shuxingxuqiu'] = SKDataUtil.toJson(xuqiuinfo,"{}");
}
if (equipInfo.NeedAttr) {
let xuqiuinfo: any = {};
let xuqiuarr = equipInfo.NeedAttr.split(':');
if (xuqiuarr.length == 2 && GameUtil.attrEquipTypeStr[xuqiuarr[0]] != null) {
xuqiuinfo[GameUtil.attrEquipTypeStr[xuqiuarr[0]]] = xuqiuarr[1];
}
result['Shuxingxuqiu'] = SKDataUtil.toJson(xuqiuinfo,"{}");
}
equipInfo.BaseScore && (result['BaseScore'] = equipInfo.BaseScore);
equipInfo.Desc && (result['EDesc'] = equipInfo.Desc);
equipInfo.Detail && (result['Detail'] = equipInfo.Detail);
equipInfo.Dynamic && (result['Dynamic'] = equipInfo.Dynamic);
equipInfo.Grade && (result['Grade'] = equipInfo.Grade);
equipInfo.Index && (result['EIndex'] = equipInfo.Index);
equipInfo.JiLv && (result['JiLv'] = equipInfo.JiLv);
equipInfo.MaxEmbedGemCnt && (result['MaxEmbedGemCnt'] = equipInfo.MaxEmbedGemCnt);
equipInfo.MaxEndure && (result['MaxEndure'] = equipInfo.MaxEndure);
equipInfo.Name && (result['EName'] = equipInfo.Name);
equipInfo.NeedGrade && (result['NeedGrade'] = equipInfo.NeedGrade);
equipInfo.NeedRei && (result['NeedRei'] = equipInfo.NeedRei);
equipInfo.NextType && (result['NextType'] = equipInfo.NextType);
equipInfo.Overlap && (result['Overlap'] = equipInfo.Overlap);
equipInfo.Quan && (result['Quan'] = equipInfo.Quan);
equipInfo.Race && (result['Race'] = equipInfo.Race);
equipInfo.Rarity && (result['Rarity'] = equipInfo.Rarity);
equipInfo.RndRange && (result['RndRange'] = equipInfo.RndRange);
equipInfo.RndWeight && (result['RndWeight'] = equipInfo.RndWeight);
equipInfo.Sex && (result['Sex'] = equipInfo.Sex);
equipInfo.Shape && (result['Shape'] = equipInfo.Shape);
equipInfo.Type && (result['Type'] = equipInfo.Type);
equipInfo.OwnerRoleId && (result['OwnerRoleId'] = equipInfo.OwnerRoleId);
return result;
}
getInsertData(equipArr: any, roleid: any): any {
if (!equipArr) {
return null;
}
let fieldstr = 'EquipID, EquipType, BaseAttr, Grade, EIndex, Shuxingxuqiu, Type, GemCnt, LianhuaAttr, RoleID, create_time, pos, BaseScore';
let valuestr = `'${equipArr.EquipID}', ${equipArr.EquipType}, '${equipArr.BaseAttr}', ${equipArr.Grade}, ${equipArr.EIndex}, '${equipArr.Shuxingxuqiu}', ${equipArr.Type}, 0, '{}', ${roleid}, NOW(), ${EEquipPos.BAG}, ${equipArr.BaseScore}`;
let data: any = {};
data.fieldstr = fieldstr;
data.valuestr = valuestr;
return data;
}
getValueForRecast(key: any,grade: any){
let Numerical = GameUtil.equipTypeNumerical; //不用进行百分比计算的属性
let score = 15; //一阶属性上限
if(key < 12){ // 如果是抗性属性
score = 30;
}
if(grade > 1){ //仙器品阶
if(key < 12){ //抗性
score = 30 + ((grade - 1) * 5);
}else{
score = 15 + ((grade - 1) * 3);
}
}
for(let zhi in Numerical){
if(key == Numerical[zhi]){
if(Numerical[zhi] == EAttrTypeL1.ATK){ //攻击
score = 3000;
if(grade > 1){
score = 3000 + ((grade - 1) * 1000);
}
}
if(Numerical[zhi] == EAttrTypeL1.HP_MAX || Numerical[zhi] == EAttrTypeL1.MP_MAX ){ //气血和发力
score = 5040;
if(grade > 1){
score = 5040 + ((grade - 1) * 1050);
}
}
if(Numerical[zhi] == EAttrTypeL1.SPD){ // 速度
score = 87;
if(grade > 1){
score = 87 + ((grade - 1) * 40);
}
}
let rand = Math.floor(GameUtil.random((score / 2),score))
if(rand == 0){
rand = 1;
}
return rand;
}
}
let rand = Math.floor(GameUtil.random((score / 2),score)) * 10 + Math.floor(Math.random() * 10);
if(rand == 0){
rand = 1;
}
return rand;
}
}