2025-04-23 09:34:08 +08:00

8775 lines
257 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 BattleObj from "./BattleObj";
import RoleTaskMgr from "../core/RoleTaskMgr";
import PartnerMgr from "./PartnerMgr";
import RelationMgr from "./RelationMgr";
import BattleMgr from "../battle/BattleMgr";
import TeamMgr from "../core/TeamMgr";
import EquipMgr from "./EquipMgr";
import PlayerMgr from "./PlayerMgr";
import NpcMgr from "../core/NpcMgr";
import PaiHangMgr from "../core/PaiHangMgr";
import Equip from "./Equip";
import SchemeMgr from "./SchemeMgr";
import BangMgr from "../bang/BangMgr";
import ActivityMgr from "../activity/ActivityMgr";
import ActivityDefine from "../activity/ActivityDefine";
import PetMgr from "../core/PetMgr";
import ChargeSum from "../core/ChargeSum";
import BattleRole from "../battle/BattleRole";
import MonsterMgr from "../core/MonsterMgr";
import World from "./World";
import DB from "../utils/DB";
import MapMgr from "../core/MapMgr";
import PetPracticeMgr from "./PetPracticeMgr";
import PalaceFight from "../activity/PalaceFight";
import ChargeConfig from "../core/ChargeConfig";
import RolePracticeMgr from "./RolePracticeMgr";
import NpcConfigMgr from "../core/NpcConfigMgr";
import HorseList from "../horse/HorseList";
import Agent from "../network/Agent";
import Exchange from "../core/Exchange";
import HorseSkill from "../horse/HorseSkill";
import Pet from "./Pet";
import SKDataUtil from "../gear/SKDataUtil";
import Npc, { NpcCreater } from "../core/Npc";
import SkillUtil from "../skill/core/SkillUtil";
import ExpUtil from "../core/ExpUtil";
import SKLogger from "../gear/SKLogger";
import GameUtil from "../core/GameUtil";
import ItemUtil from "../core/ItemUtil";
import SkillBase from "../skill/core/SkillBase";
import SKTimeUtil from "../gear/SKTimeUtil";
import VIPUtil from "../role/VIPUtil";
import DugMgr from "../role/DugMgr";
import {
BattleType,
EActionType,
EAttrCalType,
EAttrTypeL1,
EAttrTypeL2,
EEquipPos,
EEquipType,
EEventType,
ELiveingType,
ENpcCreater,
ERaceType,
ESexType,
ESkillType,
MsgCode,
Operate
} from "../role/EEnum";
import MapModel from "../core/MapModel";
import AIMgr from "../core/AIMgr";
import RoleUtil from "../utils/RoleUtil";
import GTimer from "../common/GTimer";
import MailList from "../mail/MailList";
import JingJiChang from "../activity/JingJiChang";
import SKRedisUtil from "../gear/SKRedisUtil";
import FivePhases from "../object/FivePhases";
import ChangeCard from "../object/ChangeCard";
import DWorld from "./DWorld";
import SatAssembly from "../activity/SatAssembly";
import SKCxfUtil from "../gear/SKCxfUtil";
import BoxMgr from "../core/BoxMgr";
import SpecialEffect from "../object/SpecialEffect";
import PetSupport from "../object/PetSupport";
import MagicWeapon from "./MagicWeapon";
import Ofuda from "../object/Ofuda";
import MagicWeaponMgr from "./MagicWeaponMgr";
import FactionWar from "../activity/FactionWar";
import zhenFaMgr from "../zhenFa/zhenFa";
import ZhenFaUtil from "../core/ZhenFaUtil";
import xwManager from "../zhenFa/xwManager";
import { json } from "express";
import Baby from "./Baby";
import BabyMgr from "./BabyMgr";
import StarMgr from "./StarMgr";
import KanPo3 from "../skill/ofuda/KanPo3";
export default class Player extends BattleObj {
// 帐号索引
accountid: number = 0;
// 邀请码
invite: string = "";
// 角色编码
roleid: number = 0;
// 连接器
agent: Agent;
// 种族
race: number;
// 性别
sex: number;
// 武器
weapon: string = "";
// 状态
state: number;
// 装备列表
equip_list: any;
// 法宝列表
magic_weapon_list: any;
dir: number;
aoi_model: string;
aoi_obj_list: any;
battle_id: number;
taskMgr: RoleTaskMgr;
partnerMgr: PartnerMgr;
ZFMgr: zhenFaMgr;
XWMgr: xwManager;
money: number;
jade: number;
bind_jade: number;
bangscore: number;
shiscore: number;
discore: number;
xiuscore: number;
guoscore: number;
rewardrecord: number;
sprewardrecord: number;
curPet: any;
curPetId: number;
lastonline: any;
usingIncense: any;
loaded: boolean;
gmlevel: number;
teamid: number;
isleader: boolean;
lastWorldChatTime: number;
lastWorldChatStr: string;
nFlag: number;
offline: boolean;
offlineTimer: any;
incenseTimer: NodeJS.Timeout;
shape: number;
inPrison: boolean;
level_reward: string;
getgift: number;
getpet: number;
shuilu: any;
arena: any;
titleId: number;
titleType: number;
onLoad: boolean;
bangid: number;
bangname: string;
bangpost: number;
titles: any;
schemeName: string;
baldric: number;
color1: any;
color_one_serial: any;
color2: any;
color_two_serial: any;
safe_password: string;
safe_lock: number;
friendList: any;
applyFriendList: any;
star: number = 1;
shane: any;
titleVal: any;
equipObjs: any = {};
magicWeaponObjs: any = {};
schemeMgr: SchemeMgr;
xiulevel: number = 1;
currentEquips: Equip[] = [];
currentMagicWeapons: MagicWeapon[] = [];
listEquips: Equip[] = [];
listMagicWeapons: MagicWeapon[] = [];
petList: Pet[] = [];
bag_list: any = {};
locker_list: any = {};
relivelist: any[] = [];
lockerEquips: any[] = [];
dbData: any;
anleiCnt: any;
horseList: HorseList;
horseSkill: HorseSkill;
wingId: number;
exchange: Exchange;
onlineTime: number = 0;
// 每日限购
dayMap: any;
// 宝藏
treasure: any;
// 存档计数
saveTotal: number = 0;
// 存档失败
saveFailed: string[];
// 角色索引
roleIndex: number = 0;
// 邮件管理器
mailList: MailList;
// AI管理器
ai: AIMgr;
// 背包默认空间
bagKindNum: number;
// 仓库默认空间
lockerKindNum: number;
// 界面图标
iconList: any;
// 最后一次时使用的技能
lastSkill: number;
petLastSkill: number;
// 签到数据
daySignIn: any;
// 幸运转盘每日免费
dial_num: number = 0;
// 幸运转盘累计次数
dial_count: number = 0;
// 幸运转盘免费最后一次点击时间
dial_date: any;
// 最后一次补签时间
mendDate: any;
// 最后一次刷新任务日期
mend_date: any;
// 证道积分
sat_integral: number = 0;
// 暂离状态
pause: number;
//是否自动归队
ischeck: number;
//离线时间
offlinetime: number;
//双倍点数
doublecnt: number;
//未领取的双倍点数
unget_doublecnt: number;
// 属性状态
isFrozen: number;
ai_flag: number;
list: any[];
tianti_integral: number = 0;
//宝宝
BabyMgr: BabyMgr = new BabyMgr()
//星阵
StarMgr: StarMgr = new StarMgr(this)
constructor() {
super();
this.agent = null;
this.race = ERaceType.UNKNOW; // 种族
this.sex = ESexType.UNKNOW;
this.state = 1;
// 装备列表
this.equip_list = {};
// dir 朝向 1 2
// 4方向 3 4
this.dir = 4;
this.living_type = ELiveingType.PLAYER;
this.aoi_model = "wm";
this.aoi_obj_list = {};
this.battle_id = 0;
this.taskMgr = new RoleTaskMgr(this);
this.partnerMgr = new PartnerMgr(this);
this.ZFMgr = new zhenFaMgr(this);
this.ZFMgr.init()
this.XWMgr = new xwManager(this);
this.XWMgr.init()
this.list = []
this.money = 0;
this.jade = 0;
this.bind_jade = 0;
this.bangscore = 0;
this.shiscore = 0;
this.discore = 0;
this.xiuscore = 0;
this.guoscore = 0;
// 背包空间
this.bagKindNum = GameUtil.limitBagKindNum;
// 仓库默认空间
this.lockerKindNum = GameUtil.limitLockerKindNum;
this.rewardrecord = 0;
this.sprewardrecord = 0;
this.curPet = null;
this.curPetId = 0;
this.lastonline = null;
this.usingIncense = false;
this.loaded = false; // 是否加载完毕,玩家进入了场景
this.gmlevel = 0;
this.teamid = 0;
this.isleader = false;
this.lastWorldChatTime = 0;
this.lastWorldChatStr = '';
this.nFlag = 0;
this.offline = false;
this.offlineTimer = null;
this.shane = 0;
this.inPrison = false;
this.level_reward = '';
this.getgift = 0;
this.getpet = 1;
this.shuilu = {
season: 1,
score: 0,
gongji: 0,
wtime: 0,
ltime: 0,
};
this.arena = {
count: 10, //挑战次数
jpoint: 0, //竞技点
jtime: 0, //光阴
ranking: 0
};
//this.curtitle = 0;
this.titleId = -1;
this.titleType = -1; //当前的称谓类型
this.titleVal = ''; //当前称谓值
this.onLoad = false; //是否装载称谓
this.bangid = 0;
this.bangname = '';
this.bangpost = 0;
this.titles = [];
this.schemeName = '套装方案';
this.baldric = 0;
this.color1 = 0; // 染色部位1
this.color_one_serial = 0; // 染色部位编号一
this.color2 = 0; // 染色部位2
this.color_two_serial = 0; // 染色部位编号二
this.safe_password = '';
this.safe_lock = 0;
this.friendList = {};// 好友列表
this.applyFriendList = {};// 好友申请列表
// 击杀地煞星 星级
this.star = 1;
// 翅膀索引
this.wingId = 0;
this.dayMap = {};
// 签到数据
this.daySignIn = {};
this.horseList = new HorseList(this);
this.horseSkill = new HorseSkill(this);
this.mailList = new MailList(this);
// 界面图标
this.iconList = SKDataUtil.toJson(GameUtil.iconList, "{}");
// 最后一次时使用的技能
this.lastSkill = ESkillType.NormalAtkSkill;
this.petLastSkill = ESkillType.NormalAtkSkill;
this.mendDate = "";
this.mend_date = "";
// 幸运转盘免费次数
this.dial_num = 0;
// 幸运转盘累计次数
this.dial_count = 0;
// 幸运转盘免费最后一次点击时间
this.dial_date = "";
this.sat_integral = 0;
this.pause = 0;
this.ischeck = 0;
this.offlinetime = 0;
this.doublecnt = 0;
this.unget_doublecnt = 0;
this.isFrozen = 0;
this.ai_flag = 0;
this.tianti_integral = 0;
}
update(dt: number) {
if (this.shane > 0) {
this.shane--;
if (this.shane <= 0) {
this.shane = 0;
this.ShanEChange();
}
}
// 未关服则每30分钟存档一次
if (dt % (GameUtil.savePlayerTime) == 0) {
// 机器人不定时存档
if (this.isRobot()) {
return;
}
// if (!GameUtil.isClose) {
let self = this;
this.saveAll((failed: string[]) => {
if (failed.length > 0) {
SKLogger.warn(`定时存档:玩家[${self.roleid}:${self.name}]存档失败:${failed}`);
} else {
SKLogger.debug(`玩家[${self.roleid}:${self.name}]定时存档成功!`);
}
});
// }
}
if (dt % (1000) == 0) {
this.getTaskMgr().OnTimer();
}
if (this.ai) {
this.ai.update(dt);
}
}
GetFlag(nIndex: any): any {
return GameUtil.getFlag(this.nFlag, nIndex);
}
SetFlag(nIndex: any, bValue: any) {
this.nFlag = GameUtil.setFlag(this.nFlag, nIndex, bValue);
}
// 获得每日限购已购次数
getDayCount(dayId: number): number {
let count = this.dayMap[dayId];
if (count == null) {
return 0;
}
return count;
}
// 增加加每日限购数量
addDayCount(dayId: number, count: number) {
let current = this.dayMap[dayId];
if (current == null) {
this.dayMap[dayId] = count;
} else {
this.dayMap[dayId] = current + count;
}
}
// 清空每日存档
clearDayMap() {
// this.dayMap = {};
let keys = Object.keys(this.dayMap)
for (let index = 0; index < keys.length; index++) {
let key = keys[index];
if (key.indexOf("day") != -1) {
this.dayMap[key] = 0
}
}
let chargeSum = ChargeSum.shared.getPlayerChargeSum(this.roleid);
let vipLevel = VIPUtil.getVipLevel(chargeSum);
// 小于VIP等级的每日奖励已领取处理
vipLevel += 1;
for (let i = 0; i < vipLevel; i++) {
this.dayMap[`vip_${i}`] = 1;
}
this.send(`s2c_clear_day`, {
dayMap: SKDataUtil.toJson(this.dayMap, "{}")
});
}
// 清空VIP存档
clearDayMapVip() {
let chargeSum = ChargeSum.shared.getPlayerChargeSum(this.roleid);
let vipLevel = VIPUtil.getVipLevel(chargeSum);
this.dayMap[`vip_${vipLevel}`] = 0;
this.send(`s2c_clear_day`, {
dayMap: SKDataUtil.toJson(this.dayMap, "{}")
});
}
OnEnterTeam() {
this.getTaskMgr().checkAndInceptTask();
this.getTaskMgr().updateTaskStateToClient();
}
// 离开队伍
leaveTeam() {
if (this.teamid == 0) {
SKLogger.debug(`玩家[${this.roleid}:${this.name}]已离队`);
return;
}
this.teamid = 0;
this.isleader = false;
this.getTaskMgr().leaveTeam();
SKLogger.debug(`玩家[${this.roleid}:${this.name}]${this.isleader ? "队长" : "队员"}离开队伍${this.teamid}`);
}
getTeamId() {
return this.teamid;
}
isTeamLeader() {
if (this.teamid == 0) {
return false;
}
return this.isleader;
}
getTaskMgr(): RoleTaskMgr {
if (!this.taskMgr) {
this.taskMgr = new RoleTaskMgr(this);
}
return this.taskMgr;
}
CheckNewDay(lastonline: any) {
if (lastonline == null) {
return;
}
let cdate = new Date(GameUtil.gameTime);
let ly = lastonline.getFullYear();
let lm = lastonline.getMonth();
let lw = GTimer.getYearWeek(lastonline);
let ld = GTimer.getYearDay(lastonline);
if (ly != cdate.getFullYear()) {
this.OnNewYear();
}
if (lm != cdate.getMonth()) {
this.OnNewMonth();
}
if (lw != GTimer.getYearWeek(cdate)) {
this.OnNewWeek();
}
if (lw != GTimer.getYearWeek(cdate)) {
this.OnNewWeek();
}
if (ld != GTimer.getYearDay(cdate)) {
this.OnNewDay();
}
}
OnNewYear() {
// 这辈子估计不会调用
}
OnNewMonth() {
}
OnNewWeek() {
}
OnNewDay() {
}
on5oclock() {
if (this.getTaskMgr() == null)
return;
this.getTaskMgr().OnNewDay();
}
// OnNewHour() {
// }
setAgent(agent: any) {
if (this.agent) {
if (this.agent != agent) {
SKLogger.debug(`玩家[${this.roleid}:${this.name}]在其他设备登录!`);
this.agent.otherLogin();
}
}
this.agent = agent;
}
playerOffline() {
if (this.offline) {
return;
}
delete this.aoi_obj_list[this.onlyid];
let self = this;
let offtime = this.offlinetime * (60 * 60 * 1000)
this.offlineTimer = SKTimeUtil.delay(() => {
if (this.teamid > 0) {
TeamMgr.shared.leaveTeam(this);
}
self.destroy();//时间结束清理下线
}, offtime);
if (this.battle_id != 0) {
BattleMgr.shared.playerOffline(this.battle_id, this.onlyid);
}
// 未关服离线存档
if (!GameUtil.isClose && this.saveTotal < 1) {
// 机器人下线不存档
if (this.isRobot()) {
return;
}
let self = this;
// this.redisSave();
this.saveAll((failed: string[]) => {
if (failed.length > 0) {
SKLogger.warn(`存档:玩家[${self.roleid}:${self.name}]离线存档失败!`);
} else {
SKLogger.debug(`存档:玩家[${self.roleid}:${self.name}]离线存档成功!`);
}
});
// 通过cxf存档
this.cxfSavePlayerAll();
}
RelationMgr.shared.deleteTempRelationByPlayer(this.roleid);
this.agent = null;
SKLogger.debug(`玩家[${this.roleid}:${this.name}]已离线`);
this.offline = true;
this.calcOnlineTime();
}
activateScheme() {
let scheme = this.schemeMgr.getActivateScheme();
if (scheme) {
this.addattr2 = scheme.content.attribute.addPoint;
this.qianneng = scheme.content.attribute.qianNeng;
this.addattr1 = scheme.content.defense.xiuPoint;
this.xiulevel = scheme.content.defense.xiuLevel;
for (const key in this.addattr1) {
if (this.addattr1.hasOwnProperty(key)) {
this.xiulevel += this.addattr1[key];
}
}
for (let index = 0; index < this.currentEquips.length; index++) {
this.currentEquips[index].pos = EEquipPos.BAG;
this.addEquipList(this.currentEquips[index]);
}
this.currentEquips = [];
for (var it in scheme.content.curEquips) {
let eid = scheme.content.curEquips[it];
let equip = this.equipObjs[eid];
if (equip) {
let flag = true;
let fullEquipData = equip.getFullData(this.roleid);
if (fullEquipData.NeedGrade > this.level || fullEquipData.NeedRei > this.relive) {
this.send('s2c_notice', {
strRichText: '角色等级不足,尚不能使用!'
});
flag = false;
}
if (fullEquipData.Shuxingxuqiu) { //属性需求不符合
for (const key in fullEquipData.Shuxingxuqiu) {
if (this.getAttr1(key) < fullEquipData.Shuxingxuqiu[key]) {
this.send('s2c_notice', {
strRichText: '角色属性不足,尚不能使用!'
});
flag = false;
}
}
}
if (flag) {
equip.pos = EEquipPos.USE;
} else {
equip.pos = EEquipPos.BAG;
continue;
}
this.currentEquips.push(equip);
for (let index = 0; index < this.listEquips.length; index++) {
if (this.listEquips[index].EquipID == eid) {
this.listEquips.splice(index, 1);
break;
}
}
if (equip.EIndex == 1) {
this.changeWeapon(equip);
}
}
}
this.sendEquipList();
this.schemeName = scheme.schemeName;
this.partnerMgr.vecChuZhan = SKDataUtil.jsonBy(SKDataUtil.toJson(scheme.content.partner, "{}"));
this.calculateAttr();
this.send('s2c_player_data', this.getData());
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
}
}
checkSchemeEquip(equipid: any): boolean {
//装备
let equip: Equip = this.equipObjs[equipid];
let fullEquipData = equip.getFullData();
if (fullEquipData.OwnerRoleId > 0 && fullEquipData.OwnerRoleId != this.resid) {
this.send('s2c_notice', {
strRichText: '角色不匹配,不能使用!'
});
return false;
} else if ((fullEquipData.Sex != 9 && fullEquipData.Sex != this.sex) || (fullEquipData.Race != 9 && fullEquipData.Race != this.race)) {
this.send('s2c_notice', {
strRichText: '角色不匹配,不能使用!'
});
return false;
}
if (fullEquipData.Shuxingxuqiu) { //属性需求不符合
for (const key in fullEquipData.Shuxingxuqiu) {
if (this.getAttr1(key) < fullEquipData.Shuxingxuqiu[key]) {
this.send('s2c_notice', {
strRichText: '角色属性不足,尚不能使用!'
});
return false;
}
}
}
return true;
}
syncSchemePartner() {
if (this.schemeMgr != null) {
this.schemeMgr.syncSchemePartner();
}
}
destroy() {
if (this.offlineTimer) {
SKTimeUtil.cancelDelay(this.offlineTimer);
this.offlineTimer = null;
}
if (this.incenseTimer) {
SKTimeUtil.cancelDelay(this.incenseTimer);
this.incenseTimer = null;
}
if (this.agent) {
this.agent.close();
this.agent = null;
}
for (let equipid in this.equipObjs) {
EquipMgr.shared.delEquip(equipid);
}
let map = MapMgr.shared.getMap(this);
if (map) {
map.exitMap(this);
}
delete this.taskMgr;
delete this.partnerMgr;
PlayerMgr.shared.delPlayer(this.roleid);
NpcMgr.shared.deletePlayersNpc(this.roleid);
}
// 从数据库中读档
setDB(data: any) {
data.lastonline = new Date(data.lastonline);
this.dbData = data;
this.accountid = data.accountid;
this.invite = data.invite;
this.roleid = data.roleid;
this.mapid = data.mapid;
this.resid = data.resid;
this.race = RoleUtil.checkRace(data.race, data.resid);
this.sex = RoleUtil.checkSex(data.sex, data.resid);
this.name = data.name;
this.level_reward = data.level_reward;
this.exp = data.exp;
// 默认最低星 1星
this.star = data.star;
if (this.star < 1) {
this.star = 1;
}
this.bag_list = SKDataUtil.jsonBy(data.bagitem) || {};
// 设置称谓信息
// 称谓放在有关系统初始化之前,之后会操作称谓
let titles: any = SKDataUtil.jsonBy(data.title);
this.setTitles(titles);
this.initBang(data.bangid);
let partnerdata = SKDataUtil.jsonBy(data.partnerlist);
this.partnerMgr.init(partnerdata);
this.locker_list = SKDataUtil.jsonBy(data.lockeritem) || {};
this.money = data.money;
this.jade = data.jade;
this.bind_jade = data.bind_jade || 0;
this.bangscore = data.bang_score || 0;
this.shiscore = data.shi_score || 0;
this.discore = data.di_score || 0;
this.xiuscore = data.xiu_score || 0;
this.guoscore = data.guo_score || 0;
this.rewardrecord = data.rewardrecord;
this.sprewardrecord = data.sprewardrecord;
this.x = data.x;
this.y = data.y;
this.curPetId = data.pet;
this.curPet = null;
this.petList = [];
this.lastonline = data.lastonline;
this.nFlag = data.state;
this.getgift = data.getgift;
this.tianti_integral = Number(data.tianti_integral);//天梯积分
// 背包空间
this.bagKindNum = data.bag_kind_num;
// 等级相关
let relivelist = [
[0, 0],
[0, 0],
[0, 0],
[0, 0],
];
let relist = SKDataUtil.jsonBy(data.relivelist) || relivelist;
let fixed = 4 - relist.length;
for (let i = 0; i < fixed; i++) {
relist.push([0, 0]);
}
this.relivelist = relist;
this.relive = data.relive;
this.level = data.level;
this.sat_integral = data.sat_integral;
this.offlinetime = data.offlinetime;
this.doublecnt = data.doublecnt;
this.unget_doublecnt = data.unget_doublecnt == null ? 0 : data.unget_doublecnt;
this.mend_date = data.mend_date == null ? "" : data.mend_date;
if (data.color && data.color.length > 0) {
let colors = SKDataUtil.jsonBy(data.color);
if (colors.c1) {
this.color1 = colors.c1;
}
if (colors.c2) {
this.color2 = colors.c2;
}
if (colors.p1) {
this.color_one_serial = colors.p1;
}
if (colors.p2) {
this.color_two_serial = colors.p2;
}
}
if (data.safecode != null) {
let array = data.safecode.split(':');
this.safe_password = array[1] || '';
this.safe_lock = parseInt(array[0]) || 0;
}
else {
this.safe_password = '';
this.safe_lock = 0;
}
this.currentEquips = [];
this.listEquips = [];
this.equipObjs = {};
this.lockerEquips = [];
let equipList: any = {};
if (data.equipRows) {
for (let info of data.equipRows) {
equipList[info.EquipID] = info;
}
}
for (let equipid in equipList) {
if (this.equipObjs[equipid] != null) {
continue;
}
let info = SKDataUtil.valueForKey(equipList, equipid);
if (info == null) {
SKLogger.warn(``);
} else {
let equip = new Equip(info, this);
switch (info.pos) {
case EEquipPos.USE: {
let find = false;
for (let useequip of this.currentEquips) {
if (useequip.EIndex == equip.EIndex) {
find = true;
equip.pos = EEquipPos.BAG;
this.addEquipList(equip);
}
}
if (!find) {
this.currentEquips.push(equip);
if (equip.EIndex == 6) {
let conf = EquipMgr.shared.getXianQiBy(equip.Type);
this.wingId = conf.Shape;
}
}
break;
}
case EEquipPos.BAG: {
this.addEquipList(equip);
break;
}
case EEquipPos.BANK: {
this.lockerEquips.push(equip);
break;
}
default: {
equip.pos = EEquipPos.BAG;
this.addEquipList(equip);
}
}
this.equipObjs[equip.EquipID] = equip;
SKLogger.debug(`玩家[${this.roleid}:${this.name}]加入装备[${equip.EquipID}:${equip.name}]`);
}
}
// 水陆大会信息
this.initShuilu(data.shuilu);
this.initJingji(data.arena);
this.initRolePoint(data.addpoint);
this.checkRolePoint();
// 修炼等级
this.xiulevel = data.xiulevel;
this.initXiuLianPoint(data.xiupoint);
this.checkXiulianPoint();
// 设置等级在属性设置 之后设置!
this.setLevel(data.level);
// 取消技能熟练度升级,直接满级
this.resetSkill();
this.getpet = data.getpet;
// GM等级
this.gmlevel = data.gmlevel;
this.shane = data.shane;
if (this.shane > 0) {
let curDate = new Date();
let passtime = (curDate.getTime() - data.lastonline.getTime()) / 1000;
if (passtime > 0) {
this.shane -= Math.floor(passtime * 4);
}
if (this.shane <= 0) {
this.shane = 0;
}
}
let schemeMgr: SchemeMgr = new SchemeMgr(this);
this.schemeMgr = schemeMgr;
this.schemeMgr.readDB();
// 好友相关
let friendlist: any = SKDataUtil.jsonBy(data.friendlist) || {};
if (friendlist.version == 1) {
for (let roleid in friendlist) {
if (roleid == 'version') {
delete friendlist['version'];
continue;
}
if (friendlist.hasOwnProperty(roleid)) {
let finfo = friendlist[roleid];
try {
finfo.name = Buffer.from(finfo.name, 'base64').toString();
} catch (error) {
SKLogger.warn(`好友名称[${finfo.name}]编码失败`);
}
}
}
}
this.friendList = friendlist;
// 兑换码
this.exchange = new Exchange(this.roleid);
this.exchange.readDB();
//阵法信息
if (!!data.zhenfa) {
var info = SKDataUtil.jsonBy(data.zhenfa);
this.ZFMgr.initByData(info)
}
if (!!data.xw) {
var info = SKDataUtil.jsonBy(data.xw);
this.XWMgr.loadData(info)
}
// 坐骑
this.horseList.setDB(data.horseRows);
this.horseList.horseIndex = SKDataUtil.clamp(data.horse_index, 0, 4);
// 坐骑技能
this.horseSkill.setDB(data.horseSkillRows);
this.setPetDB(data.petRows);
this.loaded = true;
if (data.day_count) {
this.dayMap = SKDataUtil.jsonBy(data.day_count);
}
// 不是机器人才进行读取签到数据和邮件数据
if (!this.isRobot()) {
// 获取当前角色签到数据
if (data.signIn[0]) {
// 补签日期
this.mendDate = data.signIn[0].mendDate == null ? "" : data.signIn[0].mendDate;
let signInInfo = SKDataUtil.jsonBy(data.signIn[0].daySignIn);
// 获取当前角色所签到的月份
let key: any = Object.keys(signInInfo);
// 储存的月份与当前月份不相等重新进行生成
if (key != GTimer.getCurMonth()) {
this.daySignIn = SKDataUtil.jsonBy(GameUtil.getDaySignIn());
} else {
this.daySignIn = signInInfo;
}
} else {
this.daySignIn = SKDataUtil.jsonBy(GameUtil.getDaySignIn());
}
// 获取当前角色签到数据
if (data.dial[0]) {
// 补签日期
this.dial_num = data.dial[0].dial_num;
this.dial_count = data.dial[0].dial_count;
this.dial_date = data.dial[0].dial_date;
} else {
this.dial_num = 1;
this.dial_count = 0;
this.dial_date = GTimer.getYearMonthDay();
}
this.mailList.setDB(data.mailRows);
}
this.OnlineReminder();
//宝宝信息
this.BabyMgr.setDB(data.baby)
this.StarMgr.setDB(data.star_info)
};
setTitles(titles: any) {
if (titles == null) {
return;
}
this.titles = titles.titles;
this.onLoad = titles.onload;
this.titles.filter((e: any) => {
if (e.onload) {
this.titleType = e.type;
this.titleId = e.titleid;
this.titleVal = e.value;
}
});
}
setActivateSchemeName(schemeName: any) {
this.schemeName = schemeName;
this.send('s2c_player_data', this.getData());
}
// 开启背包格子
openBackpackGrid() {
// 消耗金额
let price: number = GameUtil.bagPrice;
// 消耗金额类型
let consume_type: number = GameUtil.goldKind.Money;
// 当前背包格子大于65时,每开启5个格子固定消费仙玉(也就是开启75个格子时往后消费固定仙玉)
if (this.bagKindNum > 65) {
if (this.jade < price) {
this.send_notice(`仙玉不足无法开启物品格子`);
return;
}
consume_type = GameUtil.goldKind.Jade;
}
// 当前背包格子不等于初始格子并且当前背包格子小于65个格子时消费 银币
else if (this.bagKindNum != GameUtil.limitBagKindNum) {
// ((当前背包格子 - 默认背包格子) / 5 * 背包开启价格 + 背包开启价格) * 50
price = ((this.bagKindNum - GameUtil.limitBagKindNum) / 5 * GameUtil.bagPrice + GameUtil.bagPrice) * 50;
if (this.money < price) {
this.send_notice(`银币不足无法开启物品格子`);
return;
}
}
// 第一次开启格子
else {
if (this.money < price) {
this.send_notice(`银币不足无法开启物品格子`);
return;
}
}
// 增加背包格子
this.bagKindNum += 5;
// 扣钱金钱
this.addMoney(consume_type, -price, "", MsgCode.SUCCESS)
this.send('s2c_open_backpack_grid', {
num: this.bagKindNum
});
// 发送信息
this.send_notice(`你新增了5个物品格子`);
}
OnlineReminder() {
let name: any = [];
let moneyRank: any = null;
let levelRank: any = null;
let jingjiRank: any = null;
let moneyDesc: any = '';
let levelDesc: any = '';
let jingjiDesc: any = '';
moneyRank = PaiHangMgr.shared.getMoneyRank();
levelRank = PaiHangMgr.shared.getLevelRank();
jingjiRank = PaiHangMgr.shared.getJingJiRank();
for (let i = 0; i < 3; i++) {
SKLogger.debug(moneyRank.length)
if (moneyRank.length > 0 && moneyRank.length > i) {
name.push(moneyRank[i][1]);
}
SKLogger.debug(levelRank.length)
if (levelRank.length > 0 && levelRank.length > i) {
name.push(levelRank[i][1]);
}
SKLogger.debug(jingjiRank.length)
if (jingjiRank.length > 0 && jingjiRank.length > i) {
name.push(jingjiRank[i][1]);
}
}
let allname: any = SKDataUtil.unique(name);
for (let j = 0; j < allname.length; j++) {
if (allname[j] == this.name) {
for (let n = 0; n < 3; n++) {
if (moneyRank.length > 0 && moneyRank.length > n) {
if (moneyRank[n][0] == this.name) {
moneyDesc = `财富排行第${n + 1}`;
break;
}
}
}
for (let m = 0; m < 3; m++) {
if (levelRank.length > 0 && levelRank.length > m) {
if (levelRank[m][0] == this.name) {
levelDesc = `练功狂人排行第${m + 1}`;
break;
}
}
}
for (let k = 0; k < 3; k++) {
if (jingjiRank.length > 0 && jingjiRank.length > k) {
if (jingjiRank[k][0] == this.name) {
jingjiDesc = `竞技排行第${k + 1}`;
break;
}
}
}
let strRichText = `<color=#0fffff > ${moneyDesc}</color ><color=#0fffff > ${levelDesc}</color ><color=#0fffff > ${jingjiDesc}</color ><color=#00ff00 > ${allname[j]}</c > <color=#ffffff > 玩家,上线了!</c >`;
PlayerMgr.shared.broadcast('s2c_screen_msg', {
strRichText: strRichText,
bInsertFront: 0
});
break;
}
}
}
checkEquipExist(equipId: any) {
let checkRes = false;
checkRes = this.currentEquips.some((e: any) => {
return e.EquipID == equipId;
})
if (!checkRes) {
return this.listEquips.some((e: any) => {
return e.EquipID == equipId;
});
}
return checkRes;
}
initBang(bangid: any) {
// 检查是否被踢
this.bangid = bangid;
if (this.bangid > 0 && BangMgr.shared.bangList[this.bangid] == null) {
this.bangid = 0;
}
if (this.bangid != 0) {
let bang = BangMgr.shared.getBang(this.bangid);
if (bang == null) {
SKLogger.info(`没有找到帮编号${this.bangid}`)
this.bangid = 0;
} else {
if (bang.isinit == true) {
if (bang.checkPlayer(this.roleid)) {
if (bang.masterid == this.roleid) {
bang.mastername = this.name;
}
this.bangname = bang.name;
this.bangpost = bang.getBangPost(this.roleid);
if (bang.masterid == this.roleid) {
this.addTitle(GameUtil.titleType.CommonTitle, GameUtil.titleBangType.BangZhu, '', false);
} else {
this.addTitle(GameUtil.titleType.CommonTitle, GameUtil.titleBangType.BangZhong, '', false);
}
} else {
SKLogger.info(`${this.name}:没有找到帮编号${this.bangid}`)
this.bangid = 0;
this.bangname = '';
this.bangpost = 0;
this.delTitle(GameUtil.titleType.CommonTitle, GameUtil.titleBangType.BangZhu);
this.delTitle(GameUtil.titleType.CommonTitle, GameUtil.titleBangType.BangZhong);
}
}
}
}
}
initShuilu(shuiluinfo: any) {
this.shuilu = {
season: 1,
score: 0,
gongji: 0,
wtime: 0,
ltime: 0,
};
if (shuiluinfo) {
let t = SKDataUtil.jsonBy(shuiluinfo);
this.shuilu.season = t.season ? t.season : 0;
this.shuilu.score = t.score ? t.score : 0;
this.shuilu.gongji = t.gongji ? t.gongji : 0;
this.shuilu.wtime = t.wtime ? t.wtime : 0;
this.shuilu.ltime = t.ltime ? t.ltime : 0;
}
let shuiludahui = ActivityMgr.shared.getActivity(ActivityDefine.activityKindID.ShuiLuDaHui);
if (shuiludahui && this.shuilu.season != shuiludahui.season) {
this.shuilu.season = shuiludahui.season;
this.shuilu.score = 0;
this.shuilu.wtime = 0;
this.shuilu.ltime = 0;
}
}
initJingji(jingjiinfo: any) {
this.arena = {
count: 10,
jpoint: 0,
jtime: 0,
ranking: 0,
};
if (jingjiinfo) {
let t = SKDataUtil.jsonBy(jingjiinfo);
this.arena.count = t.count ? t.count : 10;
this.arena.jpoint = t.jpoint ? t.jpoint : 0;
this.arena.jtime = t.jtime ? t.jtime : 0;
this.arena.ranking = t.ranking ? t.ranking : 0;
}
}
// 升级技能
updateSkill(data: any) {
if (this.skill_list[data.skillId] == null) {
this.send('s2c_notice', {
strRichText: `找不到技能[${SkillUtil.getSkillName(data.skillId)}]`
});
return;
}
let maxLevel = ExpUtil.getMaxSkillLevel(this.relive);
if (this.skill_list[data.skillId] > maxLevel) {
this.skill_list[data.skillId] = maxLevel;
}
if (this.skill_list[data.skillId] >= maxLevel) {
this.send('s2c_notice', {
strRichText: `技能[${SkillUtil.getSkillName(data.skillId)}]已经满级了!`
});
return;
}
this.skill_list[data.skillId] += 100;
if (this.skill_list[data.skillId] > maxLevel) {
this.skill_list[data.skillId] = maxLevel;
}
this.send('s2c_player_data', this.getData());
let info = this.CostFee(GameUtil.goldKind.Money, data.costMoney); //升级技能所消耗的金币
if (info.length > 0) {
this.send('s2c_notice', {
strRichText: info
});
}
}
addCustomPoint(data: any) {
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
let addlist = SKDataUtil.jsonBy(data.addattr);
let alladd = 0;
for (const key in addlist) {
if (addlist.hasOwnProperty(key)) {
//如果有负数,跳过
if (addlist[key] < 0) {
continue;
}
alladd += addlist[key];
}
}
//如果加点超过1500点
if (alladd > 1500 || alladd < 0) {
return;
}
if (alladd == 0) {
return;
}
if (alladd <= this.qianneng) {
for (const key in this.addattr2) {
if (addlist.hasOwnProperty(key) && this.addattr2.hasOwnProperty(key)) {
this.addattr2[key] += addlist[key];
}
}
this.calQianNeng();
this.calculateAttr();
if (player) {
//cxf人物加点
SKCxfUtil.getCxfRecordOperate({
roleId: player.roleid,
roleName: player.name,
operateType: Operate.ITEM,
operateDepict: "人物加点",
operateResSerial: player.roleid,
operateResName: player.name,
operateContent: ""
})
}
// this.send('s2c_player_data', this.getData());
this.schemeMgr && this.schemeMgr.syncSchemePoint();
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
// 如果在队伍中需要刷新队伍信息
this.refresh_team_data();
}
}
// 属性检测
freeze() {
//如果玩家根骨、灵性、力量、敏捷等属性超过2000点
if (this.attr1[EAttrTypeL1.BONE] > 2000 || this.attr1[EAttrTypeL1.SPIRIT] > 2000 || this.attr1[EAttrTypeL1.STRENGTH] > 2000 || this.attr1[EAttrTypeL1.DEXTERITY] > 2000) {
this.send_notice('系统检测属性异常,请联系管理人员说明情况否则,对您进行封号处理');
// DB.freezeIP(this.accountid, (ret: any, ip: any) => {
// if (ret == MsgCode.SUCCESS) {
// if (ip == 0) {
// return;
// }
// delete PlayerMgr.shared.player_role_list[this.roleid];
// delete PlayerMgr.shared.player_only_list[this.onlyid];
// this.destroy();
// FrozenIPMgr.shared.addFrozenIP(ip,this.accountid);
// Signal.shared.DeleteTocken(this.accountid);
// }
// });
}
}
initTaskMgr(data: string) {
let dict: any = SKDataUtil.jsonBy(data) || {};
let vecStateList = SKDataUtil.getDefault(dict.StateList, []);
let vecRecordList = SKDataUtil.getDefault(dict.RecordList, []);
let mapDailyCnt = SKDataUtil.getDefault(dict.DailyCnt, {});
let mapFuBenCnt = SKDataUtil.getDefault(dict.FuBenCnt, {});
let mapDailyStart = SKDataUtil.getDefault(dict.DailyStart, {});
let mapActiveScore = SKDataUtil.getDefault(dict.mapActiveScore, {});
let szBeenTake = SKDataUtil.getDefault(dict.szBeenTake, [0, 0, 0, 0, 0, 0]);
this.getTaskMgr().init(vecStateList, vecRecordList, mapDailyCnt, mapFuBenCnt, mapDailyStart, mapActiveScore, szBeenTake);
}
// 设置召唤兽数据
setPetDB(rows: any) {
SKLogger.debug(`玩家[${this.roleid}:${this.name}]加载召唤兽列表...`);
if (rows == null || rows.length < 1) {
this.getpet = 0;
} else {
for (let item of rows) {
if (item.state == 0) { // 被删除
continue;
}
let pet = new Pet(item.dataid);
pet.setOwner(this);
pet.setDB(item);
this.petList.push(pet);
if (this.curPetId == 0) {
this.curPetId = pet.petid;
this.curPet = pet;
} else if (this.curPetId == pet.petid) {
this.curPet = pet;
}
}
}
}
// 重置技能,取消技能熟练度升级,直接满级
resetSkill() {
let conf: any = GameUtil.defineSkill;
this.skill_list = SKDataUtil.clone(conf[this.race][this.sex]);
let maxLevel = ExpUtil.getMaxSkillLevel(this.relive);
for (let skillId in this.skill_list) {
this.skill_list[skillId] = maxLevel;
}
}
// 机器人重置技能,取消技能熟练度升级,直接满级
resetRoleSkill() {
let conf: any = GameUtil.robotDefineSkill;
this.skill_list = SKDataUtil.clone(conf[this.race][this.sex]);
let maxLevel = ExpUtil.getMaxSkillLevel(this.relive);
for (let skillId in this.skill_list) {
this.skill_list[skillId] = maxLevel;
}
}
// 初始化角色加点
initRolePoint(rolepoints: any) {
if (rolepoints == null) {
return;
}
if (rolepoints.length > 0 && (rolepoints[0] == '{' || rolepoints[0] == '[')) {
let setPonit2 = (key: any, num: any) => {
if (typeof (num) == 'number' && !isNaN(num)) {
this.addattr2[key] = num > 0 ? num : 0;
}
}
let addpoint = SKDataUtil.jsonBy(rolepoints);
setPonit2(EAttrTypeL2.GENGU, addpoint[EAttrTypeL2.GENGU]);
setPonit2(EAttrTypeL2.LINGXING, addpoint[EAttrTypeL2.LINGXING]);
setPonit2(EAttrTypeL2.MINJIE, addpoint[EAttrTypeL2.MINJIE]);
setPonit2(EAttrTypeL2.LILIANG, addpoint[EAttrTypeL2.LILIANG]);
}
}
updateFriend(pInfo: any) {
let friend = this.friendList[pInfo.roleid];
if (friend) {
this.friendList[pInfo.roleid].name = pInfo.name;
}
}
// 获得好友数量
getFriendNum(): number {
let n = 0;
for (let pid in this.friendList) {
if (this.friendList.hasOwnProperty(pid)) {
n++;
}
}
return n;
}
checkRolePoint() {
let qncount = this.level * 4; // LevelMgr.getRoleLevelQianneng();
let qn = 0;
for (const key in this.addattr2) {
if (this.addattr2.hasOwnProperty(key)) {
qn += this.addattr2[key];
}
}
if (qn > qncount) {
this.resetRolePoint();
this.calQianNeng();
}
}
initXiuLianPoint(xiupoints: any) {
if (xiupoints != null) {
if (xiupoints.length > 0 && (xiupoints[0] == '{' || xiupoints[0] == '[')) {
let setPonit1 = (key: any, num: any) => {
if (typeof (num) == 'number' && !isNaN(num)) {
this.addattr1[key] = num > 0 ? num : 0;
}
}
let xiupoint = SKDataUtil.jsonBy(xiupoints);
for (const attrtype in xiupoint) {
if (xiupoint.hasOwnProperty(attrtype)) {
const num = xiupoint[attrtype];
setPonit1(attrtype, num);
}
}
}
}
}
checkXiulianPoint() {
let maxlevel = RolePracticeMgr.shared.GetMaxPriactiveLevel(this.relive);
if (this.xiulevel > maxlevel) {
this.xiulevel = maxlevel;
this.resetXiulianPoint();
return;
}
let xlpoint = 0
for (const key in this.addattr1) {
if (this.addattr1.hasOwnProperty(key)) {
const p = this.addattr1[key];
xlpoint += p;
}
}
if (xlpoint > this.xiulevel) {
this.resetXiulianPoint();
}
}
getTotalQianneng() {
return this.level * 4;
}
calQianNeng() {
let qncount = this.level * 4; // LevelMgr.getRoleLevelQianneng();
let qn = 0;
for (const key in this.addattr2) {
if (this.addattr2.hasOwnProperty(key)) {
qn += this.addattr2[key];
}
}
let left_qn = qncount - qn;
this.qianneng = left_qn;
//当潜能值发生变化时,同步方案潜能值
this.schemeMgr && this.schemeMgr.syncSchemePoint();
}
calculatePointAttr() {
this.calQianNeng();
this.setAttr1(EAttrTypeL1.BONE, this.level + this.addattr2[EAttrTypeL1.BONE]);
this.setAttr1(EAttrTypeL1.STRENGTH, this.level + this.addattr2[EAttrTypeL1.STRENGTH]);
this.setAttr1(EAttrTypeL1.SPIRIT, this.level + this.addattr2[EAttrTypeL1.SPIRIT]);
this.setAttr1(EAttrTypeL1.DEXTERITY, this.level + this.addattr2[EAttrTypeL1.DEXTERITY]);
}
calculateZhenfaAttr() {
console.log("calculateZhenfaAttr.......")
this.ZFMgr.calculateZhenfaAttr(this.attr1)
}
calculateStarAttr() {
this.StarMgr.calculateStarAttr(this.attr1)
}
calculateEquipAttr() {
if (this.currentEquips) {
let list = [EAttrTypeL1.HP, EAttrTypeL1.MP, EAttrTypeL1.HP_MAX, EAttrTypeL1.MP_MAX, EAttrTypeL1.ATK, EAttrTypeL1.SPD];
for (const equip of this.currentEquips) {
for (let key in EAttrTypeL1) {
let value = SKDataUtil.numberBy(key);
if (isNaN(value)) {
continue;
}
if (list.indexOf(value) != -1) {
continue;
}
let equipattr = equip.getAttr(value);
if (equipattr == null || equipattr == 0) {
continue;
}
let addattr = GameUtil.attrToBaseAttr[value];
if (addattr != null) {
let target_attr = addattr.target;
if (addattr.cal == EAttrCalType.ADD_PERCENT) {
this.attr1[target_attr] = (1 + equipattr / 100) * this.attr1[target_attr];
} else if (addattr.cal == EAttrCalType.PERCENT) {
this.attr1[target_attr] = (equipattr / 100) * this.attr1[target_attr];
} else if (addattr.cal == EAttrCalType.ADD_NUM) {
this.attr1[target_attr] += equipattr;
}
} else {
this.attr1[value] += equipattr;
}
}
}
}
this.checkBaldricSuit();
this.checkPlayerOfudaUseState();
}
// 检查佩饰套装
checkBaldricSuit() {
let suitId: number = -1;
let suitName: string = "";
let suitCount: number = 0;
for (let equip of this.currentEquips) {
if (ItemUtil.isBaldric(equip.EIndex)) {
let itemData = ItemUtil.getItemData(equip.Type);
if (itemData) {
if (suitId == -1) {
suitId = itemData.level;
suitName = itemData.name.substring(0, 2);
suitCount++;
} else if (suitId == itemData.level) { //如果品级一样 则配饰技能不变
suitId = itemData.level;
suitCount++;
} else if (suitName == itemData.name.substring(0, 2)) {
if (suitId > itemData.level) { //如果比原配饰品级低 则替换成低级的技能
suitId = itemData.level;
}
suitCount++;
} else {
break;
}
}
}
}
if (suitCount >= 5) {
let suitData = ItemUtil.getBaldricSuit(suitId);
if (suitData) {
let skill = SkillUtil.getSkill(suitData.skill);
if (skill) {
this.baldric = skill.skill_id;
this.calcBaldricSkill(skill, 0, "佩饰技能");
}
}
} else {
this.baldric = 0;
}
}
//检查正在使用的天策符
checkPlayerOfudaUseState() {
let ms1 = new Date().getMilliseconds();
let ofuda_map = Ofuda.shared.inUseOfudaByRoleid(this.roleid);
if (ofuda_map == null || ofuda_map == undefined) {
return;
}
if (ofuda_map.size > 0) {
for (let [key, value] of ofuda_map) {
if (value.oftype == 1 || value.oftype == 2) {
let skill = SkillUtil.getSkill(key);
this.calcBaldricSkill(skill, value.addition, "天策符")
}
if (value.oftype == 3) {
for (let pet of this.petList) {
pet.calculateAttribute();
}
}
}
}
let ms2 = new Date().getMilliseconds();
let time = ms2 - ms1;
SKLogger.info(`检查正在使用的天策符-运行时间:${time}ms`);
}
checkPetOfudaUseState(pet: any, attr: any) {
let ofuda_map = Ofuda.shared.inUseOfudaByRoleid(this.roleid);
if (ofuda_map == null || ofuda_map == undefined) {
return 0;
}
if (ofuda_map.size > 0) {
for (let [key, value] of ofuda_map) {
if (value.oftype == 3) {
let skill = SkillUtil.getSkill(key);
if (attr == EAttrTypeL1.PHY_BREAK) {
if (skill.skill_id == ESkillType.MengGong1 || skill.skill_id == ESkillType.MengGong2 || skill.skill_id == ESkillType.MengGong3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
} else if (attr == EAttrTypeL1.PHY_BREAK_PROB) {
if (skill.skill_id == ESkillType.KanPo1 || skill.skill_id == ESkillType.KanPo2 || skill.skill_id == ESkillType.KanPo3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
} else if (attr == EAttrTypeL1.PHY_HIT) {
if (skill.skill_id == ESkillType.JingZhun1 || skill.skill_id == ESkillType.JingZhun2 || skill.skill_id == ESkillType.JingZhun3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
} else if (attr == EAttrTypeL1.PHY_REBOUND) {
if (skill.skill_id == ESkillType.HuWei1 || skill.skill_id == ESkillType.HuWei2 || skill.skill_id == ESkillType.HuWei3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
} else if (attr == EAttrTypeL1.K_DETER) {
if (skill.skill_id == ESkillType.LianXi1 || skill.skill_id == ESkillType.LianXi2 || skill.skill_id == ESkillType.LianXi3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
} else if (attr == EAttrTypeL1.K_SEAL) {
if (skill.skill_id == ESkillType.HuiGen1 || skill.skill_id == ESkillType.HuiGen2 || skill.skill_id == ESkillType.HuiGen3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
} else if (attr == EAttrTypeL1.K_CONFUSION) {
if (skill.skill_id == ESkillType.HuiGen1 || skill.skill_id == ESkillType.HuiGen2 || skill.skill_id == ESkillType.HuiGen3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
} else if (attr == EAttrTypeL1.K_SLEEP) {
if (skill.skill_id == ESkillType.HuiGen1 || skill.skill_id == ESkillType.HuiGen2 || skill.skill_id == ESkillType.HuiGen3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
} else if (attr == EAttrTypeL1.K_FORGET) {
if (skill.skill_id == ESkillType.HuiGen1 || skill.skill_id == ESkillType.HuiGen2 || skill.skill_id == ESkillType.HuiGen3) {
return this.petOfudaAttr(skill, value.addition, pet);
}
continue;
}
}
}
}
return 0;
}
calcOfudaSkill(skill: SkillBase, addition: number) {
if (skill == null) {
return 0;
}
if (skill.action_type != EActionType.PASSIVE) {
return 0;
}
let level = 0;
let bang = BangMgr.shared.getBang(this.bangid);
if (bang) {
let list = bang.rolelist;
for (let key in list) {
if (this.roleid == list[key].roleid) {
level = list[key].ofudalevel;
break;
}
}
}
let effectMap = skill.effectMap;
for (let key in effectMap) {
let type: EAttrTypeL1 = SKDataUtil.numberBy(key);
let ret = skill.getBaldricEffect(type);
return ret.add = SKDataUtil.toDecimal2((1 + (addition * 0.1)) * (level * 0.1));
}
return 0;
}
// 计算佩饰技能
calcBaldricSkill(skill: SkillBase, addition: number, prefix: string) {
if (skill == null) {
return;
}
if (skill.action_type != EActionType.PASSIVE) {
return;
}
let level = 0;
let bang = BangMgr.shared.getBang(this.bangid);
if (bang) {
let list = bang.rolelist;
for (let key in list) {
if (this.roleid == list[key].roleid) {
level = list[key].ofudalevel;
break;
}
}
}
let effectMap = skill.effectMap;
for (let key in effectMap) {
let type: EAttrTypeL1 = SKDataUtil.numberBy(key);
let ret = skill.getBaldricEffect(type);
if (prefix == "天策符") {
if (ret.add < 0) {
ret.add = Math.floor((1 + (addition * 0.1)) * (level * 0.1) * (ret.add / 10));
} else {
ret.add = SKDataUtil.toDecimal2((1 + (addition * 0.1)) * (level * 0.1));
}
}
if (ret.add) {
let old = SKDataUtil.toDecimal2(this.attr1[type]);
if (!(type == 0 || type == 1 || type == 2 || type == 9)) {
this.attr1[type] = SKDataUtil.toDecimal2(old + ret.add);
}
let current: number = this.attr1[type];
SKLogger.debug(`玩家[${this.roleid}:${this.name}]佩饰技能[${skill.skill_name}][${GameUtil.attrTypeL1Name[type]}]改变[${ret.add}]:${old}->${current}`);
let oldHP = this.attr1[EAttrTypeL1.HP];
let oldMP = this.attr1[EAttrTypeL1.MP];
let oldATK = this.attr1[EAttrTypeL1.ATK];
let oldSPD = this.attr1[EAttrTypeL1.SPD];
if (prefix != "天策符") {
if (type == EAttrTypeL1.HP_MAX) {
this.attr1[EAttrTypeL1.HP] = this.attr1[EAttrTypeL1.HP_MAX];
SKLogger.debug(`玩家[${this.roleid}:${this.name}]佩饰技能[${skill.skill_name}]气血最大值改变:${oldHP}->${this.attr1[EAttrTypeL1.HP]}`);
} else if (type == EAttrTypeL1.MP_MAX) {
this.attr1[EAttrTypeL1.MP] = this.attr1[EAttrTypeL1.MP_MAX];
SKLogger.debug(`玩家[${this.roleid}:${this.name}]佩饰技能[${skill.skill_name}]法力最大值改变:${oldMP}->${this.attr1[EAttrTypeL1.MP]}`);
} else if (type == EAttrTypeL1.HP_PERC) {
this.attr1[EAttrTypeL1.HP] = Math.floor(this.attr1[EAttrTypeL1.HP_MAX] * (1 + ret.add / 100));
SKLogger.debug(`玩家[${this.roleid}:${this.name}]佩饰技能[${skill.skill_name}]气血百分比改变:${oldHP}->${this.attr1[EAttrTypeL1.HP]}`);
} else if (type == EAttrTypeL1.MP_PERC) {
this.attr1[EAttrTypeL1.MP] = Math.floor(this.attr1[EAttrTypeL1.MP_MAX] * (1 + ret.add / 100));
SKLogger.debug(`玩家[${this.roleid}:${this.name}]佩饰技能[${skill.skill_name}]法力百分比改变:${oldMP}->${this.attr1[EAttrTypeL1.MP]}`);
} else if (type == EAttrTypeL1.ATK_PERC) {
this.attr1[EAttrTypeL1.ATK] = Math.floor(this.attr1[EAttrTypeL1.ATK] * (1 + ret.add / 100));
SKLogger.debug(`玩家[${this.roleid}:${this.name}]佩饰技能[${skill.skill_name}]攻击百分比改变:${oldATK}->${this.attr1[EAttrTypeL1.ATK]}`);
} else if (type == EAttrTypeL1.ATK_ADD) {
this.attr1[EAttrTypeL1.ATK] = Math.floor(this.attr1[EAttrTypeL1.ATK] * (1 + ret.add / 100));
SKLogger.debug(`玩家[${this.roleid}:${this.name}]佩饰技能[${skill.skill_name}]攻击百分比改变:${oldATK}->${this.attr1[EAttrTypeL1.ATK]}`);
} else if (type == EAttrTypeL1.SPD_PERC) {
this.attr1[EAttrTypeL1.SPD] = Math.floor(this.attr1[EAttrTypeL1.SPD] * (1 + ret.add / 100));
SKLogger.debug(`玩家[${this.roleid}:${this.name}]佩饰技能[${skill.skill_name}]速度百分比改变:${oldSPD}->${this.attr1[EAttrTypeL1.SPD]}`);
} else if (type == EAttrTypeL1.CURE_EHAN) {//加强治愈
this.attr1[EAttrTypeL1.CURE_EHAN] = Math.floor(this.attr1[EAttrTypeL1.CURE_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.SWEEP_EHAN) {//加强横扫
this.attr1[EAttrTypeL1.SWEEP_EHAN] = Math.floor(this.attr1[EAttrTypeL1.SWEEP_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.BREAK_EHAN) {//加强破甲
this.attr1[EAttrTypeL1.BREAK_EHAN] = Math.floor(this.attr1[EAttrTypeL1.BREAK_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.THUD_EHAN) {//加强震击
this.attr1[EAttrTypeL1.THUD_EHAN] = Math.floor(this.attr1[EAttrTypeL1.THUD_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.BLOODRETURN_EHAN) {//加强三尸
this.attr1[EAttrTypeL1.BLOODRETURN_EHAN] = Math.floor(this.attr1[EAttrTypeL1.BLOODRETURN_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_WIND) {//忽视抗风
this.attr1[EAttrTypeL1.HK_WIND] = Math.floor(this.attr1[EAttrTypeL1.HK_WIND] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_WILDFIRE) {//忽视抗鬼火
this.attr1[EAttrTypeL1.HK_WILDFIRE] = Math.floor(this.attr1[EAttrTypeL1.HK_WILDFIRE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.K_BLOODRETURN) {//抗三尸
this.attr1[EAttrTypeL1.K_BLOODRETURN] = Math.floor(this.attr1[EAttrTypeL1.K_BLOODRETURN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_BLOODRETURN) {//忽视抗三尸
this.attr1[EAttrTypeL1.HK_BLOODRETURN] = Math.floor(this.attr1[EAttrTypeL1.HK_BLOODRETURN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.K_CONFUSION) {//抗混乱
this.attr1[EAttrTypeL1.K_CONFUSION] = Math.floor(this.attr1[EAttrTypeL1.K_CONFUSION] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_CONFUSION) {//忽视抗混乱
this.attr1[EAttrTypeL1.HK_CONFUSION] = Math.floor(this.attr1[EAttrTypeL1.HK_CONFUSION] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_FIRE) {//忽视抗火
this.attr1[EAttrTypeL1.HK_FIRE] = Math.floor(this.attr1[EAttrTypeL1.HK_FIRE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_WATER) {//忽视抗水
this.attr1[EAttrTypeL1.HK_WATER] = Math.floor(this.attr1[EAttrTypeL1.HK_WATER] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_THUNDER) {//忽视雷
this.attr1[EAttrTypeL1.HK_THUNDER] = Math.floor(this.attr1[EAttrTypeL1.HK_THUNDER] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.K_SLEEP) {//抗睡
this.attr1[EAttrTypeL1.K_SLEEP] = Math.floor(this.attr1[EAttrTypeL1.K_SLEEP] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_SLEEP) {//忽视抗睡
this.attr1[EAttrTypeL1.HK_SLEEP] = Math.floor(this.attr1[EAttrTypeL1.HK_SLEEP] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.PHY_DODGE) {//闪避
this.attr1[EAttrTypeL1.PHY_DODGE] = Math.floor(this.attr1[EAttrTypeL1.PHY_DODGE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.K_DETER) {//抗震慑
this.attr1[EAttrTypeL1.PHY_DODGE] = Math.floor(this.attr1[EAttrTypeL1.PHY_DODGE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_DETER) {//忽视抗震慑
this.attr1[EAttrTypeL1.HK_DETER] = Math.floor(this.attr1[EAttrTypeL1.HK_DETER] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.PHY_BREAK) {//破防程度
this.attr1[EAttrTypeL1.PHY_BREAK] = Math.floor(this.attr1[EAttrTypeL1.PHY_BREAK] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.PHY_BREAK_PROB) {//破防率
this.attr1[EAttrTypeL1.PHY_BREAK_PROB] = Math.floor(this.attr1[EAttrTypeL1.PHY_BREAK_PROB] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_FORGET) {//忽视抗遗忘
this.attr1[EAttrTypeL1.HK_FORGET] = Math.floor(this.attr1[EAttrTypeL1.HK_FORGET] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.S_GOLD) {//强力克金
this.attr1[EAttrTypeL1.S_GOLD] = Math.floor(this.attr1[EAttrTypeL1.S_GOLD] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.S_WOOD) {//强力克木
this.attr1[EAttrTypeL1.S_WOOD] = Math.floor(this.attr1[EAttrTypeL1.S_WOOD] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.S_WATER) {//强力克水
this.attr1[EAttrTypeL1.S_WATER] = Math.floor(this.attr1[EAttrTypeL1.S_WATER] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.S_FIRE) {//强力克火
this.attr1[EAttrTypeL1.S_FIRE] = Math.floor(this.attr1[EAttrTypeL1.S_FIRE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.S_SOIL) {//强力克土
this.attr1[EAttrTypeL1.S_SOIL] = Math.floor(this.attr1[EAttrTypeL1.S_SOIL] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.KB_WIND) {//风系狂暴率
this.attr1[EAttrTypeL1.KB_WIND] = Math.floor(this.attr1[EAttrTypeL1.KB_WIND] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.KB_FIRE) {//火系狂暴率
this.attr1[EAttrTypeL1.KB_FIRE] = Math.floor(this.attr1[EAttrTypeL1.KB_FIRE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.KB_WATER) {//水系狂暴率
this.attr1[EAttrTypeL1.KB_WATER] = Math.floor(this.attr1[EAttrTypeL1.KB_WATER] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.KB_THUNDER) {//雷系狂暴率
this.attr1[EAttrTypeL1.KB_THUNDER] = Math.floor(this.attr1[EAttrTypeL1.KB_THUNDER] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.KB_BLOODRETURN) {//三尸狂暴率
this.attr1[EAttrTypeL1.KB_BLOODRETURN] = Math.floor(this.attr1[EAttrTypeL1.KB_BLOODRETURN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.KB_WILDFIRE) {//鬼火狂暴率
this.attr1[EAttrTypeL1.KB_WILDFIRE] = Math.floor(this.attr1[EAttrTypeL1.KB_WILDFIRE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.Q_BLOODRETURN) {//三尸狂暴
this.attr1[EAttrTypeL1.Q_BLOODRETURN] = Math.floor(this.attr1[EAttrTypeL1.Q_BLOODRETURN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.Q_WILDFIRE) {//鬼火狂暴
this.attr1[EAttrTypeL1.Q_WILDFIRE] = Math.floor(this.attr1[EAttrTypeL1.Q_WILDFIRE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.Q_WIND) {//风系狂暴
this.attr1[EAttrTypeL1.Q_WIND] = Math.floor(this.attr1[EAttrTypeL1.Q_WIND] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.Q_FIRE) {//火系狂暴
this.attr1[EAttrTypeL1.Q_FIRE] = Math.floor(this.attr1[EAttrTypeL1.Q_FIRE] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.Q_WATER) {//水系狂暴
this.attr1[EAttrTypeL1.Q_WATER] = Math.floor(this.attr1[EAttrTypeL1.Q_WATER] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.Q_THUNDER) {//雷系狂暴
this.attr1[EAttrTypeL1.Q_THUNDER] = Math.floor(this.attr1[EAttrTypeL1.Q_THUNDER] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.WATER_EHAN) {//强水
this.attr1[EAttrTypeL1.WATER_EHAN] = Math.floor(this.attr1[EAttrTypeL1.WATER_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.FIRE_EHAN) {//强火
this.attr1[EAttrTypeL1.FIRE_EHAN] = Math.floor(this.attr1[EAttrTypeL1.FIRE_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.WIND_EHAN) {//强风
this.attr1[EAttrTypeL1.WIND_EHAN] = Math.floor(this.attr1[EAttrTypeL1.WIND_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.THUNDER_EHAN) {//强雷
this.attr1[EAttrTypeL1.THUNDER_EHAN] = Math.floor(this.attr1[EAttrTypeL1.THUNDER_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.CHAOS_EHAN) {//强雷
this.attr1[EAttrTypeL1.CHAOS_EHAN] = Math.floor(this.attr1[EAttrTypeL1.CHAOS_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.SEAL_EHAN) {//强雷
this.attr1[EAttrTypeL1.SEAL_EHAN] = Math.floor(this.attr1[EAttrTypeL1.SEAL_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.DEFEND_ADD_EHAN) {//强雷
this.attr1[EAttrTypeL1.DEFEND_ADD_EHAN] = Math.floor(this.attr1[EAttrTypeL1.DEFEND_ADD_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.SPD_ADD_EHAN) {//强雷
this.attr1[EAttrTypeL1.SPD_ADD_EHAN] = Math.floor(this.attr1[EAttrTypeL1.SPD_ADD_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.DETER_EHAN) {//强雷
this.attr1[EAttrTypeL1.DETER_EHAN] = Math.floor(this.attr1[EAttrTypeL1.DETER_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.SLEEP_EHAN) {//强雷
this.attr1[EAttrTypeL1.SLEEP_EHAN] = Math.floor(this.attr1[EAttrTypeL1.SLEEP_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.TOXIN_EHAN) {//强毒
this.attr1[EAttrTypeL1.TOXIN_EHAN] = Math.floor(this.attr1[EAttrTypeL1.TOXIN_EHAN] * (1 + ret.add / 100));
} else if (type == EAttrTypeL1.HK_POISON) {//忽视抗毒
this.attr1[EAttrTypeL1.HK_POISON] = Math.floor(this.attr1[EAttrTypeL1.HK_POISON] * (1 + ret.add / 100));
}
} else {
this.attr1[type] = this.attr1[type];
}
}
}
}
checkOfudaBySkillId(skillid: any) {
let ofuda_map = Ofuda.shared.inUseOfudaByRoleid(this.roleid);
if (ofuda_map == null || ofuda_map == undefined || ofuda_map.size < 0) {
return false;
}
for (let [key, value] of ofuda_map) {
if (key == skillid) {
return true;
}
}
return false;
}
// 基础百分比气血等 属性放在 等级计算等级之后
calculateEquipBaseAttr() {
if (this.currentEquips) {
let list = [EAttrTypeL1.HP_ADD, EAttrTypeL1.MP_ADD, EAttrTypeL1.ATK_ADD, EAttrTypeL1.SPD_ADD, EAttrTypeL1.HP_PERC, EAttrTypeL1.MP_PERC, EAttrTypeL1.ATK_PERC, EAttrTypeL1.SPD_PERC]; //, EAttrTypeL1.AATK, EAttrTypeL1.ASPD
for (let equip of this.currentEquips) {
for (let key in EAttrTypeL1) {
let value = SKDataUtil.numberBy(key);
if (isNaN(value)) {
continue;
}
if (list.indexOf(value) == -1) {
continue;
}
let equipattr = equip.getAttr(value);
if (equipattr == null || equipattr == 0) {
continue;
}
let addattr = GameUtil.attrToBaseAttr[value];
if (addattr != null) {
let target_attr = addattr.target;
if (addattr.cal == EAttrCalType.ADD_PERCENT) {
this.attr1[target_attr] = Math.floor((1 + equipattr / 100) * this.attr1[target_attr]);
} else if (addattr.cal == EAttrCalType.PERCENT) {
this.attr1[target_attr] = Math.floor((1 + equipattr / 100) * this.attr1[target_attr]);
} else if (addattr.cal == EAttrCalType.ADD_NUM) {
this.attr1[target_attr] = Math.floor(this.attr1[target_attr] + equipattr);
}
} else {
this.attr1[value] = Math.floor(this.attr1[value] + equipattr);
}
}
}
}
let ofuda_map = Ofuda.shared.inUseOfudaByRoleid(this.roleid);
if (ofuda_map != null && ofuda_map != undefined && ofuda_map.size > 0) {
//载物符 - 通明 | 活血
for (let [key, value] of ofuda_map) {
if (key == ESkillType.TongMing1 || key == ESkillType.TongMing2 || key == ESkillType.TongMing3) {
let skill = SkillUtil.getSkill(key);
let addition = this.calcOfudaSkill(skill, value.addition);
this.attr1[EAttrTypeL1.MP] += Math.floor(this.attr1[EAttrTypeL1.MP_MAX] * (addition / 100));
}
if (key == ESkillType.HuoXue1 || key == ESkillType.HuoXue2 || key == ESkillType.HuoXue3) {
let skill = SkillUtil.getSkill(key);
let addition = this.calcOfudaSkill(skill, value.addition);
this.attr1[EAttrTypeL1.HP] += Math.floor(this.attr1[EAttrTypeL1.HP_MAX] * (addition / 100));
}
}
}
// if(this.attr1[EAttrTypeL1.MP] > this.attr1[EAttrTypeL1.MP_MAX]){
// this.attr1[EAttrTypeL1.MP] = this.attr1[EAttrTypeL1.MP_MAX]
// }
// if(this.attr1[EAttrTypeL1.HP] > this.attr1[EAttrTypeL1.HP_MAX]){
// this.attr1[EAttrTypeL1.HP] = this.attr1[EAttrTypeL1.HP_MAX]
// }
}
addXiulianPoint(data: any) {
if (!data) {
return;
}
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
// 重置修炼点
if (data.type == 0) {
let strErr = this.CostFee(GameUtil.goldKind.Money, 200000);
if (strErr != '') {
return;
}
this.resetXiulianPoint();
this.calculateAttr();
this.send('s2c_player_data', this.getData());
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
this.schemeMgr && this.schemeMgr.syncSchemePoint();
if (player) {
//cxf重置修炼点
SKCxfUtil.getCxfRecordOperate({
roleId: player.roleid,
roleName: player.name,
operateType: Operate.PLAYER,
operateDepict: "重置修炼点",
operateResSerial: player.roleid,
operateResName: player.name,
operateContent: ""
})
}
return;
}
if (data.type == 1) {
let sumpoint = 0;
let addpoint: any = {};
addpoint = SKDataUtil.jsonBy(data.info);
for (const key in addpoint) {
sumpoint += addpoint[key];
}
/*
let curpoint = 0;
for (const key in this.addattr1) {
curpoint += this.addattr1[key];
}
if (sumpoint + curpoint > this.xiulevel) {
return;
}
*/
if (sumpoint > this.xiulevel) {
return;
}
for (const key in addpoint) {
if (this.addattr1[key] == null) {
this.addattr1[key] = 0;
}
if (Number(key) == 1000) {
if (this.race == 1 && (this.addattr1[key] + addpoint[key] > 32)) {
this.send_notice(`上限为180点`);
return;
}
if ((this.race == 2 || this.race == 5) && (this.addattr1[key] + addpoint[key] > 20)) {
this.send_notice(`上限为150点`);
return;
}
if ((this.race == 3 || this.race == 4) && (this.addattr1[key] + addpoint[key] > 24)) {
this.send_notice(`上限为160点`);
return;
}
}
this.addattr1[key] += addpoint[key];
}
}
this.checkXiulianPoint();
this.calculateAttr();
if (player) {
//帮派修炼
SKCxfUtil.getCxfRecordOperate({
roleId: player.roleid,
roleName: player.name,
operateType: Operate.PLAYER,
operateDepict: "帮派修炼",
operateResSerial: player.roleid,
operateResName: player.name,
operateContent: ""
})
}
this.send('s2c_player_data', this.getData());
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
}
resetRolePoint() {
//重置加点
this.addattr2[EAttrTypeL2.GENGU] = 0;
this.addattr2[EAttrTypeL2.LINGXING] = 0;
this.addattr2[EAttrTypeL2.MINJIE] = 0;
this.addattr2[EAttrTypeL2.LILIANG] = 0;
for (let equip of this.currentEquips) {
this.addEquipList(equip);
}
this.currentEquips = [];
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
//cxf重置加点
SKCxfUtil.getCxfRecordOperate({
roleId: player.roleid,
roleName: player.name,
operateType: Operate.PLAYER,
operateDepict: "重置加点",
operateResSerial: player.roleid,
operateResName: player.name,
operateContent: ""
})
}
this.changeWeapon(null);
}
resetXiulianPoint() {
for (const key in this.addattr1) {
this.addattr1[key] = 0;
}
}
xiulianUpgrade(data: any) {
let maxxiulian = RolePracticeMgr.shared.GetMaxPriactiveLevel(this.relive);
if (this.xiulevel < maxxiulian) {
if (this.bangscore >= data.score) {
this.bangscore -= data.score;
DB.updateMoney({ bind_jade: this.bind_jade, shiscore: this.shiscore, bangscore: this.bangscore, discore: this.discore, xiuscore: this.xiuscore, guoscore: this.guoscore, roleid: this.roleid });
this.xiulevel++;
this.send('s2c_player_data', this.getData());
this.send('s2c_notice', {
strRichText: '获得1个修炼点'
});
} else {
this.send_notice("帮贡不足");
return;
}
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
//cxf帮派修炼等级
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.PLAYER,
operateDepict: "帮派修炼等级",
operateResSerial: this.bangid,
operateResName: this.name,
operateContent: ""
})
}
this.schemeMgr && this.schemeMgr.syncSchemePoint();
} else {
this.send('s2c_notice', {
strRichText: '修炼点已达到上限'
});
}
}
getEquipAttr(attrtype: number): number {
let tmp = 0;
for (const equip of this.currentEquips) {
tmp += equip.getAttr(attrtype);
}
return tmp;
}
calculateLevel() {
let int = Math.floor;
let E = int((100 - this.level) / 5);
let L = this.level;
let Gs: any = GameUtil.growPre[this.race];
let P = this.getAttr1(EAttrTypeL2.GENGU); // + this.getEquipAttr(EAttrTypeL1.GENGU);
let G = Gs[EAttrTypeL2.GENGU];
let base = GameUtil.baseAttr[this.race][EAttrTypeL1.HP];
let Fs: any = this.getReliveFix();
let F: any = (Fs[EAttrTypeL1.HP] != null) ? Fs[EAttrTypeL1.HP] : 1;
let hp = int((int((L + E) * P * G + base) + this.getEquipAttr(EAttrTypeL1.HP_MAX)) * (1 + F / 100));
P = this.getAttr1(EAttrTypeL2.LINGXING); // + this.getEquipAttr(EAttrTypeL1.LINGXING);
G = Gs[EAttrTypeL2.LINGXING];
base = GameUtil.baseAttr[this.race][EAttrTypeL1.MP];
F = (Fs[EAttrTypeL1.MP] != null) ? Fs[EAttrTypeL1.MP] : 1;
let mp = int((int((L + E) * P * G + base) + this.getEquipAttr(EAttrTypeL1.MP_MAX)) * (1 + F / 100));
P = this.getAttr1(EAttrTypeL2.LILIANG); // + this.getEquipAttr(EAttrTypeL1.LILIANG);
G = Gs[EAttrTypeL2.LILIANG];
base = GameUtil.baseAttr[this.race][EAttrTypeL1.ATK];
F = (Fs[EAttrTypeL1.ATK] != null) ? Fs[EAttrTypeL1.ATK] : 1;
let atk = int((L + E) * P * G / 5 + base + this.getEquipAttr(EAttrTypeL1.ATK) * (1 + F / 100));
P = this.getAttr1(EAttrTypeL2.MINJIE); // + this.getEquipAttr(EAttrTypeL1.MINJIE);
G = Gs[EAttrTypeL2.MINJIE];
base = GameUtil.baseAttr[this.race][EAttrTypeL1.SPD];
F = (Fs[EAttrTypeL1.SPD] != null) ? Fs[EAttrTypeL1.SPD] : 1;
let spd = int((int((10 + P) * G) + this.getEquipAttr(EAttrTypeL1.SPD)) * (1 + F / 100))
this.attr1[EAttrTypeL1.HP] = hp;
this.attr1[EAttrTypeL1.HP_MAX] = hp;
this.attr1[EAttrTypeL1.MP] = mp;
this.attr1[EAttrTypeL1.MP_MAX] = mp;
this.attr1[EAttrTypeL1.ATK] = atk;
this.attr1[EAttrTypeL1.SPD] = spd;
this.calculateEquipBaseAttr();
this.hp = this.attr1[EAttrTypeL1.HP];
this.maxhp = this.attr1[EAttrTypeL1.HP];
this.mp = this.attr1[EAttrTypeL1.MP];
this.maxmp = this.attr1[EAttrTypeL1.MP];
this.atk = this.attr1[EAttrTypeL1.ATK];
this.spd = this.attr1[EAttrTypeL1.SPD];
this.attr1[EAttrTypeL1.HP_MAX] = this.attr1[EAttrTypeL1.HP];
this.attr1[EAttrTypeL1.MP_MAX] = this.attr1[EAttrTypeL1.MP];
if (this.race == ERaceType.HUMEN) {
// 抗混乱 封印 毒 昏睡 每4级 + 1
this.attr1[EAttrTypeL1.K_CONFUSION] += 0 + int(L / 4);
this.attr1[EAttrTypeL1.K_SEAL] += 0 + int(L / 4);
this.attr1[EAttrTypeL1.K_SLEEP] += 0 + int(L / 4);
this.attr1[EAttrTypeL1.K_POISON] += 0 + int(L / 4);
} else if (this.race == ERaceType.SKY) {
this.attr1[EAttrTypeL1.K_WATER] += 0 + int(L / 8);
this.attr1[EAttrTypeL1.K_FIRE] += 0 + int(L / 8);
this.attr1[EAttrTypeL1.K_THUNDER] += 0 + int(L / 8);
this.attr1[EAttrTypeL1.K_WIND] += 0 + int(L / 8);
} else if (this.race == ERaceType.DEMON) {
this.attr1[EAttrTypeL1.K_PHY_GET] += 0 + int(L / 8);
this.attr1[EAttrTypeL1.K_CONFUSION] += 0 + int(L / 8);
this.attr1[EAttrTypeL1.K_SEAL] += 0 + int(L / 8);
this.attr1[EAttrTypeL1.K_SLEEP] += 0 + int(L / 8);
this.attr1[EAttrTypeL1.K_POISON] += 0 + int(L / 8);
this.attr1[EAttrTypeL1.K_WATER] += 0 + int(L / 12);
this.attr1[EAttrTypeL1.K_FIRE] += 0 + int(L / 12);
this.attr1[EAttrTypeL1.K_THUNDER] += 0 + int(L / 12);
this.attr1[EAttrTypeL1.K_WIND] += 0 + int(L / 12);
} else if (this.race == ERaceType.GHOST) {
this.attr1[EAttrTypeL1.K_CONFUSION] += 0 + int(L / 6);
this.attr1[EAttrTypeL1.K_SEAL] += 0 + int(L / 6);
this.attr1[EAttrTypeL1.K_SLEEP] += 0 + int(L / 6);
this.attr1[EAttrTypeL1.K_POISON] += 0 + int(L / 6);
this.attr1[EAttrTypeL1.K_FORGET] += 0 + int(L / 6);
this.attr1[EAttrTypeL1.K_WILDFIRE] += 0 + int(L / 6);
this.attr1[EAttrTypeL1.K_BLOODRETURN] += 0 + int(L / 6);
this.attr1[EAttrTypeL1.K_WATER] += 0 - int(L / 8);
this.attr1[EAttrTypeL1.K_FIRE] += 0 - int(L / 8);
this.attr1[EAttrTypeL1.K_THUNDER] += 0 - int(L / 8);
this.attr1[EAttrTypeL1.K_WIND] += 0 - int(L / 8);
this.attr1[EAttrTypeL1.PHY_HIT] += 0 + int(L / 4);
this.attr1[EAttrTypeL1.PHY_DODGE] += 0 + int(L / 4);
}
}
getReliveFix(): any {
let result: any = {};
let relivefixs: any[] = [GameUtil.reliveFixAttr1, GameUtil.reliveFixAttr2, GameUtil.reliveFixAttr3, GameUtil.reliveFixAttr4]
for (let index = 0; index < this.relive; index++) {
let rerace = this.relivelist[index][0];
let resex = this.relivelist[index][1];
let item: any = relivefixs[index][rerace];
if (item == null) {
continue;
}
let temp: any = item[resex];
for (const attr1 in temp) {
const num = temp[attr1];
if (result[attr1] == null) {
result[attr1] = 0;
}
result[attr1] += num;
}
}
return result;
}
calculateReliveAttr() {
if (this.relive == 0) {
return;
}
let list = [EAttrTypeL1.HP, EAttrTypeL1.HP_MAX, EAttrTypeL1.MP, EAttrTypeL1.MP_MAX, EAttrTypeL1.ATK, EAttrTypeL1.SPD];
let fixed = this.getReliveFix();
for (let key in fixed) {
if (fixed.hasOwnProperty(key)) {
const addattr = fixed[key];
const id = parseInt(key);
if (list.indexOf(id) == -1) {
this.attr1[key] += addattr;
} else {
// this.attr1[key] = Math.ceil(this.attr1[key] * (1 + addattr / 100));
}
}
}
}
calculateXiuAttr() {
let tempK_SLEEP: number = 0;
let tempK_SEAL: number = 0;
let tempK_CONFUSION: number = 0;
let tempK_FORGET: number = 0;
let temp_Max: number = 0;
this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] = 100 + (this.addattr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] == null ? 0 : this.addattr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] * 2.5);
this.attr1[EAttrTypeL1.K_SEAL] += (this.addattr1[EAttrTypeL1.K_SEAL] == null ? 0 : this.addattr1[EAttrTypeL1.K_SEAL] * 5);
this.attr1[EAttrTypeL1.K_CONFUSION] += (this.addattr1[EAttrTypeL1.K_CONFUSION] == null ? 0 : this.addattr1[EAttrTypeL1.K_CONFUSION] * 5);
this.attr1[EAttrTypeL1.K_SLEEP] += (this.addattr1[EAttrTypeL1.K_SLEEP] == null ? 0 : this.addattr1[EAttrTypeL1.K_SLEEP] * 5);
this.attr1[EAttrTypeL1.K_FORGET] += (this.addattr1[EAttrTypeL1.K_FORGET] == null ? 0 : this.addattr1[EAttrTypeL1.K_FORGET] * 5);
tempK_SEAL = this.attr1[EAttrTypeL1.K_SEAL];
tempK_CONFUSION = this.attr1[EAttrTypeL1.K_CONFUSION];
tempK_SLEEP = this.attr1[EAttrTypeL1.K_SLEEP];
tempK_FORGET = this.attr1[EAttrTypeL1.K_FORGET];
SKLogger.warn("---------1111111111111111111---" + tempK_SEAL + "-抗封印-" + tempK_CONFUSION + "-抗混乱-" + tempK_SLEEP + "-抗昏睡--" + tempK_FORGET)
if (this.attr1[EAttrTypeL1.K_SEAL] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]) {
this.attr1[EAttrTypeL1.K_SEAL] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
}
if (this.attr1[EAttrTypeL1.K_CONFUSION] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]) {
this.attr1[EAttrTypeL1.K_CONFUSION] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
}
if (this.attr1[EAttrTypeL1.K_SLEEP] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]) {
this.attr1[EAttrTypeL1.K_SLEEP] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
}
if (this.attr1[EAttrTypeL1.K_FORGET] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]) {
this.attr1[EAttrTypeL1.K_FORGET] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
}
/*
if(this.race == ERaceType.HUMEN){
if (this.attr1[EAttrTypeL1.K_SEAL] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN]) {
this.attr1[EAttrTypeL1.K_SEAL] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN];
}
}else if(this.race == ERaceType.DRAGON){
if (this.attr1[EAttrTypeL1.K_SEAL] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG]) {
this.attr1[EAttrTypeL1.K_SEAL] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG];
}
}else{
if (this.attr1[EAttrTypeL1.K_SEAL] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]) {
this.attr1[EAttrTypeL1.K_SEAL] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
}
}
if(this.race == ERaceType.HUMEN){
if (this.attr1[EAttrTypeL1.K_CONFUSION] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN]) {
this.attr1[EAttrTypeL1.K_CONFUSION] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN];
}
}else if(this.race == ERaceType.DRAGON){
if (this.attr1[EAttrTypeL1.K_CONFUSION] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG]) {
this.attr1[EAttrTypeL1.K_CONFUSION] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG];
}
}else{
if (this.attr1[EAttrTypeL1.K_CONFUSION] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]) {
this.attr1[EAttrTypeL1.K_CONFUSION] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
}
}
if(this.race == ERaceType.HUMEN){
if (this.attr1[EAttrTypeL1.K_SLEEP] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN]) {
this.attr1[EAttrTypeL1.K_SLEEP] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN];
}
}else if(this.race == ERaceType.DRAGON){
if (this.attr1[EAttrTypeL1.K_SLEEP] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG]) {
this.attr1[EAttrTypeL1.K_SLEEP] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG];
}
}else{
if (this.attr1[EAttrTypeL1.K_SLEEP] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]) {
this.attr1[EAttrTypeL1.K_SLEEP] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
}
}
if(this.race == ERaceType.HUMEN){
if (this.attr1[EAttrTypeL1.K_FORGET] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN]) {
this.attr1[EAttrTypeL1.K_FORGET] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN];
}
}else if(this.race == ERaceType.DRAGON){
if (this.attr1[EAttrTypeL1.K_FORGET] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG]) {
this.attr1[EAttrTypeL1.K_FORGET] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG];
}
}else{
if (this.attr1[EAttrTypeL1.K_FORGET] > this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]) {
this.attr1[EAttrTypeL1.K_FORGET] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
}
}
*/
if (this.race == ERaceType.HUMEN) {
if (this.attr1[EAttrTypeL1.K_FORGET] > 180) {
this.attr1[EAttrTypeL1.K_FORGET] = 180;
}
if (this.attr1[EAttrTypeL1.K_SLEEP] > 180) {
this.attr1[EAttrTypeL1.K_SLEEP] = 180;
}
if (this.attr1[EAttrTypeL1.K_CONFUSION] > 180) {
this.attr1[EAttrTypeL1.K_CONFUSION] = 180;
}
if (this.attr1[EAttrTypeL1.K_SEAL] > 180) {
this.attr1[EAttrTypeL1.K_SEAL] = 180
}
temp_Max = 180;
} else if (this.race == ERaceType.DRAGON || this.race == ERaceType.SKY) {
if (this.attr1[EAttrTypeL1.K_FORGET] > 150) {
this.attr1[EAttrTypeL1.K_FORGET] = 150;
}
if (this.attr1[EAttrTypeL1.K_SLEEP] > 150) {
this.attr1[EAttrTypeL1.K_SLEEP] = 150;
}
if (this.attr1[EAttrTypeL1.K_CONFUSION] > 150) {
this.attr1[EAttrTypeL1.K_CONFUSION] = 150;
}
if (this.attr1[EAttrTypeL1.K_SEAL] > 150) {
this.attr1[EAttrTypeL1.K_SEAL] = 150
}
temp_Max = 150;
} else {
if (this.attr1[EAttrTypeL1.K_FORGET] > 160) {
this.attr1[EAttrTypeL1.K_FORGET] = 160;
}
if (this.attr1[EAttrTypeL1.K_SLEEP] > 160) {
this.attr1[EAttrTypeL1.K_SLEEP] = 160;
}
if (this.attr1[EAttrTypeL1.K_CONFUSION] > 160) {
this.attr1[EAttrTypeL1.K_CONFUSION] = 160;
}
if (this.attr1[EAttrTypeL1.K_SEAL] > 160) {
this.attr1[EAttrTypeL1.K_SEAL] = 160
}
temp_Max = 160;
}
let ofuda_map = Ofuda.shared.inUseOfudaByRoleid(this.roleid);
if (ofuda_map != null && ofuda_map != undefined && ofuda_map.size > 0) {
//载物符 - 明镜 | 清明 | 沉着 | 强心
for (let [key, value] of ofuda_map) {
if (key == ESkillType.MingJing1 || key == ESkillType.MingJing2 || key == ESkillType.MingJing3) {
let skill = SkillUtil.getSkill(key);
let addition = this.calcOfudaSkill(skill, value.addition);
// if(this.race == ERaceType.HUMEN){
// if (tempK_SEAL > (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN] + addition)) {
// this.attr1[EAttrTypeL1.K_SEAL] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN] + addition;
// }
// }else if(this.race == ERaceType.DRAGON){
// if (tempK_SEAL > (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG] + addition)) {
// this.attr1[EAttrTypeL1.K_SEAL] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG] + addition;
// }
// }else{
if (tempK_SEAL >= (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + addition)) {
this.attr1[EAttrTypeL1.K_SEAL] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + addition;
} else if (tempK_SEAL >= temp_Max) {
this.attr1[EAttrTypeL1.K_SEAL] = tempK_SEAL;
}
//}
}
if (key == ESkillType.QingMing1 || key == ESkillType.QingMing2 || key == ESkillType.QingMing3) {
let skill = SkillUtil.getSkill(key);
let addition = this.calcOfudaSkill(skill, value.addition);
// if(this.race == ERaceType.HUMEN){
// if (tempK_CONFUSION > (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN] + addition)) {
// this.attr1[EAttrTypeL1.K_CONFUSION] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN] + addition;
// }
// }else if(this.race == ERaceType.DRAGON){
// if (tempK_CONFUSION > (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG] + addition)) {
// this.attr1[EAttrTypeL1.K_CONFUSION] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG] + addition;
// }
// }else{
if (tempK_CONFUSION >= (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + addition)) {
this.attr1[EAttrTypeL1.K_CONFUSION] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + addition;
} else if (tempK_CONFUSION >= temp_Max) {
this.attr1[EAttrTypeL1.K_CONFUSION] = tempK_CONFUSION;
}
//}
}
if (key == ESkillType.ChenZhuo1 || key == ESkillType.ChenZhuo2 || key == ESkillType.ChenZhuo3) {
let skill = SkillUtil.getSkill(key);
let addition = this.calcOfudaSkill(skill, value.addition);
// if(this.race == ERaceType.HUMEN){
// if (tempK_SLEEP > (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN] + addition)) {
// this.attr1[EAttrTypeL1.K_SLEEP] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN] + addition;
// }
// }else if(this.race == ERaceType.DRAGON){
// if (tempK_SLEEP > (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG] + addition)) {
// this.attr1[EAttrTypeL1.K_SLEEP] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG] + addition;
// }
// }else{
if (tempK_SLEEP >= (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + addition)) {
this.attr1[EAttrTypeL1.K_SLEEP] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + addition;
} else if (tempK_SLEEP >= temp_Max) {
this.attr1[EAttrTypeL1.K_SLEEP] = tempK_SLEEP;
}
//}
}
if (key == ESkillType.QiangXin1 || key == ESkillType.QiangXin2 || key == ESkillType.QiangXin3) {
let skill = SkillUtil.getSkill(key);
let addition = this.calcOfudaSkill(skill, value.addition);
// if(this.race == ERaceType.HUMEN){
// if (tempK_FORGET > (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN] + addition)) {
// this.attr1[EAttrTypeL1.K_FORGET] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_REN] + addition;
// }
// }else if(this.race == ERaceType.DRAGON){
// if (tempK_FORGET > (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG] + addition)) {
// this.attr1[EAttrTypeL1.K_FORGET] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_LIMIT_LONG] + addition;
// }
// }else{
if (tempK_FORGET >= (this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + addition)) {
this.attr1[EAttrTypeL1.K_FORGET] = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + addition;
} else if (tempK_FORGET >= temp_Max) {
this.attr1[EAttrTypeL1.K_FORGET] = tempK_FORGET;
}
//}
}
}
}
SKLogger.warn("---------2222222---" + this.attr1[EAttrTypeL1.K_SEAL] + "-抗封印-" + this.attr1[EAttrTypeL1.K_CONFUSION] + "-抗混乱-" + this.attr1[EAttrTypeL1.K_SLEEP] + "-抗昏睡--" + this.attr1[EAttrTypeL1.K_FORGET])
this.attr1[EAttrTypeL1.K_WIND] += (this.addattr1[EAttrTypeL1.K_WIND] == null ? 0 : this.addattr1[EAttrTypeL1.K_WIND] * 5);
this.attr1[EAttrTypeL1.K_THUNDER] += (this.addattr1[EAttrTypeL1.K_THUNDER] == null ? 0 : this.addattr1[EAttrTypeL1.K_THUNDER] * 5);
this.attr1[EAttrTypeL1.K_WATER] += (this.addattr1[EAttrTypeL1.K_WATER] == null ? 0 : this.addattr1[EAttrTypeL1.K_WATER] * 5);
this.attr1[EAttrTypeL1.K_FIRE] += (this.addattr1[EAttrTypeL1.K_FIRE] == null ? 0 : this.addattr1[EAttrTypeL1.K_FIRE] * 5);
this.attr1[EAttrTypeL1.K_WILDFIRE] += (this.addattr1[EAttrTypeL1.K_WILDFIRE] == null ? 0 : this.addattr1[EAttrTypeL1.K_WILDFIRE] * 5);
this.attr1[EAttrTypeL1.K_BLOODRETURN] += (this.addattr1[EAttrTypeL1.K_BLOODRETURN] == null ? 0 : this.addattr1[EAttrTypeL1.K_BLOODRETURN] * 5);
this.attr1[EAttrTypeL1.K_POISON] += (this.addattr1[EAttrTypeL1.K_POISON] == null ? 0 : this.addattr1[EAttrTypeL1.K_POISON] * 5);
this.attr1[EAttrTypeL1.PHY_GET] += (this.addattr1[EAttrTypeL1.PHY_GET] == null ? 0 : this.addattr1[EAttrTypeL1.PHY_GET] * 4);
}
// 是否为机器人
isRobot(): boolean {
if (this.ai) {
return true;
}
return false;
}
// 全部存档
saveAll(callback: (failed: string[]) => void) {
if (this.roleid != undefined && this.resid != undefined) {
let prefix: string = `${this.isRobot() ? `机器人` : `玩家`}`;
if (this.saveTotal > 0) {
SKLogger.warn(`${prefix}[${this.roleid}:${this.name}]正在存档中,当前存档:${this.saveTotal}`);
return;
}
if (!this.loaded) {
SKLogger.warn(`${prefix}[${this.roleid}:${this.name}]没有加载完成稍后存档`);
callback([]);
return;
}
if (this.ai_flag != 1) {
this.saveTotal = 5; // 检查是否存档完成 套装,召唤兽,坐骑列表,坐骑技能,玩家
this.saveFailed = [];
let equipSQL = '';
for (const equip of this.currentEquips) {
equipSQL += equip.saveSQL();
}
for (const equip of this.listEquips) {
equipSQL += equip.saveSQL();
}
for (let equip of this.lockerEquips) {
equipSQL += equip.saveSQL();
}
if (this.mapid == 3002) {
this.mapid = 1011;
this.x = 237;
this.y = 19;
}
if (this.mapid == 1201 && !this.inPrison) {
this.mapid = 1011;
this.x = 112;
this.y = 78;
}
let titles = SKDataUtil.toJson({
onload: this.onLoad,
titles: this.titles,
}, "{}");
let partnerList: string = "";
if (this.partnerMgr) {
partnerList = this.partnerMgr.toJson();
}
let color = { c1: this.color1, c2: this.color2, p1: this.color_one_serial, p2: this.color_two_serial };
let friendlist = SKDataUtil.clone(this.friendList);
for (let roleid in friendlist) {
if (friendlist.hasOwnProperty(roleid)) {
if (roleid == 'version') {
continue;
}
let finfo = friendlist[roleid];
finfo.name = Buffer.from(finfo.name).toString('base64');
}
}
friendlist.version = 1;
let dbinfo = {
accountid: this.accountid,
name: this.name,
mapid: this.mapid,
x: this.x,
y: this.y,
addpoint: this.addattr2,
xiupoint: this.addattr1,
xiulevel: this.xiulevel,
pet: this.curPetId,
friendlist: friendlist,
equipinfo: equipSQL,
bagitem: this.bag_list,
bangid: this.bangid,
taskstate: this.taskStateToJson(),
partnerlist: partnerList,
lockeritem: this.locker_list,
skill: this.skill_list,
money: this.money,
jade: this.jade,
bind_jade: this.bind_jade,
bang_score: this.bangscore,
shi_score: this.shiscore,
di_score: this.discore,
xiu_score: this.xiuscore,
guo_score: this.guoscore,
exp: this.exp,
level: this.level,
level_reward: this.level_reward,
resid: this.resid,
race: this.race,
sex: this.sex,
relive: this.relive,
relivelist: this.relivelist,
shane: this.shane,
state: this.nFlag,
rewardrecord: this.rewardrecord,
sprewardrecord: this.sprewardrecord,
getgift: this.getgift,
shuilu: this.shuilu,
arena: this.arena,
titles: titles,
active_scheme_name: this.schemeName,
color: color,
star: this.star,
horse_index: this.horseList.horseIndex,
day_count: this.dayMap,
bagKindNum: this.bagKindNum,
mend_date: this.mend_date,
sat_integral: this.sat_integral,
offlinetime: this.offlinetime,
doublecnt: this.doublecnt,
unget_doublecnt: this.unget_doublecnt,
zhenfa: this.ZFMgr.toJson(),
xw: this.XWMgr.getXwListByJson(),
baby: this.BabyMgr.ToJson(),
star_info: this.StarMgr.ToJson(),
tianti_integral: this.tianti_integral,
};
let self = this;
DB.savePlayerInfo(this.roleid, dbinfo, (code: number, msg: string) => {
let info = `存档:${prefix}[${this.roleid}:${this.name}]角色存档`;
if (code == MsgCode.SUCCESS) {
info += `成功!`;
SKLogger.debug(info);
} else {
info += `失败:[${msg}]!`;
SKLogger.warn(info);
}
self.checkSave(code, info, callback, "玩家信息");
});
// 保存套装
if (this.schemeMgr) {
this.schemeMgr.saveDB((code: number, msg: string) => {
this.checkSave(code, msg, callback, "套装");
});
} else {
let msg = `存档:${prefix}[${this.roleid}:${this.name}]套装无需存档!`;
this.checkSave(MsgCode.SUCCESS, msg, callback, "套装");
}
// 保存召唤兽
DB.savePets(this.petList, this.roleid, (code: number, msg: string) => {
let info = `存档:${prefix}[${this.roleid}:${this.name}]召唤兽存档`;
if (code == MsgCode.SUCCESS) {
info += `成功!`;
SKLogger.debug(info);
} else {
info += `失败[${msg}]!`;
SKLogger.warn(info);
}
this.checkSave(code, msg, callback, "召唤兽");
});
this.horseList.saveDB((code: number, msg: string) => {
let info = `存档:${prefix}[${this.roleid}:${this.name}]坐骑列表存档`;
if (code == MsgCode.SUCCESS) {
info += `成功!`;
SKLogger.debug(info);
} else {
info += `失败[${msg}]!`;
SKLogger.warn(info);
}
this.checkSave(code, info, callback, "坐骑");
});
this.horseSkill.saveDB((code: number, msg: string) => {
let info = `存档:${prefix}[${this.roleid}:${this.name}]坐骑技能存档`;
if (code == MsgCode.SUCCESS) {
info += `成功!`;
SKLogger.debug(info);
} else {
info += `失败[${msg}]!`;
SKLogger.warn(info);
}
this.checkSave(code, info, callback, "坐骑技能");
});
//天策符的使用状态
let ofudaList = Ofuda.shared.getOfListByRoid(this.roleid);
if (ofudaList.length > 0) {
DB.insertOfuda(this.roleid, SKDataUtil.toJson(ofudaList, "{}"));
}
} else {
let dbinfo = {
accountid: this.accountid,
name: this.name,
mapid: this.mapid,
x: this.x,
y: this.y,
addpoint: this.addattr2,
xiupoint: this.addattr1,
xiulevel: this.xiulevel,
pet: this.curPetId,
bagitem: this.bag_list,
bangid: this.bangid,
taskstate: this.taskStateToJson(),
lockeritem: this.locker_list,
skill: this.skill_list,
money: this.money,
jade: this.jade,
bind_jade: this.bind_jade,
bang_score: this.bangscore,
shi_score: this.shiscore,
di_score: this.discore,
xiu_score: this.xiuscore,
guo_score: this.guoscore,
exp: this.exp,
level: this.level,
level_reward: this.level_reward,
resid: this.resid,
race: this.race,
sex: this.sex,
relive: this.relive,
relivelist: this.relivelist,
shane: this.shane,
state: this.nFlag,
rewardrecord: this.rewardrecord,
sprewardrecord: this.sprewardrecord,
getgift: this.getgift,
shuilu: this.shuilu,
arena: this.arena,
active_scheme_name: this.schemeName,
star: this.star,
horse_index: this.horseList.horseIndex,
day_count: this.dayMap,
bagKindNum: this.bagKindNum,
mend_date: this.mend_date,
sat_integral: this.sat_integral,
al_flag: this.ai_flag
};
DB.savePlayerInfoRobot(this.roleid, dbinfo, (code: number, msg: string) => {
let info = `机器人存档:[${this.roleid}:${this.name}]角色存档`;
if (code == MsgCode.SUCCESS) {
info += `成功!`;
SKLogger.info(info);
callback([]);
} else {
info += `失败:[${msg}]!`;
SKLogger.warn(info);
callback([]);
}
});
}
} else {
SKLogger.warn("玩家信息错误/机器人不进行存档");
callback([]);
}
}
// 保存角色签到数据
saveSignIn() {
DB.saveSignIn(SKDataUtil.toJson(this.daySignIn, "{}"), this.roleid, this.mendDate, (code: number, msg: string) => {
let info = `存档:[${this.roleid}:${this.name}]签到数据存档`;
if (code == MsgCode.SUCCESS) {
info += `成功!`;
SKLogger.info(info);
} else {
info += `失败[${msg}]!`;
SKLogger.info(info);
}
});
}
// 备用存档
saveAllReserve() {
if (this.roleid != undefined && this.resid != undefined) {
let equipSQL = '';
for (const equip of this.currentEquips) {
equipSQL += equip.saveSQL();
}
for (const equip of this.listEquips) {
equipSQL += equip.saveSQL();
}
for (let equip of this.lockerEquips) {
equipSQL += equip.saveSQL();
}
if (this.mapid == 3002) {
this.mapid = 1011;
this.x = 237;
this.y = 19;
}
if (this.mapid == 1201 && !this.inPrison) {
this.mapid = 1011;
this.x = 112;
this.y = 78;
}
let titles = SKDataUtil.toJson({
onload: this.onLoad,
titles: this.titles,
}, "{}");
let partnerList: string = "";
if (this.partnerMgr) {
partnerList = this.partnerMgr.toJson();
}
let color = { c1: this.color1, c2: this.color2, p1: this.color_one_serial, p2: this.color_two_serial };
let friendlist = SKDataUtil.clone(this.friendList);
for (let roleid in friendlist) {
if (friendlist.hasOwnProperty(roleid)) {
if (roleid == 'version') {
continue;
}
let finfo = friendlist[roleid];
finfo.name = Buffer.from(finfo.name).toString('base64');
}
}
friendlist.version = 1;
let dbinfo = {
accountid: this.accountid,
name: this.name,
mapid: this.mapid,
x: this.x,
y: this.y,
addpoint: this.addattr2,
xiupoint: this.addattr1,
xiulevel: this.xiulevel,
pet: this.curPetId,
friendlist: friendlist,
equipinfo: equipSQL,
bagitem: this.bag_list,
bangid: this.bangid,
taskstate: this.taskStateToJson(),
partnerlist: partnerList,
lockeritem: this.locker_list,
skill: this.skill_list,
money: this.money,
jade: this.jade,
bind_jade: this.bind_jade,
bang_score: this.bangscore,
shi_score: this.shiscore,
di_score: this.discore,
xiu_score: this.xiuscore,
guo_score: this.guoscore,
exp: this.exp,
level: this.level,
level_reward: this.level_reward,
resid: this.resid,
race: this.race,
sex: this.sex,
relive: this.relive,
relivelist: this.relivelist,
shane: this.shane,
state: this.nFlag,
rewardrecord: this.rewardrecord,
sprewardrecord: this.sprewardrecord,
getgift: this.getgift,
shuilu: this.shuilu,
arena: this.arena,
titles: titles,
active_scheme_name: this.schemeName,
color: color,
star: this.star,
horse_index: this.horseList.horseIndex,
day_count: this.dayMap,
bagKindNum: this.bagKindNum,
mend_date: this.mend_date,
sat_integral: this.sat_integral,
zhenfa: this.ZFMgr.toJson(),
xw: this.XWMgr.getXwListByJson(),
baby: this.BabyMgr.ToJson(),
star_info: this.StarMgr.ToJson(),
tianti_integral: this.tianti_integral,
};
DB.savePlayerInfo(this.roleid, dbinfo, (code: number, msg: string) => {
let info = `备用存档:[${this.roleid}:${this.name}]角色存档`;
if (code == MsgCode.SUCCESS) {
info += `成功!`;
SKLogger.info(info);
} else {
info += `失败:[${msg}]!`;
SKLogger.warn(info);
}
});
} else {
SKLogger.warn("备用玩家信息错误不进行存档");
}
}
// 保存角色风雨转盘数据
saveDial() {
DB.saveDial(this.roleid, this.dial_num, this.dial_count, this.dial_date, (code: number, msg: string) => {
let info = `存档:[${this.roleid}:${this.name}]风雨转盘数据存档`;
if (code == MsgCode.SUCCESS) {
info += `成功!`;
SKLogger.info(info);
} else {
info += `失败[${msg}]!`;
SKLogger.info(info);
}
});
}
// 通过CXF通讯存档
cxfSavePlayerAll() {
if (this.roleid != undefined && this.resid != undefined) {
let prefix: string = `${this.isRobot() ? `机器人` : `玩家`}`;
if (!this.loaded) {
SKLogger.warn(`${prefix}[${this.roleid}:${this.name}]没有加载完成稍后存档`);
return;
}
this.saveFailed = [];
// --------------------------------------------------- 装备存档 ----------------------------------------------------------
for (const equip of this.currentEquips) {
SKCxfUtil.getCxfSaveEquip(equip.cxfEquip(this.roleid));
}
for (const equip of this.listEquips) {
SKCxfUtil.getCxfSaveEquip(equip.cxfEquip(this.roleid));
}
for (let equip of this.lockerEquips) {
SKCxfUtil.getCxfSaveEquip(equip.cxfEquip(this.roleid));
}
// --------------------------------------------------- 玩家存档 ----------------------------------------------------------
if (this.mapid == 3002) {
this.mapid = 1011;
this.x = 237;
this.y = 19;
}
if (this.mapid == 1201 && !this.inPrison) {
this.mapid = 1011;
this.x = 112;
this.y = 78;
}
let titles = SKDataUtil.toJson({
onload: this.onLoad,
titles: this.titles,
}, "{}");
let partnerList: string = "";
if (this.partnerMgr) {
partnerList = this.partnerMgr.toJson();
}
let color = { c1: this.color1, c2: this.color2, p1: this.color_one_serial, p2: this.color_two_serial };
let friendlist = SKDataUtil.clone(this.friendList);
for (let roleid in friendlist) {
if (friendlist.hasOwnProperty(roleid)) {
if (roleid == 'version') {
continue;
}
let finfo = friendlist[roleid];
finfo.name = Buffer.from(finfo.name).toString('base64');
}
}
friendlist.version = 1;
let dbinfo = {
roleid: this.roleid,
accountid: this.accountid,
serverid: GameUtil.serverId,
name: this.name,
resid: this.resid,
race: this.race,
sex: this.sex,
relive: this.relive,
relivelist: SKDataUtil.toJson(this.relivelist, "[]"),
level: this.level,
level_reward: this.level_reward,
exp: this.exp,
money: this.money,
jade: this.jade,
bind_jade: this.bind_jade,
bang_score: this.bangscore,
shi_score: this.shiscore,
di_score: this.discore,
xiu_score: this.xiuscore,
guo_score: this.guoscore,
mapid: this.mapid,
x: this.x,
y: this.y,
bangid: this.bangid,
color: SKDataUtil.toJson(color, "{}"),
star: this.star,
shane: this.shane,
addpoint: SKDataUtil.toJson(this.addattr2, "{}"),
xiupoint: SKDataUtil.toJson(this.addattr1, "{}"),
xiulevel: this.xiulevel,
skill: SKDataUtil.toJson(this.skill_list, "{}"),
bagitem: SKDataUtil.toJson(this.bag_list, "{}"),
lockeritem: SKDataUtil.toJson(this.locker_list, "{}"),
pet: this.curPetId,
friendlist: SKDataUtil.toJson(friendlist, "{}"),
taskstate: SKDataUtil.toJson(this.taskStateToJson(), "{}"),
partnerlist: SKDataUtil.toJson(partnerList, "{}"),
state: this.nFlag,
rewardrecord: this.rewardrecord,
sprewardrecord: this.sprewardrecord,
getgift: this.getgift,
shuilu: SKDataUtil.toJson(this.shuilu, "{}"),
arena: SKDataUtil.toJson(this.arena, "{}"),
titles: titles,
activeSchemeName: this.schemeName,
horseIndex: this.horseList.horseIndex,
dayCount: SKDataUtil.toJson(this.dayMap, "{}"),
bagKindNum: this.bagKindNum,
mendDate: this.mend_date,
satIntegral: this.sat_integral,
tianti_integral: this.tianti_integral,
};
// 玩家信息存档
SKCxfUtil.getCxfSaveGamer(dbinfo);
// --------------------------------------------------- 套装存档 ----------------------------------------------------------
// 保存套装
if (this.schemeMgr) {
let schemeList: any = this.schemeMgr.schemeList;
for (let key in schemeList) {
let scheme = schemeList[key];
SKCxfUtil.getCxfSaveScheme(scheme.toObj());
}
}
// -------------------------------------------------- 召唤兽存档 ---------------------------------------------------------
for (let pet of this.petList) {
SKCxfUtil.getCxfSavePet(pet.toSaveObj())
}
// ------------------------------------------------- 坐骑列表存档 --------------------------------------------------------
for (let position in this.horseList.dict) {
let horse = this.horseList.dict[position];
if (horse) {
let horseObj: any = {};
horseObj.roleId = this.roleid;
horseObj.exp = horse.exp;
horseObj.name = horse.name;
horseObj.level = horse.level;
horseObj.position = horse.position;
SKCxfUtil.getCxfSaveHorse(horseObj);
}
}
// ------------------------------------------------- 坐骑技能存档 --------------------------------------------------------
for (let position in this.horseSkill.dict) {
let skill: any = this.horseSkill.dict[position];
if (skill) {
let horseSkillObj: any = {};
horseSkillObj.skillId = skill.skill_id;
horseSkillObj.exp = skill.exp;
horseSkillObj.position = position;
horseSkillObj.roleId = this.roleid;
SKCxfUtil.getCxfSaveHorseSkill(horseSkillObj);
}
}
}
}
// 检查存档
checkSave(code: MsgCode, msg: string, callback: (failed: string[]) => void, content: string) {
if (code != MsgCode.SUCCESS) {
this.saveFailed.push(msg);
}
SKLogger.debug(msg);
this.saveTotal--;
// SKLogger.info(`**存档:[${this.roleid}:${this.name}]存档进度${this.saveTotal}/5,当前内容:${content}`);
if (this.saveTotal > 0) {
return;
}
// SKLogger.info(`[${this.roleid}:${this.name}]完成存档${this.saveTotal}`);
callback(this.saveFailed);
}
redisSave() {
let equipSQL = '';
for (const equip of this.currentEquips) {
equipSQL += equip.saveSQL();
}
for (const equip of this.listEquips) {
equipSQL += equip.saveSQL();
}
for (let equip of this.lockerEquips) {
equipSQL += equip.saveSQL();
}
if (this.mapid == 3002) {
this.mapid = 1011;
this.x = 237;
this.y = 19;
}
if (this.mapid == 1201 && !this.inPrison) {
this.mapid = 1011;
this.x = 112;
this.y = 78;
}
let titles = SKDataUtil.toJson({
onload: this.onLoad,
titles: this.titles,
}, "{}");
let partnerList: string = "";
if (this.partnerMgr) {
partnerList = this.partnerMgr.toJson();
}
let color = { c1: this.color1, c2: this.color2, p1: this.color_one_serial, p2: this.color_two_serial };
let friendlist = SKDataUtil.clone(this.friendList);
for (let roleid in friendlist) {
if (friendlist.hasOwnProperty(roleid)) {
if (roleid == 'version') {
continue;
}
let finfo = friendlist[roleid];
finfo.name = Buffer.from(finfo.name).toString('base64');
}
}
friendlist.version = 1;
let role_data: any = {
daySignIn: SKDataUtil.toJson(this.daySignIn, "{}"),
mendDate: this.mendDate,
dial_num: this.dial_num,
dial_count: this.dial_count,
dial_date: this.dial_date,
friendList: this.friendList,
color: color,
dbinfo: {
accountid: this.accountid,
name: this.name,
mapid: this.mapid,
x: this.x,
y: this.y,
addpoint: this.addattr2,
xiupoint: this.addattr1,
xiulevel: this.xiulevel,
pet: this.curPetId,
friendlist: friendlist,
equipinfo: equipSQL,
bagitem: this.bag_list,
bangid: this.bangid,
taskstate: this.taskStateToJson(),
partnerlist: partnerList,
lockeritem: this.locker_list,
skill: this.skill_list,
money: this.money,
jade: this.jade,
bind_jade: this.bind_jade,
bang_score: this.bangscore,
shi_score: this.shiscore,
di_score: this.discore,
xiu_score: this.xiuscore,
guo_score: this.guoscore,
exp: this.exp,
level: this.level,
level_reward: this.level_reward,
resid: this.resid,
race: this.race,
sex: this.sex,
relive: this.relive,
relivelist: this.relivelist,
shane: this.shane,
state: this.nFlag,
rewardrecord: this.rewardrecord,
sprewardrecord: this.sprewardrecord,
getgift: this.getgift,
shuilu: this.shuilu,
arena: this.arena,
titles: titles,
active_scheme_name: this.schemeName,
color: color,
star: this.star,
horse_index: this.horseList.horseIndex,
day_count: this.dayMap,
bagKindNum: this.bagKindNum,
mend_date: this.mend_date,
tianti_integral: this.tianti_integral,
},
}
SKRedisUtil.setValue(this.roleid.toString(), role_data);
let pet_list: any = [];
let scheme_list: any = [];
let hourse_list: any = [];
let hourse_skill_list: any = [];
for (let key in this.petList) {
let pet = this.petList[key];
pet_list.push(pet.toSaveObj())
}
for (let key in this.schemeMgr.schemeList) {
let scheme = this.schemeMgr.schemeList[key];
scheme_list.push(scheme.toObj())
}
for (let key in this.horseList.dict) {
let hourse = this.horseList.dict[key];
hourse_list.push(hourse)
}
for (let key in this.horseSkill.dict) {
let hourses = this.horseSkill.dict[key];
hourse_skill_list.push(hourses)
}
SKRedisUtil.setValue(this.roleid + "pet", SKDataUtil.toJson(pet_list, "{}"));
SKRedisUtil.setValue(this.roleid + "scheme", SKDataUtil.toJson(scheme_list, "{}"));
SKRedisUtil.setValue(this.roleid + "hourse", SKDataUtil.toJson(hourse_list, "{}"));
SKRedisUtil.setValue(this.roleid + "hourseskill", SKDataUtil.toJson(hourse_skill_list, "{}"));
}
toObj(): any {
let teamPlayers = TeamMgr.shared.getTeamPlayer(this.teamid);
let card = ChangeCard.shared.selectUseCard(this.roleid);
let effid = SpecialEffect.shared.getSuiEffect(this.roleid)
let changeid = 0;
let effectid = 0;
if (card) {
changeid = card.resid;
}
if (effid > 0) {
effectid = effid;
}
let obj: any = super.toObj();
obj.relive = this.relive;
obj.xiulevel = this.xiulevel;
obj.level = this.level;
obj.accountid = this.accountid;
obj.roleid = this.roleid;
obj.resid = this.resid;
obj.race = this.race;
obj.sex = this.sex;
obj.spd = this.attr1[EAttrTypeL1.SPD];
obj.bangid = this.bangid;
obj.livingtype = this.living_type;
obj.teamid = this.teamid;
obj.isleader = this.isleader;
obj.teamcnt = teamPlayers == null ? 0 : teamPlayers.length;
obj.weapon = this.getWeapon();
obj.battleid = this.battle_id;
obj.bangname = this.bangname;
obj.titletype = this.titleType;
obj.titleid = this.titleId;
obj.titleval = this.titleVal;
obj.color1 = this.color1;
obj.color2 = this.color2;
obj.schemename = this.schemeName;
obj.baldric = this.baldric;
obj.safepassword = this.safe_password;
obj.safelock = this.safe_lock;
obj.horseList = this.horseList.toObj();
obj.wingId = this.wingId;
obj.sat_integral = this.sat_integral;
obj.dayMap = SKDataUtil.toJson(this.dayMap, "{}");
obj.chargesum = ChargeSum.shared.getPlayerChargeSum(this.roleid);
obj.bagKindNum = this.bagKindNum;
obj.lockerKindNum = this.lockerKindNum;
obj.tianti_integral = this.tianti_integral;
// 坐牢时间
obj.shane = this.shane
// 界面图标
obj.iconList = this.iconList;
// 出战宠物信息
let pet: any;
if (this.curPet != undefined) {
pet = {};
pet.petid = this.curPet.petid;
pet.resid = this.curPet.resid;
pet.name = this.curPet.name;
pet.spd = this.curPet.attr1[EAttrTypeL1.SPD];
pet.level = this.curPet.level;
pet.relive = this.curPet.relive;
}
obj.curPet = pet == undefined ? "" : pet;
// 最后一次时使用的技能
let role = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
let skill = ESkillType.NormalAtkSkill;
if (role != null && role != undefined) {
let brole = new BattleRole();
brole.setObj(role);
if (brole.last_skill > 0) {
skill = brole.last_skill;
}
}
obj.lastSkill = skill;
// 竞技场信息
obj.arena = this.arena;
// 签到数据
obj.daySignIn = this.daySignIn;
// 补签日期
obj.mendDate = this.mendDate;
//变身卡id
obj.changeid = changeid;
let seffectlist = [505201, 505202, 505301, 505302, 505401, 505406, 505407, 505433, 505452, 505457, 505432, 505437, 505601, 505602, 505453];
let index = Math.floor((Math.random() * seffectlist.length))
if (this.ai_flag == 0) {
//正在使用的特效
obj.effectlist = SKDataUtil.toJson(SpecialEffect.shared.getUseingEffect(this.roleid), "{}");
//随身特效
obj.effectid = effectid;
} else {
let list = [];
list.push(seffectlist[index]);
obj.effectlist = SKDataUtil.toJson(list, "{}");
obj.effectid = seffectlist[index];
}
//头像框
obj.portrait = SpecialEffect.shared.getPortraitByRoleid(this.roleid);
obj.pause = this.pause;
obj.ischeck = this.ischeck;
obj.offlinetime = this.offlinetime;
obj.doublecnt = this.doublecnt;
obj.unget_doublecnt = this.unget_doublecnt;
obj.getgift = this.getgift;
obj.isFrozen = this.isFrozen;
obj.babyList = this.BabyMgr.ToJson()
obj.xwList = this.XWMgr.ToJson()
obj.starInfo = this.StarMgr.ToJson()
this.clear_task();
// 属性检测
this.freeze();
return obj;
}
clear_task() {
// 处理部分任务不刷新
let mendDate: any = new Date(GTimer.getYearMonthDay()).getTime();
let lastDate = mendDate;
if (this.mend_date != "") {
lastDate = new Date(this.mend_date).getTime();
if (lastDate < mendDate) {
this.F5_Task();
}
} else {
this.F5_Task();
}
}
F5_Task() {
let hours: number = GTimer.getHours();
if (hours >= 5) {
if (!this.isRobot()) {
console.log("玩家:" + this.roleid + " == " + this.name + "任务刷新了~")
if (this.dbData != undefined) {
this.dbData.taskstate = null;
}
this.arena.count = 10;
this.dial_num = 1;
this.getTaskMgr().OnNewDay();
this.clearDayMap();
this.clearDayMapVip();
this.mend_date = GTimer.getYearMonthDay();
}
}
}
getWeapon() {
for (let equip of this.currentEquips) {
if (equip.EIndex == 1) {
let equipobj: any = {};
equipobj.equipid = equip.EquipID;
equipobj.gemcnt = equip.GemCnt;
equipobj.type = equip.EquipType;
equipobj.level = equip.Grade;
return SKDataUtil.toJson(equipobj, "{}");
}
}
return "";
}
getData() {
let fp = FivePhases.shared.getFivePhasesByRoleid(this.roleid);
let card = ChangeCard.shared.selectUseCard(this.roleid);
let fplevel = 0;
let changeid = 0;
if (fp) {
fplevel = fp.fplevel;
}
if (card) {
changeid = card.resid;
}
let obj: any = {};
obj.onlyid = this.onlyid;
obj.qianneng = this.qianneng;
obj.attr1 = SKDataUtil.toJson(this.attr1, "{}");
obj.xiulevel = this.xiulevel;
obj.addattr1 = SKDataUtil.toJson(this.addattr1, "{}");
obj.addattr2 = SKDataUtil.toJson(this.addattr2, "{}");
obj.skill = SKDataUtil.toJson(this.skill_list, "{}");
obj.level = this.level;
obj.exp = this.exp;
obj.bangid = this.bangid;
obj.race = this.race;
obj.sex = this.sex;
obj.maxexp = this.maxexp;
obj.money = this.money;
obj.jade = this.jade;
obj.bangscore = this.bangscore;
obj.shiscore = this.shiscore;
obj.discore = this.discore;
obj.xiuscore = this.xiuscore;
obj.guoscore = this.guoscore;
obj.bindjade = this.bind_jade;
obj.gmlevel = this.gmlevel;
obj.chargesum = ChargeSum.shared.getPlayerChargeSum(this.roleid);
obj.rewardrecord = this.rewardrecord;
obj.sprewardrecord = this.sprewardrecord;
obj.levelreward = this.level_reward;
obj.shuilugj = this.shuilu.gongji;
obj.titleval = this.titleVal;
obj.titletype = this.titleType;
obj.titleid = this.titleId;
obj.color1 = this.color1;
obj.color2 = this.color2;
obj.schemename = this.schemeName;
obj.wingId = this.wingId;
obj.sat_integral = this.sat_integral;
obj.fplevel = fplevel;
obj.changeid = changeid;
obj.jpoint = this.arena.jpoint;
obj.tianti_integral = this.tianti_integral;
obj.iconList = this.iconList;
return obj;
}
setLevel(level: any, issend?: any) {//等级改变
let maxlevel = ExpUtil.getUserMaxGrade(this.relive);
this.level = Math.min(level, maxlevel);
SKLogger.debug(`玩家[${this.name}${this.roleid}]等级改变,当前${this.level}`);
this.maxexp = ExpUtil.getPlayerUpgradeExp(this.relive, this.level);
this.calQianNeng();
this.calculateAttr();
if (this.partnerMgr) {
this.partnerMgr.checkAndAddPartner();
if (this.level <= GameUtil.limitPartnerLevel) {
this.partnerMgr.UpdatePartnerLevelAsPlayer();
}
}
PaiHangMgr.shared.CheckAndInsertLevelPaihang(this.roleid, this.name, this.relive, this.level, this.money);
// 更新红名榜数据
PaiHangMgr.shared.updateMurderRankDataInfo(this.roleid, this.name, 0, this.level, this.relive);
if (issend) {
this.send('s2c_level_up', {
onlyid: this.onlyid,
curlevel: this.level,
});
}
if (this.bangid > 0) {
let bang = BangMgr.shared.getBang(this.bangid)
if (bang) {
for (const roleInfo of bang.rolelist) {
if (this.roleid == roleInfo.roleid) {
roleInfo.relive = this.relive;
roleInfo.level = this.level;
break;
}
}
}
}
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
// 刷新队伍信息
this.refresh_team_data();
}
taskStateToJson(): string {
let mapValue: any = {};
let vecData = [];
if (this.getTaskMgr()) {
if (this.getTaskMgr().mapTaskState) {
for (let it in this.getTaskMgr().mapTaskState) {
let stTaskState = this.getTaskMgr().mapTaskState[it];
let nCurStep = 0;
for (let it2 in stTaskState.vecEventState) {
if (stTaskState.vecEventState[it2].nState == 1)
nCurStep = Number(it2);
}
vecData.push({
nTaskID: stTaskState.nTaskID,
nCurStep: nCurStep
});
}
}
mapValue['RecordList'] = this.getTaskMgr().recordList;
mapValue['DailyCnt'] = this.getTaskMgr().mapDailyCnt;
mapValue['FuBenCnt'] = this.getTaskMgr().mapFuBenCnt;
mapValue['DailyStart'] = this.getTaskMgr().mapDailyStart;
mapValue['mapActiveScore'] = this.getTaskMgr().mapActiveScore;
mapValue['szBeenTake'] = this.getTaskMgr().szBeenTake;
}
mapValue['StateList'] = vecData;
return mapValue;
}
////////////////////////////// 物品 相关 /////////////////////////////
// 清理背包
clear_bag(msg: string) {
// if (msg == "清理背包"){
// this.bag_list = {}
// this.send('s2c_bagitem', {
// info: SKDataUtil.toJson(this.bag_list, "{}")
// });
// }
if (msg == "分解配饰") {
this.clear_acc(2);
} else if (msg == "打开五行礼包") {
this.openGoods("50033");
} else if (msg == "打开变身卡礼包") {
this.openGoods("50034");
}
// else if (msg == "退出本次战斗") {
// if(this.battle_id > 0){
// let battle = BattleMgr.shared.getBattle(this.battle_id);
// if(battle.battle_type != BattleType.Force && battle.battle_type != BattleType.PK && battle.battle_type != BattleType.ShuiLu && battle.battle_type != BattleType.AREAN && battle.battle_type != BattleType.Sat){
// if(this.teamid > 0){
// if (this.isleader){
// BattleMgr.shared.destroyBattle(this.battle_id)
// }else {
// this.send_notice("您不是队长!");
// }
// }else {
// BattleMgr.shared.destroyBattle(this.battle_id)
// }
// }
// }
// }
}
openGoods(item: any) {
let obj: any = {};
let num = this.getBagItemNum(item);
if (num > 0) {
for (let i = 0; i < num; i++) {
let randomSelect = BoxMgr.shared.randomSelect(item);
let goods = this.bag_list[randomSelect.item_id]
if (goods == null || goods == undefined) {
this.bag_list[randomSelect.item_id] = randomSelect.count;
} else {
this.bag_list[randomSelect.item_id] += randomSelect.count;
}
if (obj[randomSelect.item_id] == null || obj[randomSelect.item_id] == undefined) {
obj[randomSelect.item_id] = randomSelect.count;
} else {
obj[randomSelect.item_id] += randomSelect.count;
}
}
this.bag_list[item] -= num;
if (this.bag_list[item] <= 0) {
delete this.bag_list[item];
}
let msg = "本次开启礼包获得:";
for (let key in obj) {
let itemData = ItemUtil.getItemData(key);
let count = obj[key];
msg += `[color=#ff0000]${itemData.name}[/color]${count}`;
}
this.send_notice(msg);
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
} else {
this.send_notice("抱歉,您背包没有该道具!");
}
}
/**
*
* @param flag :1 全部清理、2 只分解配饰
*/
clear_acc(flag: number) {
let equipAcc: any = [];
for (let i = 0; i < this.listEquips.length; i++) {
let equip = this.listEquips[i];
if (equip.EquipType == 5) {
let equip_: Equip = this.equipObjs[equip.EquipID];
equipAcc.push(equip_);
}
}
//let count_score = 0;
for (const acc of equipAcc) {
// let score = 1;
// if (acc.BaseAttr.length != 0 ){
// if (acc.Grade == 2) {
// score = 2;
// } else if (acc.Grade == 3) {
// score = 5;
// }
// }
// count_score += score;
//this.shuilu.gongji += score;
this.delEquipByTo(acc.EquipID, false, "佩饰分解");
this.sendEquipList();
}
// this.send('s2c_you_money', {
// nKind: GameUtil.goldKind.SLDH_Score,
// nNum: this.shuilu.gongji,
// nChange: count_score
// });
// let info = `本次分解获得[color=#ff0000][${count_score}][/color]功绩`;
// this.send('s2c_notice', {
// strRichText: info
// });
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
}
// 批量分解配饰
delEquipByTo(equipid: any, uninlay = true, source = '') {
if (!equipid || equipid <= 0) {
return;
}
let delequip = null;
for (let index = 0; index < this.currentEquips.length; index++) { //已经装备的不能删,所以注释掉以下代码
if (this.currentEquips[index].EquipID == equipid) {
delequip = this.currentEquips[index];
this.currentEquips.splice(index, 1);
continue;
}
}
for (let index = 0; index < this.listEquips.length; index++) {
if (this.listEquips[index].EquipID == equipid) {
delequip = this.listEquips[index];
this.listEquips.splice(index, 1);
continue;
}
}
if (delequip != null) {
delequip.pos = EEquipPos.UNKNOW;
let equipfulldata = delequip.getFullData();
SKLogger.debug(`玩家[${this.roleid}:${this.name}]删除装备[${delequip.EquipID}:${equipfulldata.EName}]:${source}]`);
if (uninlay) {
this.unInLay(delequip);
}
delequip.state = 0;
delequip.save();
delete this.equipObjs[delequip.EquipID];
EquipMgr.shared.delEquip(delequip.EquipID);
this.schemeMgr.deleteCurEquips(delequip.EquipID);
}
}
update_bagitem(data: any) {
if (data.operation == 0) {
if (this.bag_list[data.itemid] == null || this.bag_list[data.itemid] < data.count) {
this.send('s2c_operation_result', {
code: MsgCode.ITEM_OPERATION_ERROR
});
} else {
this.bag_list[data.itemid] -= data.count;
if (this.bag_list[data.itemid] <= 0) {
delete this.bag_list[data.itemid];
}
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
}
} else {
if (this.bag_list[data.itemid] == null) {
this.bag_list[data.itemid] = data.count;
} else {
this.bag_list[data.itemid] += data.count;
}
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
}
}
update_lockeritem(data: any) {
if (data.operation == 1) {
if (this.getLockerItemAllKindNum() >= this.lockerKindNum) {
this.send_notice(`仓库已满`);
return;
}
} else if (data.operation == 0) {
if (this.getBagItemAllKindNum() >= this.bagKindNum) {
this.send_notice(`背包已满`);
return;
}
}
if (data.type == 0) {
if (data.operation == 0) {
if (this.locker_list[data.operateid] > 0) {
if (this.bag_list[data.operateid] == null) this.bag_list[data.operateid] = 0;
this.bag_list[data.operateid] += this.locker_list[data.operateid];
}
delete this.locker_list[data.operateid];
} else {
if (this.bag_list[data.operateid] > 0) {
if (this.locker_list[data.operateid] == null) this.locker_list[data.operateid] = 0;
this.locker_list[data.operateid] += this.bag_list[data.operateid];
}
delete this.bag_list[data.operateid];
}
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
} else if (data.type == 1) {
if (data.operation == 0) {
for (let index = 0; index < this.lockerEquips.length; index++) {
let equip = this.lockerEquips[index];
if (data.operateid == equip.EquipID) {
equip.pos = EEquipPos.BAG;
this.lockerEquips.splice(index, 1);
this.addEquipList(equip);
break;
}
}
} else {
for (let index = 0; index < this.listEquips.length; index++) {
let equip = this.listEquips[index];
if (data.operateid == equip.EquipID) {
equip.pos = EEquipPos.BANK;
this.listEquips.splice(index, 1);
this.lockerEquips.push(equip);
break;
}
}
}
this.sendEquipList();
}
}
getBagItemNum(itemid: any): any {
if (this.bag_list.hasOwnProperty(itemid) == false)
return 0;
return this.bag_list[itemid];
}
// 加经验值
addExp(exp: number) {
if (exp == 0) {
return;
}
//检查星阵是否装备赤马阵, 经验获得加成
if (exp > 0 && this.StarMgr.EquipID == 5) {
let star = this.StarMgr.GetStarByID(5)
let buf = star.Level * 0.003
exp = Math.floor(exp * (1 + buf))
}
super.addExp(exp);//经验改变
if (this.relive == 0 && this.level > 28) {
let score = 0;
for (let equip of this.currentEquips) {
let full = equip.getFullData(this.roleid);
if (full) {
score += Number(full.BaseScore);
}
}
//角色大于28级加入竞技场
let jingjilist = PaiHangMgr.shared.jingjilist;
let isexit = false;
for (let index = 0; index < jingjilist.length; index++) {
let brole = jingjilist[index];
if (brole.roleId == this.roleid) {
isexit = true;
jingjilist.splice(index, 1, {//存在,替换
roleId: this.roleid,
resid: this.resid,
name: this.name,
count: this.arena.count,
jpoint: this.arena.jpoint,
relive: this.relive,
level: this.level,
ranking: index + 1,
baseSource: score,
});
this.arena.ranking = index + 1
}
}
if (isexit == false) {//不存在加入
jingjilist.push({
roleId: this.roleid,
resid: this.resid,
name: this.name,
count: this.arena.count,
jpoint: this.arena.jpoint,
relive: this.relive,
level: this.level,
ranking: jingjilist.length + 1,
baseSource: score,
});
this.arena.ranking = jingjilist.length + 1
}
}
if (this.relive == 1 && this.level >= 80) { //达到1转80级开启五行修炼
let playerfp = FivePhases.shared.getFivePhasesByRoleid(this.roleid);
if (playerfp == undefined) {
let fp = {
roleid: this.roleid,//角色id
fplevel: 0, //五行等级
jinlevel: 0, //金等级
jinexp: 0, //金经验
mulevel: 0, //木等级
muexp: 0, //木经验
shuilevel: 0, //水等级
shuiexp: 0, //水经验
huolevel: 0, //火等级
huoexp: 0, //火经验
tulevel: 0, //土等级
tuexp: 0, //土经验
count: 1000000 //次数
}
FivePhases.shared.fplist.push(fp);
DB.insertFivePhasesById(this.roleid);
}
}
if (exp > 0) {
this.send('s2c_add_exp', {
onlyid: this.onlyid,
curexp: this.exp,
addexp: exp,
maxexp: this.maxexp,
});
}
this.send('s2c_player_data', this.getData());
}
addItem(itemId: number, count: number, isNotice = false, source = ''): boolean {
count = SKDataUtil.numberBy(count);
if (isNaN(count)) {
SKLogger.warn(`玩家[${this.roleid}:${this.name}]:获得物品[${itemId}]数量无效!`);
return false;
}
let itemData = ItemUtil.getItemData(itemId);
if (itemData == null) { // 无此道具
SKLogger.warn(`玩家[${this.roleid}:${this.name}]获得物品[${itemId}]找不到!`);
return false;
}
if (itemData.type < 4) {
this.addBagItem(itemId, count, isNotice);
} else if (itemData.type == 4) {
this.addExp(count);
} else if (itemData.type == 5) {
this.addMoney(0, count, source, isNotice == true ? MsgCode.SUCCESS : MsgCode.FAILED);
} else if (itemData.type == 6) {
this.addMoney(1, count, source, isNotice == true ? MsgCode.SUCCESS : MsgCode.FAILED);
} else if (itemData.type == 7 || itemData.type == 8) { // 7 神器 8 仙器
let info = itemData.json;
if (itemData.id) {
info.resid = itemData.id;
}
info.roleid = this.roleid;
this.addEquip(info);
} else if (itemData.type == 9) {
if (this.petList.length >= GameUtil.limitPetNum) {
this.send_notice("当前携带宠物已上限")
return false;
}
this.createPet(itemData.json, source, isNotice);
} else if (itemData.type == 10) {
this.addBagItem(itemId, count, isNotice);
} else if (itemData.type == 11) {
let itemlist = itemData.json;
if (itemlist) {
let index = Math.floor(Math.random() * itemlist.length);
let tempId = itemlist[index];
if (tempId != null) {
itemId = tempId;
}
this.addBagItem(itemId, 1, isNotice);
}
} else if (itemData.type == 12) {
this.addMoney(GameUtil.goldKind.BindJade, count, source, MsgCode.SUCCESS);
} else if (itemData.type == 13) { // 宝箱
this.addBagItem(itemId, count, isNotice);
} else if (itemData.type == 14) { // 钥匙
this.addBagItem(itemId, count, isNotice);
} else if (itemData.type == 15) { // 变身卡
this.addBagItem(itemId, count, isNotice);
} else if (itemData.type == 16) { // 特效
//获取特效类型
let effecttype = SpecialEffect.shared.getSeffectType(itemId);
SpecialEffect.shared.seffectlist.push({
roleid: this.roleid,
effectid: itemId,
effecttype: effecttype,
usestate: 0
})
DB.insertSeffect(itemId, this.roleid, 0, effecttype, 1);
//this.addBagItem(itemId, count, isNotice);
} else if (itemData.type == 17) {
let info = itemData.json;
info.id = itemData.id;
info.roleid = this.roleid;
this.addMagicWeapon(info);
} else if (18 == itemData.type) {
if (this.XWMgr.buildNewXw(itemId)) {
this.addBagItem(itemId, count, isNotice);
}
} else if (19 == itemData.type) {
this.addBagItem(itemId, count, isNotice);
}
let info = `玩家[(${this.roleid}:${this.name}]`;
if (count < 0) {
info += `物品[${itemData.id}:${itemData.name}]减少${count}个,${source}`;
} else {
info += `获得物品[${itemData.id}:${itemData.name}]${count}个,${source}`;
}
SKLogger.debug(info);
return true;
}
getBagItemAllKindNum() {
let count: number = 0;
for (const item in this.bag_list) {
let data = ItemUtil.getItemData(item);
if (data != null) { // 无此道具
if (data.type != 15 && data.type != 18) {
if (GameUtil.flagGoods.indexOf(data.id) == -1) {
count++;
}
}
}
}
return this.listEquips.length + count;
}
getLockerItemAllKindNum() {
return this.lockerEquips.length + Object.keys(this.locker_list).length;
}
addBagItem(nItem: any, nNum: any, bNotice: any) {
nNum = SKDataUtil.numberBy(nNum);
if (isNaN(nNum)) {
return;
}
if (this.bag_list[nItem] == null) {
if (nNum > 0) {
if (this.getBagItemAllKindNum() >= this.bagKindNum) {
this.send_notice(`背包已满`)
return;
}
}
this.bag_list[nItem] = 0;
}
let nNewNum = parseInt(this.bag_list[nItem]) + parseInt(nNum);
if (nNewNum < 0) {
return;
}
let itemData = ItemUtil.getItemData(nItem);
if (itemData == null) {
return;
}
this.bag_list[nItem] = nNewNum;
if (this.bag_list[nItem] == 0) {
delete this.bag_list[nItem];
}
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
if (bNotice) {
this.send('s2c_you_get_item', {
nItem: nItem,
nNum: nNum
});
}
//cxf背包物品变动
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "背包物品变动",
operateResSerial: itemData.id,
operateResName: itemData.name,
operateContent: `${itemData.name} :数量${nNum},背包剩余数量${nNewNum}`
})
// if (itemData.notice != 0 && nNum > 0) {
// let strRichText = `<color=#00ff00 > ${this.name}</c > <color=#ffffff > 获得了</c ><color=#0fffff > ${itemData.name}</color ><color=#ffffff > 真是太幸运了</c >`;
// PlayerMgr.shared.broadcast('s2c_screen_msg', {
// strRichText: strRichText,
// bInsertFront: 0
// });
// }
return;
}
/**
* 所有金币类消耗的入口
* @param {number} nKind 消耗类型
* @param {number} nNum 数量
* @param {String} strText 消耗日志
* @param {Boolen} usebind 是否使用绑定类型
*/
CostFee(nKind: any, nNum: any, strText?: any, usebind = true) {
let vecMsg = ['银两不足', '仙玉不足', '绑定仙玉不足', '水陆功绩不足', '', '竞技点不足'];
let money = this.GetMoney(nKind);
// let bindjade = this.GetMoney(GameUtil.goldKind.BindJade);
// if (nKind == GameUtil.goldKind.Jade && usebind) {
// money += bindjade;
// }
if (money < nNum) {
return vecMsg[nKind];
}
this.addMoney(nKind, -nNum, strText, MsgCode.SUCCESS);
return '';
}
GetMoney(nKind: any) {
let money = 0;
switch (nKind) {
case GameUtil.goldKind.Money:
money = this.money;
break;
case GameUtil.goldKind.Jade:
money = this.jade;
break;
case GameUtil.goldKind.BindJade:
money = this.bind_jade;
break;
case GameUtil.goldKind.SLDH_Score:
money = this.shuilu.gongji;
break;
case GameUtil.goldKind.arena_Score:
money = this.arena.jpoint;
break;
case GameUtil.goldKind.bang_Score:
money = this.bangscore;
break;
case GameUtil.goldKind.shi_Score:
money = this.shiscore;
break;
case GameUtil.goldKind.di_Score:
money = this.discore;
break;
case GameUtil.goldKind.xiu_Score:
money = this.xiuscore;
break;
case GameUtil.goldKind.guo_Score:
money = this.guoscore;
break;
}
return money;
}
// 加银两或仙玉
addMoney(kind: any, count: number, msg: string = "", flag: number = MsgCode.SUCCESS) {
if (kind == GameUtil.goldKind.Money) {
let money = this.money + count;
if (money > 2000000000) {
money = 2000000000;
}
this.money = money;
PaiHangMgr.shared.CheckAndInsertMoneyPaihang(this.roleid, this.name, this.relive, this.level, this.money);
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.money,
nChange: count,
flag: flag
});
SKLogger.debug(`玩家[${this.name}(${this.roleid})]银两改变[${count}],当前[${this.money},消息:${msg}]`);
}
return;
}
if (kind == GameUtil.goldKind.Jade) { // 仙玉
let jade = this.jade + count;
if (jade > 1000000000) {
jade = 1000000000;
}
this.jade = jade;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.jade,
nChange: count,
flag: flag
});
//cxf仙玉变动
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "仙玉改变",
operateResSerial: "",
operateResName: "",
operateContent: `${this.name}]仙玉改变[${count}],当前[${this.jade}],消息:${msg}`
})
SKLogger.info(`玩家[${this.roleid}:${this.name}]仙玉改变[${count}],当前[${this.jade}],消息:${msg}`);
}
return;
}
if (kind == GameUtil.goldKind.bang_Score) { // 帮贡
let bangscore = this.bangscore + count;
if (bangscore > 10000000000) {
bangscore = 10000000000;
}
this.bangscore = bangscore;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.bangscore,
nChange: count,
flag: flag
});
//cxf仙玉变动
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "帮贡改变",
operateResSerial: "",
operateResName: "",
operateContent: `${this.name}]帮贡改变[${count}],当前[${this.bangscore}],消息:${msg}`
})
SKLogger.info(`玩家[${this.roleid}:${this.name}]帮贡改变[${count}],当前[${this.bangscore}],消息:${msg}`);
DB.updateMoney({ bind_jade: this.bind_jade, shiscore: this.shiscore, bangscore: this.bangscore, discore: this.discore, xiuscore: this.xiuscore, guoscore: this.guoscore, roleid: this.roleid });
}
return;
}
if (kind == GameUtil.goldKind.shi_Score) { // 师贡
let shiscore = this.shiscore + count;
if (shiscore > 10000000000) {
shiscore = 10000000000;
}
this.shiscore = shiscore;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.shiscore,
nChange: count,
flag: flag
});
//cxf仙玉变动
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "师贡改变",
operateResSerial: "",
operateResName: "",
operateContent: `${this.name}]师贡改变[${count}],当前[${this.shiscore}],消息:${msg}`
})
SKLogger.info(`玩家[${this.roleid}:${this.name}]师贡改变[${count}],当前[${this.shiscore}],消息:${msg}`);
DB.updateMoney({ bind_jade: this.bind_jade, shiscore: this.shiscore, bangscore: this.bangscore, discore: this.discore, xiuscore: this.xiuscore, guoscore: this.guoscore, roleid: this.roleid });
}
return;
}
if (kind == GameUtil.goldKind.di_Score) { // 地宫积分
let discore = this.discore + count;
if (discore > 10000000000) {
discore = 10000000000;
}
this.discore = discore;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.discore,
nChange: count,
flag: flag
});
//cxf仙玉变动
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "地宫积分改变",
operateResSerial: "",
operateResName: "",
operateContent: `${this.name}]地宫积分改变[${count}],当前[${this.discore}],消息:${msg}`
})
SKLogger.info(`玩家[${this.roleid}:${this.name}]地宫积分改变[${count}],当前[${this.discore}],消息:${msg}`);
DB.updateMoney({ bind_jade: this.bind_jade, shiscore: this.shiscore, bangscore: this.bangscore, discore: this.discore, xiuscore: this.xiuscore, guoscore: this.guoscore, roleid: this.roleid });
}
return;
}
if (kind == GameUtil.goldKind.xiu_Score) { // 除魔积分
let xiuscore = this.xiuscore + count;
if (xiuscore > 10000000000) {
xiuscore = 10000000000;
}
this.xiuscore = xiuscore;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.xiuscore,
nChange: count,
flag: flag
});
//cxf仙玉变动
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "除魔积分改变",
operateResSerial: "",
operateResName: "",
operateContent: `${this.name}]除魔积分改变[${count}],当前[${this.xiuscore}],消息:${msg}`
})
SKLogger.info(`玩家[${this.roleid}:${this.name}]除魔积分改变[${count}],当前[${this.xiuscore}],消息:${msg}`);
DB.updateMoney({ bind_jade: this.bind_jade, shiscore: this.shiscore, bangscore: this.bangscore, discore: this.discore, xiuscore: this.xiuscore, guoscore: this.guoscore, roleid: this.roleid });
}
return;
}
if (kind == GameUtil.goldKind.guo_Score) { // 郭氏积分
let guoscore = this.guoscore + count;
if (guoscore > 10000000000) {
guoscore = 10000000000;
}
this.guoscore = guoscore;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.guoscore,
nChange: count,
flag: flag
});
//cxf仙玉变动
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "郭氏积分改变",
operateResSerial: "",
operateResName: "",
operateContent: `${this.name}]郭氏积分改变改变[${count}],当前[${this.guoscore}],消息:${msg}`
})
SKLogger.info(`玩家[${this.roleid}:${this.name}]郭氏积分改变[${count}],当前[${this.guoscore}],消息:${msg}`);
DB.updateMoney({ bind_jade: this.bind_jade, shiscore: this.shiscore, bangscore: this.bangscore, discore: this.discore, xiuscore: this.xiuscore, guoscore: this.guoscore, roleid: this.roleid });
}
return;
}
if (kind == GameUtil.goldKind.BindJade) { // 绑定仙玉
this.bind_jade += count;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.bind_jade,
nChange: count,
flag: flag
});
SKLogger.info(`玩家[${this.roleid}:${this.name}]绑定仙玉改变[${count}],当前[${this.bind_jade}],消息:${msg}`);
DB.updateMoney({ bind_jade: this.bind_jade, shiscore: this.shiscore, bangscore: this.bangscore, discore: this.discore, xiuscore: this.xiuscore, guoscore: this.guoscore, roleid: this.roleid });
}
return;
}
if (kind == GameUtil.goldKind.SLDH_Score) { // 水陆大会功绩
this.shuilu.gongji += count;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.shuilu.gongji,
nChange: count,
flag: flag
});
SKLogger.debug(`玩家[${this.name}(${this.roleid})]水陆大会功绩改变[${count}],当前[${this.shuilu.gongji},,消息:${msg}]`);
}
return;
}
if (kind == GameUtil.goldKind.arena_Score) { // 竞技场积分
this.arena.jpoint += count;
if (count != 0) {
this.send('s2c_you_money', {
nKind: kind,
nNum: this.arena.jpoint,
nChange: count,
flag: flag
});
SKLogger.debug(`玩家[${this.name}(${this.roleid})]竞技场积分改变[${count}],当前[${this.arena.jpoint},,消息:${msg}]`);
}
return;
}
}
/*
* 充值成功
* @param jade 增加的仙玉
* @param money 充值的money
*/
chargeSuccess(jade: any, money: any) {
this.addMoney(GameUtil.goldKind.Jade, jade, '仙玉充值', MsgCode.SUCCESS);
let money_n = Number(money);
let chargesum = ChargeSum.shared.getPlayerChargeSum(this.roleid);
this.send('s2c_charge', {
money: money_n,
jade: Number(this.jade),
chargesum: chargesum,
dayMap: SKDataUtil.toJson(this.dayMap, "{}")
});
}
aoi_enter(obj: BattleObj) {
if (obj.isNpc() && this.canPlayerSeeNpc(<Npc>obj) == false) {
return;
}
if (this.offline) {
return;
}
this.aoi_obj_list[obj.onlyid] = obj;
this.send('s2c_aoi_pinfo', {
list: [obj.toObj()]
});
}
aoi_update(obj: BattleObj) {
if (obj.isNpc() && this.canPlayerSeeNpc(<Npc>obj) == false) {
return;
}
//离线时返回不发送
if (this.offline) {
return;
}
this.aoi_obj_list[obj.onlyid] = obj;
this.send('s2c_aoi_pinfo', {
list: [obj.toObj()]
});
}
aoi_exit(obj: any) {
delete this.aoi_obj_list[obj.onlyid];
if (this.offline) {
return;
}
this.send('s2c_aoi_exit', {
onlyid: obj.onlyid,
});
}
// 发送消息
send(event: string, obj?: any) {
if (this.offline) {
SKLogger.debug(`玩家[${this.roleid}:${this.name}]已离线,消息[${event}:${obj}]不发送`);
return;
}
if (this.agent) {
this.agent.send(event, obj);
} else {
// 机器人不发送消息
if (this.isRobot()) {
return;
}
// SKLogger.warn(`玩家[${this.roleid}:${this.name}]发送[${event}]失败`);
}
}
//玩家登录
playerLogined() {
if (this.offline) {
this.offline = false;
}
PlayerMgr.shared.addPlayer(this);
ChangeCard.shared.checkCard(this.roleid);
if (this.offlineTimer) {
clearInterval(this.offlineTimer);
this.offlineTimer = null;
}
if (this.mapid == 1201) {
this.inPrison = true;
}
this.send('s2c_login', {
errorcode: MsgCode.SUCCESS,
info: this.toObj(),
});
this.babyPracticeConfig()
this.calcOnlineTime();
this.mailList.check();
this.activateScheme();
this.calculateAttr()
this.send('s2c_player_data', this.getData());
}
// 玩家重新登录
playerRelogin() {
if (this.offline) {
this.offline = false;
}
if (this.offlineTimer) {
clearInterval(this.offlineTimer);
this.offlineTimer = null;
}
this.calcOnlineTime();
}
// 计算在线时长
calcOnlineTime() {
if (this.onlineTime < 1) {
this.onlineTime = new Date().getTime();
} else {
let nowTime = new Date().getTime();
let time = nowTime - this.onlineTime;
let days = Math.floor(time / (24 * 3600 * 1000)); //相差天数
let leave1 = time % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
let hours = Math.floor(leave1 / (3600 * 1000)); // 相差小时数
let leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
let minutes = Math.floor(leave2 / (60 * 1000)); // 相差分钟数
let leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
let seconds = Math.round(leave3 / 1000); // 相差秒数
SKLogger.info(`玩家[${this.roleid}:${this.name}]在线时长:${days}${hours}小时${minutes}分钟${seconds}`);
this.onlineTime = 0;
}
}
// 进入地图
onEnterMap() {
this.stopIncense();
let mapModel: MapModel = MapMgr.shared.getMap(this);
if (mapModel) {
let playerList = mapModel.enterMap(this, ELiveingType.PLAYER);
let mList = [];
for (const oid in playerList) {
if (playerList.hasOwnProperty(oid)) {
const player = playerList[oid];
if (player.isNpc() && this.canPlayerSeeNpc(player) == false)
continue;
if (player.nFuBenID > 0 && player.nFuBenID != this.bangid)
continue;
this.aoi_obj_list[player.onlyid] = player;
let prefix: string = `${player.isRobot ? `机器人` : `玩家`}`;
SKLogger.debug(`${prefix}[${player.roleid}:${player.name}]进入地图[${mapModel.map_name}]!`);
mList.push(player.toObj());
}
}
this.send('s2c_aoi_pinfo', {
list: mList
});
// 进入比武场后 检查水路大会情况
let activity = ActivityMgr.shared.getActivity(ActivityDefine.activityKindID.ShuiLuDaHui);
if (activity && activity.activity_state != ActivityDefine.activityState.Close) {
if (activity.checkSign(this.teamid) && activity.checkFinish(this.teamid) == false) {
if (this.mapid == 1213) {
this.send('s2c_shuilu_sign', {
errorcode: MsgCode.SUCCESS,
shuilustate: activity.sldh_state,
});
} else {
activity.playerUnsign(this);
this.send('s2c_shuilu_unsign', {
errorcode: MsgCode.SUCCESS,
});
}
}
}
}
}
onEnterGame() {
if (this.ShanEChange()) {
SKLogger.warn(`玩家[${this.roleid}:${this.name}]进入游戏错误`);
return;
}
SKLogger.debug(`玩家[${this.roleid}:${this.name}]进入游戏`);
this.onEnterMap();
// 发送角色数据
this.send('s2c_player_data', this.getData());
if (this.getpet == 0) {
this.send('s2c_new_pet', {});
} else {
this.sendPetList();
}
// 任务系统初始化放置在进入场景之后进行!
if (this.dbData) {
this.initTaskMgr(this.dbData.taskstate ? this.dbData.taskstate : '{}');
delete this.dbData;
}
if (this.teamid > 0) {
TeamMgr.shared.sendInfoToMember(this.teamid);
}
if (this.battle_id != 0) {
BattleMgr.shared.playerBackToBattle(this.battle_id, this.onlyid);
}
let ltime = new Date(this.lastonline);
this.CheckNewDay(ltime);
DB.updateLastOnlineTime(this.roleid);
this.lastonline = new Date(GameUtil.gameTime);
this.checkFriendInfo();
}
// 整理被删除的好友
checkFriendInfo() {
for (const key in this.friendList) {
if (this.friendList.hasOwnProperty(key)) {
let roleId = SKDataUtil.numberBy(key);
let target = PlayerMgr.shared.getPlayerByRoleId(roleId);
if (target) {
if (target.friendList[this.roleid] == null) {
delete this.friendList[target.roleid];
}
}
}
}
}
// NPC是否可见
canPlayerSeeNpc(npc: Npc) {
// 系统创建的NPC可见
if (npc.stCreater.nKind == NpcCreater.SYSTEM) {
return true;
}
// 玩家创建的并且是这个玩家可见
if (npc.stCreater.nKind == NpcCreater.PLAYER && npc.stCreater.nID == this.roleid) {
return true;
}
// 组队创建的NPC并且是这个队伍可见
if (npc.stCreater.nKind == NpcCreater.TEAM && npc.stCreater.nID == this.teamid && this.teamid > 0) {
return true;
}
return false;
}
playerMove(data: any, stop = false) {
if (this.usingIncense) {
this.anleiCnt--;
if (this.anleiCnt <= 0) {
this.triggerAnLei();
this.anleiCnt = Math.ceil(Math.random() * 15) + 15;
}
}
if (this.teamid > 0 && this.isleader && !stop) {
TeamMgr.shared.updateTeamPos(this.teamid, {
x: data.x,
y: data.y
});
}
let map: MapModel = MapMgr.shared.getMap(this);
if (map) {
let playerList: any[] = map.move(this.onlyid, data.x, data.y);
let memberList = [];
if (playerList) {
if (this.teamid > 0 && !this.isleader) {
playerList.push(this);
SKLogger.debug(`队友${this.name}加入列表`);
}
for (let player of playerList) {
if (player.isNpc() && this.canPlayerSeeNpc(player) == false) {
continue;
}
memberList.push(player.toObj());
};
}
this.send('s2c_aoi_pinfo', {
list: memberList
});
}
}
playerStop(data: any) {
this.playerMove(data, true);
if (this.teamid > 0 && this.isleader) {
TeamMgr.shared.setTeamPath(this.teamid, SKDataUtil.jsonBy(data.path));
}
}
enterPrison() {
this.inPrison = true;
if (this.teamid > 0) {
TeamMgr.shared.leaveTeam(this);
}
this.send('s2c_change_map', {
mapid: 1201,
pos: SKDataUtil.toJson({
x: 59,
y: 4
}, "{}")
});
this.changeMap({
mapid: 1201,
x: 59,
y: 4
});
}
leavePrison() {
if (this.shane > 0) {
return;
}
this.inPrison = false;
this.send('s2c_change_map', {
mapid: 1011,
pos: SKDataUtil.toJson({
x: 112,
y: 78
}, "{}")
});
this.changeMap({
mapid: 1011,
x: 112,
y: 78
});
}
changeMap(data: any) {
if (data.mapid == 1011 && this.shane > 0) {
this.enterPrison();
this.send('s2c_prison_time', {
onlyid: this.onlyid,
time: this.inPrison ? Math.ceil(this.shane / 4) : 0
});
return;
}
if (data.mapid == 3002 && this.bangid <= 0) {
this.send_notice("你还没有帮派,快去加入吧!");
return;
}
let map: MapModel = MapMgr.shared.getMap(this);
if (map) {
map.exitMap(this);
}
this.mapid = data.mapid;
this.x = data.x;
this.y = data.y;
this.onEnterMap();
if (this.teamid > 0 && this.isleader) {
TeamMgr.shared.changeTeamMap(this.teamid, this.mapid);
}
}
useIncense(time: any) {
this.stopIncense();
this.send('s2c_incense_state', {
ltime: time
});
this.usingIncense = true;
this.anleiCnt = Math.ceil(Math.random() * 20) + 20;
let self = this;
this.incenseTimer = SKTimeUtil.delay(() => {
self.usingIncense = false;
self.send('s2c_incense_state', {
ltime: 0
});
}, time * 1000);
return true;
}
stopIncense() {
this.usingIncense = false;
if (this.incenseTimer) {
SKTimeUtil.cancelDelay(this.incenseTimer);
this.incenseTimer = null;
}
}
triggerAnLei() { //触发暗雷怪
let map: MapModel = MapMgr.shared.getMap(this);
if (map) {
let groupid = map.getAnleiGroup();
if (groupid) {
this.monsterBattle(groupid, 0, BattleType.Normal, true);
}
}
}
// 召唤兽转生
relivePet(data: any) {
let operationPet = null;
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
for (let pet of this.petList) {
if (pet.petid == data.petid) {
operationPet = pet;
break;
}
}
if (operationPet == null) {
console.warn(`$警告:[${this.roleid}:${this.name}]找不到转宝召唤兽:${data.petid}`);
return;
}
operationPet.petRelive();
if (player) {
//cxf宠物转生
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物转生",
operateResSerial: data.petid,
operateResName: operationPet.name,
operateContent: ""
})
}
this.send('s2c_update_pet', {
info: operationPet.toObj()
});
}
// 开启宠物技能格子
openPetSkillGrid(data: any) {
// 道具编号
let prop: number = 10115;
let pet = this.getPetByID(data.petId);
let item_count = this.getBagItemNum(prop);
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (pet != null) {
let max: number = 4 * pet.getSkillNum();
// 必定开启
if (data.type == 2) {
if (item_count < max) {
this.send('s2c_notice', {
strRichText: `缺少[${ItemUtil.getItemName(prop)}]`,
});
return;
}
pet.openSkillGrid(data.index);
//pet.learnSkill(3007);
this.addBagItem(prop, -max, false);
if (player) {
//cxf宠物格子
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物格子",
operateResSerial: pet.petid,
operateResName: pet.name,
operateContent: ""
})
}
}
// 几率开启
else {
let min: number = 2 * pet.getSkillNum();
if (item_count < min) {
this.send('s2c_notice', {
strRichText: `缺少[${ItemUtil.getItemName(prop)}]`,
});
return;
}
// 开启成功
let random = SKDataUtil.random(0, 10);
this.addBagItem(prop, -min, false);
if (random < 3) {
pet.openSkillGrid(data.index);
if (player) {
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物格子",
operateResSerial: data.petid,
operateResName: pet.name,
operateContent: ""
})
}
} else {
if (player) {
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物格子",
operateResSerial: data.petid,
operateResName: pet.name,
operateContent: ""
})
}
// 开启失败
this.send("s2c_pet_skill_grid", {
petInfo: SKDataUtil.toJson(pet.toObj(), "{}"),
type: 2
})
let info = `消耗[color=#ED4BFA][聚魂丹][/color],开启失败,少侠再接再厉!`;
this.send_notice(info);
}
}
} else {
this.send_notice("获取宠物数据失败!")
}
}
/*
* 洗练宠物属性
*/
washProperty(data: any) {
let jll_count = this.bag_list[10118] || 0; /* 金柳露数量 */
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (data.washtaype == 1 && jll_count < 3) {
this.send_notice("金柳露数量不足!")
return;
}
if (data.washtaype == 2 && jll_count < 30) {
this.send_notice("金柳露数量不足!")
return;
}
let operationPet = null;
for (const pet of this.petList) {
if (pet.petid == data.petid) {
operationPet = pet;
break;
}
}
if (operationPet == null) {
return;
}
if (data.washtaype == 1) {
this.update_bagitem({
itemid: 10118,
count: 3,
operation: 0
});
operationPet.washProperty();
}
if (data.washtaype == 2) {
this.update_bagitem({
itemid: 10118,
count: 30,
operation: 0
});
operationPet.highWashProperty();
}
if (player) {
//cxf宠物洗练属性
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "洗练属性",
operateResSerial: data.petid,
operateResName: operationPet.name,
operateContent: ""
})
}
}
savePetProperty(data: any) {
let operationPet = null;
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
for (const pet of this.petList) {
if (pet.petid == data.petid) {
operationPet = pet;
break;
}
}
if (operationPet == null) {
return;
}
operationPet.saveProperty(data);
if (player) {
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "保存洗练属性",
operateResSerial: data.petid,
operateResName: operationPet.name,
operateContent: ""
})
}
}
// 合成召唤兽
hechengPet(data: any) {
let conf = PetMgr.shared.getPetData(data.petid);
if (conf.gettype != 1 || conf.needitem == null || conf.needitem.length < 1) {
this.send('s2c_notice', {
strRichText: `该召唤兽[${conf.name}]未开放合成!`
});
return;
}
if (PetMgr.shared.canHeCheng(this, data.petid)) {
this.createPet(data, `召唤兽[${conf.name}]合成`);
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
} else {
this.send('s2c_notice', {
strRichText: `召唤兽[${conf.name}]无法合成!`
});
}
}
createPet(data: any, source = '', isNotice: boolean = true) {
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
PetMgr.shared.createPet(this, data.petid, (pet: any) => {
if (pet != null) {
this.addPet(pet, false);
if (this.curPet == null) {
this.changePet(pet.petid, false);
}
this.getPetlist();
if (this.getpet != 1) {
DB.getPet(this.roleid);
this.getpet = 1;
}
SKLogger.debug(`玩家[${this.roleid}:s${this.name}]获得召唤兽[${pet.petid}:${pet.name}]${source}`);
if (player) {
//cxf合成宠物
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "合成宠物",
operateResSerial: pet.petid,
operateResName: pet.name,
operateContent: ""
})
}
if (isNotice) {
this.send('s2c_notice', {
strRichText: `恭喜您获得了${pet.name}`
});
}
} else {
this.send_notice("获取宠物信息失败!");
}
});
}
addPet(pet: any, issend = true) {
pet.setOwner(this);
this.petList.push(pet);
if (issend) {
this.getPetlist();
}
}
getPetByID(petid: any) {
for (let pet of this.petList) {
if (pet.petid == petid) {
return pet;
}
}
return null;
}
sendPetList() {
if (this.offline) {
return;
}
if (this.loaded == false) {
return;
}
this.getPetlist();
}
// 获得召唤兽列表
getPetlist(data?: any) {
let listInfo: any = {};
listInfo.curid = 0;
if (this.curPet != null) {
listInfo.curid = this.curPet.petid;
}
listInfo.list = [];
let repeat = SKDataUtil.removeRepeat(this.petList, "petid");
if (repeat.length > 0) {
for (let pet of repeat) {
SKLogger.warn(`玩家:[${this.roleid}:${this.name}]召唤兽[${pet.petid}:${pet.name}:${pet.state}]重复`);
}
}
for (let pet of this.petList) {
let conf = PetMgr.shared.getPetData(pet.dataid);
// if (pet.name != conf.name) {
// SKLogger.warn(`玩家:[${this.roleid}:${this.name}]召唤兽[${pet.petid}:${pet.name}]修复dataid:${pet.name}->${conf.name}`);
// pet.name = conf.name;
// }
if (pet.resid != conf.resid) {
SKLogger.warn(`玩家:[${this.roleid}:${this.name}]召唤兽[${pet.petid}:${pet.name}]修复resid:${pet.resid}->${conf.resid}`);
pet.resid = conf.resid;
}
listInfo.list.push(pet.toObj());
}
this.send('s2c_get_petlist', listInfo);
SKLogger.debug(`发送玩家[${this.roleid}:${this.name}]召唤兽列表`);
}
updatePetPoint(data: any) {
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (!data) {
return;
}
let sumpoint = 0;
let addpoint: any = {};
if (data.type > 1) {
addpoint = SKDataUtil.jsonBy(data.info);
for (let key in addpoint) {
sumpoint += addpoint[key];
}
}
let operationPet = null;
for (let pet of this.petList) {
if (pet.petid == data.petid) {
operationPet = pet;
break;
}
}
if (operationPet == null) {
return;
}
if (data.type == 0) {
for (const key in operationPet.ppoint) {
operationPet.ppoint[key] = 0;
}
} else if (data.type == 1) {
for (const key in operationPet.dpoint) {
operationPet.dpoint[key] = 0;
}
} else if (data.type == 2) {
let curpoint = 0;
for (const key in operationPet.ppoint) {
curpoint += operationPet.ppoint[key];
}
if (sumpoint + curpoint > operationPet.level * 4) {
return;
}
for (const key in addpoint) {
if (!operationPet.ppoint[key]) {
operationPet.ppoint[key] = 0;
}
operationPet.ppoint[key] += addpoint[key];
}
} else if (data.type == 3) {
let curpoint = 0;
for (let key in operationPet.dpoint) {
curpoint += operationPet.dpoint[key];
}
if (sumpoint + curpoint > PetPracticeMgr.shared.GetLevelPoint(operationPet.relive, operationPet.xlevel)) { //超过最大修炼点
return;
}
for (let key in addpoint) {
if (!operationPet.dpoint[key]) {
operationPet.dpoint[key] = 0;
}
operationPet.dpoint[key] += addpoint[key];
}
}
operationPet.calculateAttribute();
if (player) {
//cxf宠物加点
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物加点",
operateResSerial: operationPet.petid,
operateResName: operationPet.name,
operateContent: ""
})
}
this.send('s2c_update_pet', {
info: operationPet.toObj()
});
// 如果在队伍需要刷新队伍信息
this.refresh_team_data();
}
petLockSkill(petid: any, skillid: any) {
// this.send('s2c_notice', {
// strRichText: '功能暂未开放'
// });
// return;
let pet = this.getPetByID(petid);
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (!pet) {
return;
}
let skillinfo = pet.skill_list[skillid];
if (!skillinfo) {
return;
}
if (skillinfo.lck == 1) {
this.send('s2c_notice', {
strRichText: '技能已经被锁定,仙玉不变'
});
return;
}
let n = pet.getLockedSkillNum();
let cost = Math.pow(2, n) * GameUtil.petLockSkillJade;
let strErr = this.CostFee(1, cost, '宠物技能锁定');
if (strErr != '') {
this.send('s2c_notice', {
strRichText: strErr
});
return;
}
pet.lockSkill(skillid);
if (player) {
//cxf宠物技能加锁
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物技能加锁",
operateResSerial: pet.petid,
operateResName: pet.name,
operateContent: ""
})
}
}
petForgetSkill(petid: any, skillid: any) {
let pet = this.getPetByID(petid);
if (pet) {
pet.forgetSkill(skillid);
//cxf宠物遗忘技能
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.PET,
operateDepict: "宠物遗忘技能",
operateResSerial: pet.petid,
operateResName: pet.name,
operateContent: SKDataUtil.toJson(pet.toObj(), "{}")
})
}
}
petShenShouSkill(petid: any, skillid: any) {
let pet = this.getPetByID(petid);
if (!pet) {
return;
}
if (pet.grade < GameUtil.petGrade.Shen) {
return;
}
// if (skillid == GameUtil.skillIds.RuHuTianYi) {
// this.send('s2c_notice', {
// strRichText: '该技能稍后开放!'
// });
// return;
// }
let strErr = this.CostFee(GameUtil.goldKind.Money, 50000000);
if (strErr != '') {
this.send('s2c_notice', {
strRichText: strErr
});
return;
}
pet.changeShenShouSkill(skillid);
this.send('s2c_pet_changeSskill', {
errorcode: MsgCode.SUCCESS,
petid: petid,
skillid: skillid,
});
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.PET,
operateDepict: "改变神兽技能",
operateResSerial: pet.petid,
operateResName: pet.name,
operateContent: SKDataUtil.toJson(pet.toObj(), "{}")
})
}
levelReward(level: any) {
if (this.level_reward.split(':').indexOf(level + '') != -1)
return;
let level_reward = GameUtil.require_ex('../../conf/prop_data/prop_level.json');
let item = level_reward[level];
if (item) {
if (this.examine(item.relive, level)) {
if (this.level_reward == '') {
this.level_reward += level;
} else {
this.level_reward += ':' + level;
}
let reward_list = item.reward_item.split(';');
for (let item of reward_list) {
let reward = item.split(':');
this.addItem(reward[0], reward[1], false, '等级奖励');
}
let send_data = {
level: level,
};
this.send('s2c_level_reward', send_data);
}
}
}
examine(relive: any, level: any): boolean {
if (this.relive > relive) {
return true
} else {
if (this.level >= level) {
return true;
}
}
return false;
}
changePet(petid: any, issend = true) {
for (const pet of this.petList) {
if (pet.petid == petid) {
this.curPet = pet;
this.curPetId = petid;
// 刷新队伍信息
this.refresh_team_data();
if (issend) {
this.send('s2c_change_pet', {
curid: this.curPet.petid
});
}
break;
}
}
}
delPet(data: any) {
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (this.curPet != null && this.curPet.petid == data.petid) {
this.curPet.state = 0;
this.curPet = null;
}
for (let index = 0; index < this.petList.length; index++) {
let pet: Pet = this.petList[index];
if (pet.petid == data.petid) {
pet.state = 0;
this.petList.splice(index, 1);
for (let skillid in pet.skill_list) {
if (Number(skillid) == 2110 || Number(skillid) == 2010) {
PetSupport.shared.deletePet(this.roleid, pet.petid);
}
}
DB.delPet(pet.petid, this.roleid, (code: number) => {
SKLogger.debug(`玩家[${this.roleid}:${this.name}]放生召唤兽[${pet.petid}:${pet.name}]${code == MsgCode.SUCCESS ? "成功" : "失败"}`);
if (player) {
//cxf宠物放生
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物放生",
operateResSerial: pet.petid,
operateResName: pet.name,
operateContent: ""
})
}
})
break;
}
}
let params: any = {};
if (this.curPet == null) {
params.curid = -1;
} else {
params.curid = this.curPet.petid;
}
params.delid = data.petid;
this.send('s2c_del_pet', params);
}
/**
* type 装备类型0:新手装备1:高级装备2:神兵3:仙器 4:翅膀, 5:配饰
* index 装备位置:
* resid 装备编号
* roleid 角色id
* @param data
*/
addEquip(data: any) {
if (this.getBagItemAllKindNum() >= this.bagKindNum) {
this.send('s2c_notice', {
strRichText: `背包已满`
});
return;
}
let equipAttr = EquipMgr.shared.makeEquipAttr(data);
if (data.type == EEquipType.BALDRIC) {
equipAttr.BaseAttr = '[]';
}
if (!equipAttr) {
SKLogger.warn(`玩家[${this.roleid}:${this.name}]加装备失败${data.resid}`);
this.send('s2c_operation_result', {
code: 0,
});
return;
}
let equip = new Equip(equipAttr, this);
this.addEquipList(equip);
this.equipObjs[equip.EquipID] = equip;
EquipMgr.shared.addEquip(equip);
// this.send('s2c_bagitem', {
// info: SKDataUtil.toJson(this.bag_list, "{}")
// });
this.sendEquipList();
let equipInfo = equip.toObj();
let params = {
equip: SKDataUtil.toJson(equipInfo, "{}")
};
this.send("s2c_equip_info", params);
this.send('s2c_notice', {
strRichText: `恭喜你获得了[img]ui://main_ui/${equipInfo.Shape}[/img][color=#E96E29][${equipInfo.EName}][/color]`
});
/* 神兵 仙器广播 */
if (data.type > 1) {
if (data.type == 2) {
SKLogger.debug(`玩家[${this.roleid}:${this.name}]获得神兵[${equipAttr.EquipID}:${equipInfo.EName}]`);
} else if (data.type == 3) {
SKLogger.debug(`玩家[${this.roleid}:${this.name}]获得仙器[${equipAttr.EquipID}:${equipInfo.EName}]`);
}
if (data.type == 3 && equipInfo.Grade == 1) {
} else {
let strRichText = `<color=#00ff00 > ${this.name}</c > <color=#ffffff > 获得了</c ><color=#0fffff > ${equipInfo.EDesc}:${equipInfo.EName}</color ><color=#ffffff > 真是太幸运了</c >`;
PlayerMgr.shared.broadcast('s2c_screen_msg', {
strRichText: strRichText,
bInsertFront: 0
});
}
}
DB.createEquip(this.roleid, equipInfo, (code: MsgCode) => {
if (code != MsgCode.SUCCESS) {
SKLogger.debug(`存档:玩家[${this.roleid}:${this.name}]加入装备属性[${equipAttr}]失败!`);
}
});
//cxf合成装备
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EQUIP,
operateDepict: "合成装备",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
}
/**
* type 类型6 法宝
* index 装备位置:
* roleid 角色id
* @param data
*/
addMagicWeapon(data: any) {
if (this.getBagItemAllKindNum() >= this.bagKindNum) {
this.send('s2c_notice', {
strRichText: `背包已满`
});
return;
}
let magicWeapon = MagicWeaponMgr.shared.getMagicWeaponAttr(data);
if (!magicWeapon) {
SKLogger.warn(`玩家[${this.roleid}:${this.name}]加装备失败${data.resid}`);
this.send('s2c_operation_result', {
code: 0,
});
return;
}
let weapon = new MagicWeapon(magicWeapon, this);
this.addMagicWeaponList(weapon);
this.magicWeaponObjs[weapon.efId] = weapon;
MagicWeaponMgr.shared.addMagicWeapon(weapon);
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
this.sendMagicWeaponList();
let weaponInfo = weapon.toObj();
let params = {
weapon: SKDataUtil.toJson(weaponInfo, "{}")
};
this.send("s2c_magic_weapon", params);
this.send('s2c_notice', {
strRichText: `恭喜您获得了${SKDataUtil.noToChinese(weaponInfo.efType)}阶法宝:${weaponInfo.efName}`
});
//
DB.createMagicWeapon(this.roleid, weaponInfo, (code: MsgCode) => {
if (code != MsgCode.SUCCESS) {
SKLogger.info(`存档:玩家[${this.roleid}:${this.name}]加入法宝属性[${weaponInfo}]失败!`);
}
});
}
createEquip(data: any) {
if (this.getBagItemAllKindNum() >= this.bagKindNum) {
this.send('s2c_notice', {
strRichText: `背包已满`
});
return;
}
if (data.is > 0 || data.is == undefined) {
if (data.type == 2) {
if (!this.bag_list[10408] || this.bag_list[10408] < 50) {
return; //神兵碎片不足
}
this.bag_list[10408] -= 50;
SKLogger.debug(`玩家[${this.name}${this.roleid}]消耗 神兵碎片 50 个`);
} else if (data.type == 3) {
if (!this.bag_list[10406] || this.bag_list[10406] < 40) {
return; //八荒遗风不足
}
this.bag_list[10406] -= 40;
SKLogger.debug(`玩家[${this.name}${this.roleid}]消耗 八荒遗风 40 个`);
}
} else {
data.type = EEquipType.XianQi;
}
this.addEquip(data);
}
sendEquipList() {
let listInfo: any = {};
listInfo.use = {};
listInfo.score = 0;
listInfo.list = [];
listInfo.info = {};
for (let equip of this.currentEquips) {
let full = equip.getFullData();
if (full) {
listInfo.score += Number(full.BaseScore);
listInfo.use[equip.EIndex] = equip.EquipID;
listInfo.info[equip.EquipID] = equip.getSendInfo();
PaiHangMgr.shared.updateEquipRank(this.roleid, this.sex, this.name, equip.EIndex, this.level, full.BaseScore, this.relive, equip.name);
}
}
for (let equip of this.listEquips) {
listInfo.list.push(equip.EquipID);
listInfo.info[equip.EquipID] = equip.getSendInfo();
}
// 更新装备评价排行榜
PaiHangMgr.shared.updateEquipRankData(this.roleid, this.sex, this.name, this.race, this.level, listInfo.score, this.relive);
this.send("s2c_equip_list", {
list: SKDataUtil.toJson(listInfo, "{}")
});
}
sendMagicWeaponList() {
let listInfo: any = {};
listInfo.use = {};
listInfo.score = 0;
listInfo.list = [];
listInfo.info = {};
// 获取穿戴的法宝
for (let magicWeapon of this.currentMagicWeapons) {
let full = magicWeapon.getSendInfo();
if (full) {
listInfo.score += Number(full.BaseScore);
listInfo.use[magicWeapon.efIndex] = magicWeapon.efId;
listInfo.info[magicWeapon.efId] = full;
}
}
for (let magicWeapon of this.listMagicWeapons) {
listInfo.list.push(magicWeapon.efId);
listInfo.info[magicWeapon.efId] = magicWeapon.getSendInfo;
}
// 更新法宝评价排行榜
// PaiHangMgr.shared.updateEquipRankData(this.roleid, this.sex, this.name, this.race, this.level, listInfo.score, this.relive);
this.send("s2c_magic_weapon_list", {
list: SKDataUtil.toJson(listInfo, "{}")
});
}
getLockerEquipInfo() {
let rInfo: any = {};
rInfo.locker = [];
rInfo.list = [];
for (let equip of this.listEquips) {
rInfo.list.push(equip.getSendInfo());
}
for (let equip of this.lockerEquips) {
rInfo.locker.push(equip.getSendInfo());
}
return rInfo;
}
// 发送装备信息
sendEquipInfo(equipId: string) {
if (this.equipObjs[equipId]) {
let equip: Equip = this.equipObjs[equipId];
let params = {
equip: SKDataUtil.toJson(equip.toObj(), "{}")
};
this.send("s2c_equip_info", params);
}
}
// 获取属性评分
attributeScore(data: any) {
let score: number = 0;
// 判断装备是否存在
if (this.equipObjs[data.equipId]) {
// 获取装备
let equip: Equip = this.equipObjs[data.equipId];
let info = equip.toObj();
// 配饰属性评分
if (EEquipType.BALDRIC == info.EquipType) {
score = GameUtil.getBasicsListAttrScore(info.Race, info.Sex, info.BaseAttr)
}
// 翅膀属性评分
else if (EEquipType.WING == info.EquipType) {
score = GameUtil.getBasicsListAttrScore(info.Race, info.Sex, info.LianhuaAttr)
}
// 装备属性评分
else {
// 炼化
if (data.type == 0) {
score = GameUtil.getBasicsListAttrScore(info.Race, info.Sex, SKDataUtil.jsonBy(info.LianhuaAttr))
}
// 重铸
else {
score = GameUtil.calculate(JSON.parse(info.BaseAttr), info.Race, info.Sex, true);
}
}
}
// 返回属性评分
this.send('s2c_attribute_score', {
attributeScore: score
});
}
changeWeapon(weapon: any) {
if (weapon) {
let fullEquipData = weapon.getFullData(this.roleid);
let weaponstr = SKDataUtil.toJson({
gemcnt: fullEquipData.GemCnt,
type: fullEquipData.EquipType,
level: fullEquipData.Grade
}, "{}");
this.send('s2c_change_weapon', {
weapon: weaponstr
});
} else {
this.send('s2c_change_weapon', {
weapon: ''
});
}
}
upgradeEquip(data: any) {
let equip = this.equipObjs[data.equipid];
if (equip == null) {
return;
}
if (equip.EquipType > EEquipType.HIGH) {
return;
}
let itemid = 10405;
if (this.bag_list[itemid] && this.bag_list[itemid] > 0) {
let up = equip.upgrade(data);
if (!up) return; //升级失败
this.addItem(itemid, -1, false, '装备升级消耗');
if (this.bag_list[itemid] <= 0) {
delete this.bag_list[itemid];
}
} else { //没有盘古精铁
return;
}
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
this.sendEquipInfo(data.equipid);
if (equip.EIndex == 1 && this.currentEquips.indexOf(equip) != -1) {
this.changeWeapon(equip);
}
this.send('s2c_notice', {
strRichText: `升级成功`
});
}
shenbignUpgrade(data: any) {
let equip = this.equipObjs[data.equipid];
if (equip == null) {
return;
}
if (equip.EquipType > EEquipType.ShenBing) {
return;
}
if (data.use > 0 && this.equipObjs[data.use] == null) return;
if (equip.canUpgrade() == false) {
return;
}
// 是否失败
if (equip.checkUpgradeBroke() == false) {
if (equip.Grade == 1) {
this.delEquip(data.equipid, true, '神兵升级破碎');
} else {
this.delEquip(data.use, true, '神兵升级破碎');
}
this.sendEquipList();
// 神兵破碎 给 神兵碎片
this.addItem(10408, 5, false, '神兵升级破碎');
this.send('s2c_notice', {
strRichText: `神兵升级失败`
});
} else {
equip.upgrade(data);
this.delEquip(data.use, true, '神兵升级');
this.sendEquipList();
this.sendEquipInfo(data.equipid);
if (equip.EIndex == 1 && this.currentEquips.indexOf(equip) != -1) {
this.changeWeapon(equip);
}
this.send('s2c_notice', {
strRichText: `神兵升级成功`
});
}
}
xianqiUpGrade(data: any) {
let equip: Equip = this.equipObjs[data.equipid];
if (equip == null || equip == undefined) {
return;
}
if (equip.Grade == 1) { //一阶升阶需要3个
if ((data.use1 > 0 && this.equipObjs[data.use1] == null) || (data.use2 > 0 && this.equipObjs[data.use2] == null)) {
this.send_notice("数量不够")
return;
}
if (equip.pos == undefined) {
equip.pos = 0;
}
if (this.equipObjs[data.use1].pos == undefined) {
this.equipObjs[data.use1].pos = 0;
}
if (this.equipObjs[data.use2].pos == undefined) {
this.equipObjs[data.use2].pos = 0;
}
} else {//大于一阶需要两个
if ((data.use1 > 0 && this.equipObjs[data.use1] == undefined) || data.use1 <= 0) {
this.send_notice("数量不够")
return;
}
if (equip.pos == undefined) {
equip.pos = 0;
}
if (this.equipObjs[data.use1].pos == undefined) {
this.equipObjs[data.use1].pos = 0;
}
if (this.equipObjs[data.use1].pos == undefined) {
this.equipObjs[data.use1].pos = 0;
}
}
let up = equip.canUpgrade();
if (!up) {
SKLogger.warn(`仙器[${equip.name}(${equip.EquipID})]不能升阶!`);
return;
} else if (equip.pos == 2 || this.equipObjs[data.use1].pos == 2 || (this.equipObjs[data.use2] != null && this.equipObjs[data.use2].pos == 2)) {
this.send('s2c_notice', {
strRichText: `已穿戴装备[${equip.EquipID}:${equip.name}]不能升阶`
});
return;
} else if (equip.EIndex != this.equipObjs[data.use1].EIndex && (this.equipObjs[data.use2] != null && equip.EIndex != this.equipObjs[data.use2].EIndex)) {
this.send('s2c_notice', {
strRichText: `不同类型装备不能升阶`
});
return;
} else if (equip.pos == 4 || this.equipObjs[data.use1].pos == 4 || (this.equipObjs[data.use2] != null && this.equipObjs[data.use2].pos == 4)) {
this.send('s2c_notice', {
strRichText: `仓库中装备不能升阶`
});
return;
}
this.delEquip(data.use1, true, `仙器升阶`);
this.delEquip(data.use2, true, `仙器升阶`);
equip.upgrade(data);
this.sendEquipList();
this.sendEquipInfo(data.equipid);
if (equip.EIndex == 1 && this.currentEquips.indexOf(equip) != -1) {
this.changeWeapon(equip);
}
this.send('s2c_notice', {
strRichText: `仙器:${equip.name}${equip.Grade}阶成功`
});
//cxf仙器升阶
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EQUIP,
operateDepict: "仙器升阶",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
}
delEquip(equipid: any, uninlay = true, source = '') {
if (!equipid || equipid <= 0) {
return;
}
let delequip = null;
for (let index = 0; index < this.currentEquips.length; index++) { //已经装备的不能删,所以注释掉以下代码
if (this.currentEquips[index].EquipID == equipid) {
delequip = this.currentEquips[index];
this.currentEquips.splice(index, 1);
break;
}
}
for (let index = 0; index < this.listEquips.length; index++) {
if (this.listEquips[index].EquipID == equipid) {
delequip = this.listEquips[index];
this.listEquips.splice(index, 1);
break;
}
}
if (delequip != null) {
delequip.pos = EEquipPos.UNKNOW;
let equipfulldata = delequip.getFullData();
SKLogger.debug(`玩家[${this.roleid}:${this.name}]删除装备[${delequip.EquipID}:${equipfulldata.EName}]:${source}]`);
if (uninlay) {
this.unInLay(delequip);
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
}
delequip.state = 0;
delequip.save();
delete this.equipObjs[delequip.EquipID];
EquipMgr.shared.delEquip(delequip.EquipID);
this.schemeMgr.deleteCurEquips(delequip.EquipID);
}
}
updateEquip(data: any) {
if (!data) {
return;
}
let ret = false;
if (data.operation == 0) {
this.delEquip(data.equipid, true, '装备删除');
this.sendEquipList();
return;
} else if (data.operation == 1 && this.equipObjs[data.equipid]) {
//装备
let equip: Equip = this.equipObjs[data.equipid];
let fullEquipData = equip.getFullData(this.roleid);
let flag = true
if (fullEquipData.OwnerRoleId > 0 && fullEquipData.OwnerRoleId != this.resid) {
this.send('s2c_notice', {
strRichText: '角色不匹配,不能使用!'
});
return;
} else if (fullEquipData.Sex != 9 && fullEquipData.Sex != this.sex) {
this.send('s2c_notice', {
strRichText: '角色不匹配,不能使用!'
});
return;
}
if (Array.isArray(fullEquipData.Race)) {//如果是数组,多种族通用
for (let race of fullEquipData.Race) {
if (race == this.race) {
flag = false;
}
}
if (flag) {
this.send('s2c_notice', {
strRichText: '角色不匹配,不能使用!'
});
return;
}
} else if (fullEquipData.Race != 9 && fullEquipData.Race != this.race) {
this.send('s2c_notice', {
strRichText: '角色不匹配,不能使用!'
});
return;
}
if (fullEquipData.NeedGrade > this.level || fullEquipData.NeedRei > this.relive) {
this.send('s2c_notice', {
strRichText: '角色等级不足,尚不能使用!'
});
return;//转生或等级不符合
}
if (fullEquipData.Shuxingxuqiu) { //属性需求不符合
for (const key in fullEquipData.Shuxingxuqiu) {
if (this.getAttr1(key) < fullEquipData.Shuxingxuqiu[key]) {
this.send('s2c_notice', {
strRichText: '角色属性不足,尚不能使用!'
});
return;
}
}
}
for (let index = 0; index < this.currentEquips.length; index++) {
let item = this.currentEquips[index];
if (item.EIndex == equip.EIndex) {
item.pos = EEquipPos.BAG;
this.addEquipList(item);
this.currentEquips.splice(index, 1);
}
}
equip.pos = EEquipPos.USE;
this.currentEquips.push(equip);
for (let index = 0; index < this.listEquips.length; index++) {
let item = this.listEquips[index];
if (item.EquipID == data.equipid) {
this.listEquips.splice(index, 1);
break;
}
}
this.sendEquipList();
if (equip.EIndex == 1) {
this.changeWeapon(equip);
} else if (equip.EIndex == 6) {
let conf = EquipMgr.shared.getXianQiBy(equip.Type);
this.wingId = conf.Shape;
}
SKLogger.debug(`玩家[${this.roleid}:${this.name}]穿上装备[${equip.name}]`);
ret = true;
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
} else if (data.operation == 2 && this.equipObjs[data.equipid]) {
//卸下
let equip = this.equipObjs[data.equipid];
let finduse = false;
for (let index = 0; index < this.currentEquips.length; index++) {
if (this.currentEquips[index].EquipID == data.equipid) {
this.currentEquips[index].pos = EEquipPos.BAG;
this.currentEquips.splice(index, 1);
finduse = true;
break;
}
}
if (finduse) {
this.addEquipList(equip);
this.sendEquipList();
if (equip.EIndex == 1) {
this.changeWeapon(null);
} else if (equip.EIndex == 6) {
this.wingId = 0;
}
SKLogger.debug(`玩家[${this.roleid}:${this.name}]卸下装备[${equip.name}]`);
ret = true;
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
}
}
if (ret) {
this.calculateAttr();
//this.send('s2c_player_data', this.getData());
//将通过背包修改的装备信息,同步修改方案装备信息
let curEqupsData: any = {}
this.currentEquips.forEach((e: any) => {
curEqupsData[e.EIndex] = e.EquipID;
});
if ((data.operation == 1 || data.operation == 2) && this.schemeMgr) {
this.schemeMgr.syncSchemeEquips(curEqupsData);
}//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
} else {
this.send('s2c_operation_result', {
code: MsgCode.FAILED
});
}
}
// 拆卸
unInLay(equip: Equip) {
if (equip == null) {
return;
}
let itemList = equip.getGemList();
for (let itemId in itemList) {
if (itemList[itemId] <= 0) {
continue;
}
if (this.bag_list[itemId] == null) {
this.bag_list[itemId] = itemList[itemId];
SKLogger.debug(`玩家[${this.roleid}:${this.name}]装备[${equip.name}]拆卸返回道具[${ItemUtil.getItemName(itemId)}]`);
} else {
this.bag_list[itemId] += itemList[itemId];
SKLogger.debug(`玩家[${this.roleid}:${this.name}]装备[${equip.name}]拆卸返回道具[${ItemUtil.getItemName(itemId)}]${itemList[itemId]}`);
}
}
equip.GemCnt = 0;
// 刷新装备
this.sendEquipList();
SKLogger.debug(`玩家[${this.roleid}:${this.name}]装备拆卸[${equip.name}]`);
}
// 宝石镶嵌
equipInlay(data: any) {
let equip: Equip = this.equipObjs[data.equipid];
if (equip == null) {
SKLogger.warn(`玩家[${this.roleid}:${this.name}]宝石镶嵌找不到装备${data.equipid}`);
return;
}
if (data.operation == 0) {
this.unInLay(equip);
if (equip.EIndex == 1 && this.currentEquips.indexOf(equip) != -1) {
this.changeWeapon(equip);
}
} else {
let fullData = equip.getFullData();
if (fullData) {
let maxEmbed = fullData.MaxEmbedGemCnt;
if (equip.GemCnt >= maxEmbed) {
this.send_notice(`您的装备${equip.name}已经镶嵌到顶级!`);
return;
}
}
let itemid = equip.getInlayGemID();
let conf = ItemUtil.getItemData(itemid);
if (conf == null) {
SKLogger.warn(`玩家[${this.roleid}:${this.name}]装备[${equip.name}]宝石镶嵌找不到道具[${itemid}]定义!`);
this.send_notice(`您的装备${equip.name}]无法镶嵌宝石!`);
return;
}
if (this.bag_list[itemid] && this.bag_list[itemid] > 0) {
this.bag_list[itemid] -= 1;
if (this.bag_list[itemid] <= 0) {
delete this.bag_list[itemid];
}
equip.GemCnt += 1;
SKLogger.debug(`玩家[${this.roleid}:${this.name}]装备[${equip.name}]镶嵌宝石[${conf.name}]成功!`);
equip.calculateAttribute();
if (equip.EIndex == 1 && this.currentEquips.indexOf(equip) != -1) {
this.changeWeapon(equip);
}
} else {
SKLogger.debug(`玩家[${this.roleid}:${this.name}]装备[${equip.name}]镶嵌,缺少[${conf.name}]!`);
this.send_notice(`您的装备${equip.name}]无法镶嵌宝石:[${conf.name}]数量不足!`);
return;
}
}
equip.calculateAttribute();
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
this.sendEquipInfo(data.equipid);
this.calculateAttr();
this.send('s2c_player_data', this.getData());
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
// 刷新装备
this.sendEquipList();
//cxf宝石镶嵌
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EQUIP,
operateDepict: "宝石镶嵌",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
}
// 装备炼化 (装备和翅膀)
equipRefine(data: any) {
let equip = this.equipObjs[data.equipid];
if (equip == null) {
return;
}
if (data.refine) {
let refine = SKDataUtil.jsonBy(data.refine);
equip.refine = refine // 选择替换的属性, 其他炼化为空
}
if (data.operation == 1) {// 0获取1确认
if (equip.refine == null) {
return;
}
equip.LianhuaAttr = equip.refine.slice(0);
equip.refine = null;
equip.calculateAttribute();
this.sendEquipInfo(data.equipid);
this.calculateAttr();
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
this.send_notice(`炼化成功`);
// 刷新装备
this.sendEquipList();
//cxf装备炼化
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EQUIP,
operateDepict: "装备炼化",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
} else {
// 如果是翅膀,则需要10个翅膀精华10411练化一次
if (equip.EIndex == 6) {
let needitem = 10411;
if (this.bag_list[needitem] && this.bag_list[needitem] > 1) {
this.bag_list[needitem] -= 10;
if (this.bag_list[needitem] <= 0) {
delete this.bag_list[needitem];
}
} else { //
this.send('s2c_notice', {
strRichText: `炼化材料不足至少需要10个翅膀精华`
});
return;
}
} else {
let needitem = 10404;
if (data.level == 3) { needitem = 10410; }//超级九彩云龙珠
//if (data.level == 4) { needitem = 10411; }//翅膀精华
if (this.bag_list[needitem]) {
if (needitem == 10404 && this.bag_list[needitem] > 30) {
this.bag_list[needitem] -= 30;
if (this.bag_list[needitem] <= 0) {
delete this.bag_list[needitem];
}
} else if (needitem == 10404 && this.bag_list[needitem] < 30) {
this.send('s2c_notice', {
strRichText: `需要30个高级九彩云龙珠不足`
});
return;
}
if (needitem == 10410 && this.bag_list[needitem] >= 5) {
this.bag_list[needitem] -= 5;
if (this.bag_list[needitem] <= 0) {
delete this.bag_list[needitem];
}
} else if (needitem == 10410 && this.bag_list[needitem] < 5) {
this.send('s2c_notice', {
strRichText: `需要5个超级九彩云龙珠`
});
return;
}
} else {
this.send('s2c_notice', {
strRichText: `炼化材料不足`
});
return;
}
}
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
equip.refine = null;
SKLogger.debug(`炼化数据:` + data.level)
if (data.level == 2) {
let list = [];
let refinelist = EquipMgr.shared.getLianhuaData(equip.EIndex, data.level);
for (let attr of refinelist) {
equip.refine = attr;
let score = GameUtil.getBasicsListAttrScore(equip.Race, equip.Sex, equip.refine);
let obj = {
property: equip.refine,
score: score
}
list.push(obj)
}
this.send('s2c_high_refine', {
list: SKDataUtil.toJson(list, "[]")
});
} else if (data.level == 3) {
equip.refine = EquipMgr.shared.getMaxLianhuaData(equip.EIndex, data.level);//超级九彩炼化数据
this.send('s2c_equip_property', {
property: SKDataUtil.toJson(equip.refine, "[]"),
score: GameUtil.getBasicsListAttrScore(equip.Race, equip.Sex, equip.refine)
});
} else if (data.level == 4) {
equip.refine = EquipMgr.shared.getWingLianhuaData();//炼化翅膀
this.send('s2c_equip_property', {
property: SKDataUtil.toJson(equip.refine, "[]"),
score: GameUtil.getBasicsListAttrScore(equip.Race, equip.Sex, equip.refine)
});
}
else {
let list = [];
let refinelist = EquipMgr.shared.getLianhuaData(equip.EIndex, data.level);
for (let attr of refinelist) {
equip.refine = attr;
let score = GameUtil.getBasicsListAttrScore(equip.Race, equip.Sex, equip.refine);
let obj = {
property: equip.refine,
score: score
}
list.push(obj)
}
this.send('s2c_high_refine', {
list: SKDataUtil.toJson(list, "[]")
});
}
}
}
// 道具分解
itemResolve(data: any) {
let itemData = ItemUtil.getItemData(data.itemId);
if (itemData == null) { // 无此道具
SKLogger.warn(`玩家[${this.roleid}:${this.name}]物品[${data.itemId}]分解找不到定义!`);
return;
}
let count = ItemUtil.getBagItemCount(this, itemData.id);
if (count < 1) {
SKLogger.warn(`玩家[${this.roleid}:${this.name}]背包无此物品[${data.itemId}]!`);
return;
}
if (itemData && itemData.type == 10 && itemData.level == 2) {
//let count = data.count * 10;
this.addBagItem(10102, 10, true);
}
this.addItem(data.itemId, -1, false, `道具[${itemData.name}]分解`);
//let score = ItemUtil.canResolve(itemData);
// if (score < 1) {
// this.send('s2c_notice', {
// strRichText: `物品[${data.itemId}]无法分解!`
// });
// return;
// }
// this.shuilu.gongji += score;
// this.send('s2c_you_money', {
// nKind: GameUtil.goldKind.SLDH_Score,
// nNum: this.shuilu.gongji,
// nChange: score
// });
// let info = `消耗[color=#b94bd1][${itemData.name}][/color]X1得到功绩${score}`;
// this.send('s2c_notice', {
// strRichText: info
// });
}
// 佩饰重铸
baldricRecast(data: any) {
let equip: Equip = this.equipObjs[data.equipid];
if (equip == null) {
return;
}
if (!ItemUtil.isBaldric(equip.EIndex)) {
return;
}
let item_1 = 10406;
let item_2 = 10409;
if (data.operation == 1) {
if (equip.recast == null) {
return;
}
if (data.locks) {
let total = 0;
for (let lock of data.locks) {
if (lock == 1) {
total++;
}
}
if (total > 0) {
let hasCnt = ItemUtil.getBagItemCount(this, 70004)
total = SKDataUtil.clamp(total, 1, 3);
let jade = GameUtil.lockJade[total - 1];
if (hasCnt < jade) {
this.send_notice(`您的碎片不足,佩饰重铸锁住${total}条属性需消耗碎片${jade}`);
return;
}
this.addItem(70004, -jade, false, `佩饰重铸锁住${total}属性,消耗碎片${jade}`);
}
let source = equip.BaseAttr;
let target = SKDataUtil.jsonBy(equip.recast);
let index = 0;
for (let lock of data.locks) {
if (lock == 0) {
source[index] = target[index];
}
index++;
}
} else {
equip.BaseAttr = SKDataUtil.jsonBy(equip.recast);
}
equip.calculateAttribute();
equip.recast = null;
this.sendEquipInfo(data.equipid);
this.calculateAttr();
this.send('s2c_player_data', this.getData());
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
this.send_notice(`重铸替属性成功`);
// 刷新装备
this.sendEquipList();
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
//cxf配饰重铸
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.EQUIP,
operateDepict: "配饰重铸",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
}
} else {
if (this.money < 300000) {
this.send_notice(`佩饰重铸需要300000银两!`);
return;
}
let item_count_1 = this.getBagItemNum(item_1);
if (item_count_1 < 5) {
this.send_notice(`缺少重铸材料[${ItemUtil.getItemName(item_1)}至少5个]`);
return;
}
let item_count_2 = this.getBagItemNum(item_2);
if (item_count_2 < 1) {
this.send_notice(`缺少重铸材料[${ItemUtil.getItemName(item_2)}至少1个]`);
return;
}
let recastData = EquipMgr.shared.getBaldricRecast(equip);
if (recastData) {
equip.recast = recastData.BaseAttr;
this.addMoney(0, -300000, "", MsgCode.SUCCESS);
this.addBagItem(item_1, -5, false);
this.addBagItem(item_2, -1, false);
let info = equip.toObj();
//cxf配饰重铸
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EQUIP,
operateDepict: "配饰重铸",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
this.send('s2c_equip_property', {
property: equip.recast,
score: GameUtil.getBasicsListAttrScore(info.Race, info.Sex, SKDataUtil.jsonBy(info.recast))
});
}
}
}
// 佩饰分解
baldricResolve(data: any) {
let equip: Equip = this.equipObjs[data.equipid];
if (equip == null) {
SKLogger.debug(`[${this.roleid}:${this.name}]佩饰分解找不到装备${data.equipid}`);
return;
}
if (!ItemUtil.isBaldric(equip.EIndex)) {
return;
}
let score = 1;
if (equip.BaseAttr.length != 0) {
if (equip.Grade == 2) {
score = 2;
} else if (equip.Grade == 3) {
score = 5;
}
}
this.shuilu.gongji += score;
this.delEquip(equip.EquipID, true, "佩饰分解");
this.sendEquipList();
this.send('s2c_you_money', {
nKind: GameUtil.goldKind.SLDH_Score,
nNum: this.shuilu.gongji,
nChange: score
});
let info = `消耗[color=${ItemUtil.getBaldricColor(equip.Grade)}][${equip.name}][/color]X1得到功绩${score}`;
//cxf配饰分解
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EQUIP,
operateDepict: "配饰分解",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
this.send('s2c_notice', {
strRichText: info
});
}
// 配饰鉴定
accAuthenticate(data: any) {
let equip: Equip = this.equipObjs[data.equipid];
if (equip == null) {
SKLogger.debug(`[${this.roleid}:${this.name}]佩饰鉴定找不到装备${data.equipid}`);
return;
}
if (!ItemUtil.isBaldric(equip.EIndex)) {
return;
}
// 玉符,盘古精铁,补天神石,银两
let need_goods: any = [{ itemId: 10409, num: 1, type: GameUtil.goldKind.Goods }, { itemId: 10405, num: 1, type: GameUtil.goldKind.Goods }, { itemId: 10407, num: 1, type: GameUtil.goldKind.Goods }, { itemId: 90003, num: 230000, type: GameUtil.goldKind.Money }];
for (const need of need_goods) {
if (need.type == GameUtil.goldKind.Goods) {
let item_count = this.getBagItemNum(need.itemId);
if (item_count < need.num) {
this.send('s2c_notice', {
strRichText: `缺少鉴定材料[${ItemUtil.getItemName(need.itemId)}至少${need.num}个]`,
});
return;
}
} else {
if (this.money < need.num) {
this.send('s2c_notice', {
strRichText: `佩饰鉴定需要${ItemUtil.getItemName(need.num)}银两!`,
});
return;
}
}
}
for (const need of need_goods) {
if (need.type == GameUtil.goldKind.Goods) {
this.addBagItem(need.itemId, -need.num, false);
} else {
this.addMoney(GameUtil.goldKind.Money, -need.num, "", MsgCode.FAILED);
}
}
let recastData = EquipMgr.shared.getBaldricRecast(equip);
if (recastData) {
// 赋值装备属性
equip.BaseAttr = SKDataUtil.jsonBy(recastData.BaseAttr);
equip.calculateAttribute();
// 发送装备信息
this.sendEquipInfo(data.equipid);
// 核对属性
this.calculateAttr();
// 更新装备属性
this.send('s2c_player_data', this.getData());
this.send('s2c_acc_authenticate', {
attribute: recastData.BaseAttr
});
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
}
//cxf配饰鉴定
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EQUIP,
operateDepict: "配饰鉴定",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
}
// 装备重铸
equipRecast(data: any) {
let equip: any = this.equipObjs[data.equipid];
if (equip == null) {
return;
}
if (equip.EquipType == 0 || equip.EquipType == 2) {
return;
}
if (data.operation == 1) {
if (equip.recast == null) {
return;
}
equip.setDB(equip.recast);
equip.calculateAttribute();
equip.recast = null;
this.sendEquipInfo(data.equipid);
this.calculateAttr();
this.send('s2c_player_data', this.getData());
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
this.send_notice(`重铸成功`);
// 刷新装备
this.sendEquipList();
//cxf装备重铸
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EQUIP,
operateDepict: "装备重铸",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
} else {
let itemid = 10405;
if (equip.EquipType == 3) {
itemid = 10401;
}
let itemnum = this.getBagItemNum(itemid);
if (itemnum == 0) {
this.send_notice(`缺少重铸材料`);
return;
}
equip.recast = null;
let recastData = EquipMgr.shared.getRecastData({
type: equip.EquipType,
grade: equip.Grade,
role: this,
ower: equip.OwnerRoleId,
pos: equip.EIndex,
resid: equip.Type
});
equip.recast = recastData;
if (equip.recast) {
this.addBagItem(itemid, -1, false);
this.send('s2c_equip_property', {
property: equip.recast.BaseAttr,
score: GameUtil.calculate(JSON.parse(equip.recast.BaseAttr), equip.Race, equip.Sex, true)
});
}
}
}
// 装备分解
equipResolve(data: any) {
let equip = this.equipObjs[data.equipid];
if (equip == null) {
this.send('s2c_notice', {
strRichText: `分解的装备不存在!`
});
return;
}
if (equip.EIndex == 6) {
this.addItem(10411, 10, false, `${equip.name}分解`);
this.delEquip(equip.EquipID, true, "翅膀分解");
this.sendEquipList();
let info = `消耗翅膀[color=${ItemUtil.getBaldricColor(equip.Grade)}][${equip.name}][/color]X1得到10个[img]ui://main_ui/10411[/img]翅膀精华`;
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
//cxf仙器分解
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.EQUIP,
operateDepict: "翅膀分解",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
}
this.send('s2c_notice', {
strRichText: info
});
return;
}
if (equip.EquipType != 3 && equip.Grade < 2) {
this.send('s2c_notice', {
strRichText: `只有二阶及以上的仙器才能分解!`
});
return;
}
let count = ItemUtil.getEquipResolve(equip.Grade);
if (count < 1) {
this.send('s2c_notice', {
strRichText: `仙器[color=${ItemUtil.getBaldricColor(equip.Grade)}][${equip.name}][/color]无法分解!`
});
}
this.addItem(10406, count, false, `${equip.name}分解`);
this.delEquip(equip.EquipID, true, "仙器分解");
this.sendEquipList();
let info = `消耗仙器[color=${ItemUtil.getBaldricColor(equip.Grade)}][${equip.name}][/color]X1得到${count}个[img]ui://main_ui/10406[/img]八荒遗风`;
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
//cxf仙器分解
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.EQUIP,
operateDepict: "仙器分解",
operateResSerial: equip.EquipID,
operateResName: equip.name,
operateContent: SKDataUtil.toJson(equip.cxfEquip(this.roleid), "{}")
})
}
this.send('s2c_notice', {
strRichText: info
});
}
buyEquip(info: any) {
}
sellEquip(info: any) {
}
////////////////////////////// 装备 结束 /////////////////////////////
getPartnerOnBattle(): any {
let battlelist: any = [];
if (this.partnerMgr == null) {
return battlelist;
}
for (var it in this.partnerMgr.vecChuZhan) {
let nPartnerID = this.partnerMgr.vecChuZhan[it];
if (0 == nPartnerID)
continue;
let pPartner = this.partnerMgr.mapPartner[nPartnerID];
if (null == pPartner)
continue;
battlelist.push(pPartner);
}
return battlelist;
}
// 获得战斗召唤兽
getBattlePet(pos: any): any {
let pets = [];
let btlpet = null;
for (let petid in this.petList) {
let pet: Pet = this.petList[petid];
let battlePet = new BattleRole();
battlePet.setObj(pet);
battlePet.bindid = this.onlyid;
if (this.curPet && pet.onlyid == this.curPet.onlyid) {
battlePet.pos = pos;
btlpet = battlePet;
} else {
battlePet.pos = 0;
}
pets.push(battlePet);
}
let result = {
pets: pets,
btlpet: btlpet
}
return result;
}
/**
* 获取自己的战斗队伍
* @param {number} type 是否有伙伴上场 0 上场 1 不上场
*/
getBattleTeam(type = BattleType.Normal) {
let btlteam: any = [];
let teamid = this.teamid;
if (teamid != 0) {
let team_players = TeamMgr.shared.getTeamPlayer(teamid);
let count = 0;
for (let i = 0; i < team_players.length; i++) {
let player = team_players[i];
if (player.pause == 1) {
count++;
continue;
}
let brole = new BattleRole();
brole.pos = i + 1;
brole.setObj(player);
let pPets = player.getBattlePet(i + 6);
if (pPets.btlpet) {
brole.bindid = pPets.btlpet.onlyid;
}
btlteam.push(brole);
btlteam = btlteam.concat(pPets.pets);
}
if (type == BattleType.Normal || type == BattleType.PK) {
let partnerlist = TeamMgr.shared.getTeamLeaderPartner(teamid);
let index = 1;
for (const partner of partnerlist) {
let bpartner = new BattleRole();
bpartner.pos = (team_players.length - count) + index;
bpartner.setObj(partner);
btlteam.push(bpartner);
index++;
}
}
} else {
let brole = new BattleRole();
brole.pos = 1;
brole.setObj(this);
let petData = this.getBattlePet(6);
if (petData.btlpet) {
brole.bindid = petData.btlpet.onlyid;
}
btlteam.push(brole);
btlteam = btlteam.concat(petData.pets);
if (type == BattleType.Normal || type == BattleType.PK || type == BattleType.AREAN) {
let partnerlist = this.getPartnerOnBattle();
let index = 1;
for (const partner of partnerlist) {
let bpartner = new BattleRole();
bpartner.pos = 1 + index;
bpartner.setObj(partner);
btlteam.push(bpartner);
index++;
}
}
}
return btlteam;
}
forcedBattle(p1: any, battle: any) {
if (this.teamid != 0) {
let plist = TeamMgr.shared.getTeamPlayer(this.teamid);
for (const pPlayer of plist) {
if (pPlayer.pause == 1) {
continue;
}
pPlayer.send('s2c_btl', {
btlid: battle.battle_id,
teamS: battle.getTeamData(2),
teamE: battle.getTeamData(),
});
pPlayer.battle_id = battle.battle_id;
}
} else {
this.send('s2c_btl', {
btlid: battle.battle_id,
teamS: battle.getTeamData(2),
teamE: battle.getTeamData(),
});
this.battle_id = battle.battle_id;
}
}
// type 0 正常 1 pk 2 切磋
playerBattle(onlyid: any, type = BattleType.Normal) {
if (this.battle_id != 0 || this.onlyid == onlyid) {
return null;
}
let p2 = PlayerMgr.shared.getPlayerByOnlyId(onlyid);
if (p2 == null || p2.battle_id != 0) {
return null;
}
if (this.teamid != 0 && this.isleader == false) {
return null;
}
if (p2.teamid != 0 && this.teamid == p2.teamid) {
return null;
}
if (type == BattleType.Force) {
if (this.level < GameUtil.PKLevelLimit || p2.level < GameUtil.PKLevelLimit) {
this.send('s2c_notice', {
strRichText: '强制pk等级不足' + GameUtil.PKLevelLimit + '级!'
});
return null;
}
let mapsi = GameUtil.cantPKMaps.indexOf(this.mapid);
let mapti = GameUtil.cantPKMaps.indexOf(p2.mapid);
if (mapsi != -1 || mapti != -1) {
this.send('s2c_notice', {
strRichText: '此处为安全区域,无法强制PK'
});
return null;
}
if (!this.bag_list[10003] || this.bag_list[10003] < 1) {
this.send('s2c_notice', {
strRichText: '夺命香数量不足!'
});
return null;
}
this.bag_list[10003] -= 1;
if (this.bag_list[10003] <= 0) {
delete this.bag_list[10003];
}
this.send('s2c_bagitem', {
info: SKDataUtil.toJson(this.bag_list, "{}")
});
console.log(`玩家[${this.name}${this.roleid}]消耗 夺命香 1 个`);
}
let t1 = this.getBattleTeam(type);
let t2 = p2.getBattleTeam(type);
let battle = BattleMgr.shared.createBattle();
battle.setBattleType(type);
battle.setTeamBRole(t1, t2);
battle.source = this.onlyid;
let senddata = {
btlid: battle.battle_id,
teamS: battle.getTeamData(),
teamE: battle.getTeamData(2),
};
if (this.teamid != 0) {
let plist = TeamMgr.shared.getTeamPlayer(this.teamid);
for (const pPlayer of plist) {
if (pPlayer.pause == 1) {
continue;
}
pPlayer.battle_id = battle.battle_id;
pPlayer.send('s2c_btl', senddata);
pPlayer.synInfoToWatcher();
}
} else {
this.battle_id = battle.battle_id;
this.send('s2c_btl', senddata);
this.synInfoToWatcher();
}
if (type != BattleType.AREAN) {
p2.forcedBattle(this.onlyid, battle);
}
if (type == BattleType.Force) {
//显示强制PK的 通知title
this.send('s2c_pktitle', {
info: '正在强制PK对方,您失败将扣除经验【2亿】,每次胜利将获赠一次监牢30分钟旅游的机会!'
});
p2.send('s2c_pktitle', {
info: '正在被对方强制PK,您失败将扣除经验【2亿】,战胜对方是不会进监牢的,加油干掉对面吧!'
});
}
setTimeout(() => {
battle.begin();
}, 1 * 1000);
return battle;
}
monsterBattle(mongroupid?: any, taskGrop?: number, battletype = BattleType.Normal, yewai = false) {
if (this.battle_id != 0)
return null;
if (mongroupid == null || isNaN(mongroupid)) {
mongroupid = 10048;
}
let mongroup = MonsterMgr.shared.getGroupData(mongroupid);
if (mongroup == null) {
return null;
}
let monsterlist = MonsterMgr.shared.getMonGroup(mongroupid);
if (monsterlist == null) {
return null;
}
if (this.teamid != 0 && this.isleader == false) {
return null;
}
if (this.mapid == 1003) { //北俱芦洲 没有宝宝
yewai = false;
}
let t1 = this.getBattleTeam(mongroup.partner);
let maxlevel = 0;
for (let key in t1) {
let player = t1[key];
if (!player.isPet()) {
if (player.level > maxlevel) {
maxlevel = player.level
}
}
}
let t2 = [];
for (let i = 0; i < monsterlist.length; i++) {
const monster = monsterlist[i];
let brole = new BattleRole();
brole.pos = parseInt(monster.pos);
brole.setObj(monster);
let lev = maxlevel - brole.level;
if (lev > 0) {
// brole.setAttr(EAttrTypeL1.HP, 1);
// brole.setAttr(EAttrTypeL1.HP_MAX, 1);
// brole.setAttr(EAttrTypeL1.ATK, 1);
// brole.setAttr(EAttrTypeL1.SPD, 1);
brole.setAttr(EAttrTypeL1.HP, brole.roleattr[EAttrTypeL1.HP] + Math.floor(brole.roleattr[EAttrTypeL1.HP] * (lev / 100)));
brole.setAttr(EAttrTypeL1.HP_MAX, brole.roleattr[EAttrTypeL1.HP_MAX] + Math.floor(brole.roleattr[EAttrTypeL1.HP_MAX] * (lev / 100)));
brole.setAttr(EAttrTypeL1.ATK, brole.roleattr[EAttrTypeL1.ATK] + Math.floor(brole.roleattr[EAttrTypeL1.ATK] * (lev / 100)));
brole.setAttr(EAttrTypeL1.SPD, brole.roleattr[EAttrTypeL1.SPD] + Math.floor(brole.roleattr[EAttrTypeL1.SPD] * (lev / 100)));
}
t2.push(brole);
}
if (yewai && t2.length < 10) {
let r = GameUtil.random(1, 10000);
if (r < 10000) {
let list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for (const key in t2) {
const brole = t2[key];
let t = list.indexOf(brole.pos);
list.splice(t, 1);
}
if (list.length > 0) {
let bb = MonsterMgr.shared.getRandomBB();
let brole = new BattleRole();
brole.is_bb = true;
brole.pos = list[GameUtil.random(0, list.length - 1)];
brole.setObj(bb);
t2.push(brole);
}
}
}
let battle = BattleMgr.shared.createBattle();
battle.setBattleType(battletype);
battle.setTeamBRole(t1, t2);
battle.monster_group_id = mongroupid;
battle.taskGroup = taskGrop;
let senddata = {
btlid: battle.battle_id,
teamS: battle.getTeamData(),
teamE: battle.getTeamData(2),
};
if (this.teamid != 0) {
let plist = TeamMgr.shared.getTeamPlayer(this.teamid);
for (const pPlayer of plist) {
if (pPlayer.pause == 1) {
continue;
}
pPlayer.battle_id = battle.battle_id;
pPlayer.send('s2c_btl', senddata);
pPlayer.synInfoToWatcher();
}
} else {
this.battle_id = battle.battle_id;
this.send('s2c_btl', senddata);
this.synInfoToWatcher();
}
setTimeout(() => {
battle.begin();
}, 1 * 1000);
return battle;
}
// 战斗结束
exitBattle(iswin: any) {
let battle = BattleMgr.shared.getBattle(this.battle_id);
if (battle == null) {
this.battle_id = 0;
return;
}
if (battle.battle_type == BattleType.AREAN && iswin == 1) {
this.send('s2c_btl_end', {
btlid: this.battle_id,
result: iswin,
});
} else {
this.send('s2c_btl_end', {
btlid: this.battle_id,
result: iswin,
});
}
// 奖励相关
let mgdata = MonsterMgr.shared.getGroupData(battle.monster_group_id);
if (iswin == 1 && mgdata && battle.battle_type != BattleType.AREAN) {
this.addExp(mgdata.exp);
this.addMoney(0, mgdata.gold, '战斗奖励', MsgCode.SUCCESS);
if (this.curPet) {
this.curPet.addExp(mgdata.exp);
}
let itemlist = MonsterMgr.shared.makeGroupDrop(battle.monster_group_id);
for (const iteminfo of itemlist) {
this.addItem(iteminfo.itemid, iteminfo.itemnum, true, '战斗奖励');
}
}
// 任务相关
if (iswin == 1) {
if (battle.battle_type == BattleType.Force && battle.source == this.onlyid) {
if (this.teamid > 0) {
let team_players = TeamMgr.shared.getTeamPlayer(this.teamid);
// TeamMgr.shared.destroyTeam(this.teamid);
for (let i = 0; i < team_players.length; i++) {
const pPlayer = team_players[i];
pPlayer.shane += 1440 * 5;
pPlayer.ShanEChange();
pPlayer.send('s2c_aoi_pinfo', {
list: [this.toObj()]
});
}
} else {
this.shane += 1440 * 5;
this.ShanEChange();
this.send('s2c_aoi_pinfo', {
list: [this.toObj()]
});
this.send('s2c_notice', {
strRichText: '恭喜您获得30分钟监牢旅游一次的机会,进入长安才会触发!'
});
}
// 杀人记录
this.syncMurder(battle);
}
if (battle.battle_type == BattleType.Normal) {
let pNpc = NpcMgr.shared.findNpc(battle.source);
if (pNpc) {
this.OnKillNpc(pNpc.configid, pNpc.onlyid, battle);
}
}
/* 胜利宠物加10点亲密值 */
if (this.teamid > 0) {
let team_players = TeamMgr.shared.getTeamPlayer(this.teamid);
for (let player of team_players) {
if (player && player.curPet) {
player.curPet.addqinmi(10);
}
}
} else {
if (this.curPet) {
this.curPet.addqinmi(10);
}
}
} else {
// 战斗失败了
if (battle.battle_type == BattleType.Force && this.roleid) {
if (this.teamid > 0) {
let team_players = TeamMgr.shared.getTeamPlayer(this.teamid);
for (let i = 0; i < team_players.length; i++) {
const pPlayer = team_players[i];
pPlayer.addExp(-200000000);
console.log(`队伍玩家[${pPlayer.name}${pPlayer.roleid}]被强制pk 扣除经验 2亿`);
}
} else {
let pPlayer = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
pPlayer.addExp(-200000000);
pPlayer.send('s2c_notice', {
strRichText: '角色经验被扣除2亿'
});
}
}
this.getTaskMgr().OnFailEvent(EEventType.PLAYER_DEAD, 0);
let pNpc = NpcMgr.shared.findNpc(battle.source);
if (pNpc) {
// 天地星
World.shared.starMgr.ChallengeFail(pNpc.onlyid, battle);
// 证道恶鬼
World.shared.magicWorldMgr.ChallengeFail(pNpc.onlyid, battle);
// 海盗
World.shared.pirateMgr.ChallengeFail(pNpc.onlyid);
}
}
// 水路大会
if (battle.battle_type == BattleType.ShuiLu) {
let activity = ActivityMgr.shared.getActivity(ActivityDefine.activityKindID.ShuiLuDaHui);
if (activity) {
let matchteam = activity.getMatchTeamInfo(this.teamid);
if (matchteam) {
activity.battleEnd(this.teamid, iswin);
}
}
}
// 皇城pk
else if (battle.battle_type == BattleType.PALACE) {
if (iswin && ((this.teamid != 0 && this.isleader) || this.teamid == 0)) {
PalaceFight.shared.pkWin(this.roleid);
}
}
// 竞技场
else if (battle.battle_type == BattleType.AREAN) {
let tcamp = battle.plist;
let brole = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
for (let i in tcamp) {
let trole = tcamp[i];
if (trole.onlyid != brole.onlyid) {
if (trole.living_type == 1) {
JingJiChang.shared.JingJiInfo(this.roleid, trole.onlyid, iswin);
JingJiChang.shared.battleEnd(this.roleid, iswin, trole.onlyid);
break;
}
}
}
}
// 证道大会
else if (battle.battle_type == BattleType.Sat) {
if (SatAssembly.shared.activity_state != ActivityDefine.activityState.Close) {
let match_team = SatAssembly.shared.getMatchTeamInfo(this.teamid);
if (match_team) {
SatAssembly.shared.battleEnd(this.teamid, iswin);
}
}
}
// 帮战比武
else if (battle.battle_type == BattleType.FactionWarContest) {
if (FactionWar.shared.activity_state != ActivityDefine.activityState.Close) {
FactionWar.shared.contestResult(this, iswin);
}
}
// 帮战战斗
else if (battle.battle_type == BattleType.FactionWarFight) {
if (FactionWar.shared.activity_state != ActivityDefine.activityState.Close) {
FactionWar.shared.fightResult(this, iswin, battle);
}
}
this.battle_id = 0;
this.synInfoToWatcher();
}
// 杀人记录
syncMurder(battle: any) {
// 死亡玩家编号数组
let list: any = [];
for (let role of battle.campB.broles) {
// 如果是玩家 并且死亡
if (role.living_type == 1) {
if (role.source != null && role.source != undefined) {
let data: any = {
defier_role_id: this.roleid,
by_defier_role_id: role.source.roleid,
server_id: GameUtil.serverId
};
PaiHangMgr.shared.updateMurderRankData(this.roleid, this.name, this.race, this.level, this.relive)
list.push(data);
}
}
}
// 通过CXF 同步到数据库
console.log(`胜利玩家:${this.name}死亡玩家:${SKDataUtil.toJson(list, "[]")}`)
SKCxfUtil.getCxfMurder(list);
}
ShanEChange() {
let change = false;
// 如果玩家牢狱时间小于=0 并且玩家在牢房,将其释放
if (this.mapid == 1201 && this.shane <= 0) {
this.leavePrison();
this.send('s2c_prison_time', {
onlyid: this.onlyid,
time: 0
});
change = true;
}
// 如果玩家牢狱时间大于=0 并且玩家不在牢房,将其传送进牢房
if (this.mapid == 1011 && this.shane > 0) {
this.enterPrison();
change = true;
}
if (this.shane != 0) {
this.send('s2c_prison_time', {
onlyid: this.onlyid,
time: this.inPrison ? Math.ceil(this.shane / 4) : -1
});
}
// 更新监牢犯人数据
PaiHangMgr.shared.updateDaysPrisonerData(this.roleid, this.name, this.race, this.level, this.relive, this.shane);
return change;
}
getWorldStar() {
return this.star;
}
OnKillNpc(nConfigID: any, nOnlyID: any, battle: any = null) {
let pNpc = NpcMgr.shared.findNpc(nOnlyID);
if (null == pNpc)
return;
let pConfig = NpcConfigMgr.shared.getConfig(nConfigID);
if (null == pConfig)
return;
this.getTaskMgr().onGameEvent(EEventType.PLAYER_KILL_NPC, nOnlyID);
if (pNpc.stCreater.nKind != ENpcCreater.SYSTEM) {
NpcMgr.shared.CheckAndDeleteNpc(nOnlyID, this);
}
if (World.shared.starMgr.IsStar(nOnlyID)) {
this.star++;
}
// 天地星
World.shared.OnKillNpc(this.accountid, nOnlyID, battle);
// 天元盛典
DWorld.shared.OnKillNpc(this.accountid, nOnlyID);
}
// 加入到装备列表
addEquipList(value: Equip) {
this.listEquips.push(value);
}
// 加入到法宝列表
addMagicWeaponList(value: MagicWeapon) {
this.listMagicWeapons.push(value);
}
playerRelive(data: any) {
let nextlive = this.relive + 1;
let relivedata = GameUtil.reliveLimit[nextlive];
if (relivedata == null) {
this.send('s2c_relive', {
result: MsgCode.FAILED,
info: this.toObj(),
data: this.getData()
});
return;
}
if (this.level < relivedata.level) {
return;
}
//处理装备
for (const equip of this.currentEquips) {
this.addEquipList(equip);
}
this.currentEquips = [];
this.sendEquipList();
this.schemeMgr.reset();
this.changeWeapon(null);
//清理加点
for (const key in this.addattr2) {
this.addattr2[key] = 0;
}
this.relivelist[this.relive] = [this.race, this.sex];
this.relive = nextlive;
this.resid = data.resid;
this.race = SKDataUtil.clamp(data.race, ERaceType.HUMEN, ERaceType.DRAGON);
this.sex = data.sex;
this.setLevel(relivedata.tolevel);
this.resetSkill();
this.addExp(0);
this.calculateAttr();
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player.bangid > 0) {
let bang = BangMgr.shared.getBang(player.bangid)
if (bang) {
for (const roleInfo of bang.rolelist) {
if (player.roleid == roleInfo.roleid) {
roleInfo.resid = player.resid;
roleInfo.race = player.race;
roleInfo.relive = player.relive;
roleInfo.level = player.level;
roleInfo.sex = player.sex;
}
}
}
}
this.send('s2c_relive', {
result: MsgCode.SUCCESS,
info: this.toObj(),
data: this.getData()
});
// 更新红名榜数据
PaiHangMgr.shared.updateMurderRankDataInfo(this.roleid, this.name, this.race, this.level, this.relive);
//cxf玩家转生
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.EXP,
operateDepict: "玩家转生",
operateResSerial: "",
operateResName: "",
operateContent: `${this.name}]转生后:[${this.relive}转,${this.level}级]`
})
}
playerFlyUp(data: any) {
if (this.relive != 3) {
this.send('s2c_notice', {
strRichText: `你才{${this.relive}}转,需要3转180级后才可以飞升`
});
return;
}
let nextlive = this.relive + 1;
let relivedata = GameUtil.reliveLimit[nextlive];
if (relivedata == null) {
this.send('s2c_notice', {
strRichText: `没有开放飞升配置,请稍候重试!`
});
return;
}
if (this.level < relivedata.level) {
this.send('s2c_notice', {
strRichText: `需要达到等级:${relivedata.level}才可以飞升!`
});
return;
}
//处理装备
for (const equip of this.currentEquips) {
this.addEquipList(equip);
}
this.currentEquips = [];
this.sendEquipList();
this.changeWeapon(null);
//清理加点
for (const key in this.addattr2) {
this.addattr2[key] = 0;
}
this.relivelist[this.relive] = [this.race, this.sex];
this.relive = nextlive;
this.setLevel(relivedata.tolevel);
this.resetSkill();
this.addExp(0);
this.calculateAttr();
this.send('s2c_relive', {
result: MsgCode.SUCCESS,
info: this.toObj(),
data: this.getData()
});
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
}
// 玩家改变种族
playerChangeRace(data: any) {
if (this.jade < 300) {
this.send('s2c_notice', {
strRichText: '仙玉不足'
});
return;
}
this.addMoney(1, -300, `玩家[${this.roleid}:${this.name}]改变种族`, MsgCode.SUCCESS);
for (let equip of this.currentEquips) {
this.addEquipList(equip);
equip.pos = EEquipPos.BAG
}
this.currentEquips = [];
this.sendEquipList();
this.changeWeapon(null);
this.resid = data.resid;
this.race = RoleUtil.checkRace(data.race, data.resid);
this.sex = RoleUtil.checkSex(data.sex, data.resid);
//重置加点
this.addattr2[EAttrTypeL2.GENGU] = 0;
this.addattr2[EAttrTypeL2.LINGXING] = 0;
this.addattr2[EAttrTypeL2.MINJIE] = 0;
this.addattr2[EAttrTypeL2.LILIANG] = 0;
this.addXiulianPoint({ type: 0 })
this.setRoleColor(this.color_one_serial, this.color_two_serial);
this.resetSkill();
this.addExp(0);
this.calculateAttr();
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
this.horseList.changeRace(this.race);
let params = {
result: MsgCode.SUCCESS,
info: this.toObj(),
data: this.getData()
};
this.send("s2c_changerace", params);
this.syncChangeRace();
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player.bangid > 0) {
let bang = BangMgr.shared.getBang(player.bangid)
if (bang) {
for (const roleInfo of bang.rolelist) {
if (player.roleid == roleInfo.roleid) {
roleInfo.resid = player.resid;
roleInfo.race = player.race;
roleInfo.sex = player.sex;
}
}
}
}
}
// 同步种族改变
syncChangeRace() {
let playerList = this.getWatcherPlayer();
if (playerList) {
for (let key in playerList) {
let player = playerList[key];
if (player.isPlayer()) {
player.send('s2c_sync_race', {
info: this.toObj(),
data: this.getData()
});
}
}
}
}
/**
* 修改角色名称
* @param data
*/
playerChangeName(data: any) {
if (this.jade < 600) {
this.send('s2c_notice', {
strRichText: '仙玉不足'
});
return;
}
if (!GameUtil.checkLimitWord(data.name)) {
this.send_notice("再想一个独一无二的名字吧,仙玉未扣除!");
return;
}
let rag = /[\u4e00-\u9fa5a-zA-Z]{3,5}$/;
if (rag.test(data.name) == false) {
this.send_notice("名字不符合规则(3~5个中文字符)");
return;
}
let callback = (ret: any) => {
if (ret == MsgCode.SUCCESS) {
this.addMoney(1, -600, '玩家改变名字', MsgCode.SUCCESS);
this.send_notice("改名成功,西游欢迎您重新归来!");
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PLAYER,
operateDepict: "玩家改名",
operateResSerial: this.roleid,
operateResName: player.name,
operateContent: ""
})
}
this.name = data.name;
if (this.bangid > 0) {
let bang = BangMgr.shared.getBang(this.bangid)
if (bang) {
if (bang.masterid == this.roleid) {
bang.mastername = this.name;
}
for (const roleInfo of bang.rolelist) {
if (this.roleid == roleInfo.roleid) {
roleInfo.name = this.name;
break;
}
}
}
}
// 更新红名榜数据
PaiHangMgr.shared.updateMurderRankDataInfo(this.roleid, this.name, this.race, this.level, this.relive);
this.send('s2c_aoi_pinfo', {
list: [this.toObj()]
});
this.synInfoToWatcher();
} else {
this.send_notice("再想一个独一无二的名字吧,仙玉未扣除!");
}
callback = null;
}
DB.changeName(data, callback);
}
/**
* 修改宠物名字
* @param data
*/
playerChangePetName(data: any) {
if (this.jade < 600) {
this.send_notice("仙玉不足");
return;
}
if (!GameUtil.checkLimitWord(data.name)) {
this.send_notice("再想一个独一无二的名字吧,仙玉未扣除!");
return;
}
let rag = /^[\u4e00-\u9fa5]{3,5}$/;
if (rag.test(data.name) == false) {
this.send_notice("名字不符合规则(3~5个中文字符)");
return;
}
let callback = (ret: any) => {
if (ret == MsgCode.SUCCESS) {
this.addMoney(1, -600, '宠物改变名字', MsgCode.SUCCESS);
this.send_notice("改名成功!");
let operationPet = null;
for (const pet of this.petList) {
if (pet.petid == data.petId) {
operationPet = pet;
break;
}
}
operationPet.playerChangePetName(data.name);
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物改名",
operateResSerial: operationPet.petid,
operateResName: operationPet.name,
operateContent: ""
})
}
} else {
this.send_notice("修改失败!");
}
callback = null;
}
// 如果在队伍刷新宠物名称
this.refresh_team_data();
DB.changePetName(data, callback);
}
resetPoint() {
//重置加点
this.resetRolePoint();
this.sendEquipList();
this.calculateAttr();
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
this.currentEquips = [];
//this.send('s2c_player_data', this.getData());
this.send('s2c_notice', {
strRichText: '角色加点重置成功!'
});
}
sendReliveList() {
this.send('s2c_relive_list', {
strJson: SKDataUtil.toJson(this.relivelist, "[]")
});
}
changeReliveList(data: any) {
if (this.getBagItemNum(10201) <= 0) {
this.send('s2c_notice', {
strRichText: '回梦丹不足'
});
return;
}
this.addItem(10201, -1, false, '转生修正消耗');
let vecLiveInfo = SKDataUtil.jsonBy(data.strJson);
if (vecLiveInfo.length != 4)
return;
this.relivelist = [];
for (var nLive in vecLiveInfo) {
let stLive = vecLiveInfo[nLive];
let vecInfo = [GameUtil.getDefault(stLive.nRace, 0), GameUtil.getDefault(stLive.nSex, 0)];
this.relivelist.push(vecInfo);
}
this.calculateAttr();
this.send('s2c_player_data', this.getData());
//检查变身卡效果
ChangeCard.shared.checkCard(this.roleid);
this.send('s2c_notice', {
strRichText: '修改成功'
});
}
getWatcherPlayer() {
let pMap = MapMgr.shared.getMap(this);
if (pMap == null) return;
return pMap.getWatcher(this.onlyid);
}
synPosToWatcher() {
let mPlayers = this.getWatcherPlayer();
if (mPlayers) {
mPlayers[this.onlyid] = this;
for (const key in mPlayers) {
let p = mPlayers[key];
if (p.isPlayer())
p.send('s2c_player_pos', {
onlyid: this.onlyid,
x: this.x,
y: this.y
});
}
}
}
addShuiluScore(jifen: any, gongji: any, iswin: any) {
this.shuilu.gongji += parseInt(gongji);
this.shuilu.score += parseInt(jifen);
if (iswin == 1) {
this.shuilu.wtime++;
} else {
this.shuilu.ltime++;
}
}
addJingjiScore(jpoint: any, jtime: any) {
this.arena.jpoint += parseInt(jpoint);
this.arena.jtime += parseInt(jtime);
}
synInfoToWatcher() {
let mPlayers = this.getWatcherPlayer();
if (mPlayers) {
for (const key in mPlayers) {
let p = mPlayers[key];
if (p.isPlayer())
p.send('s2c_aoi_pinfo', {
list: [this.toObj()]
});
}
}
}
/*
* 充值奖励
*/
chargeReward(data: any) {
let rewardid = data.rewardid;
let choose_item = null;
let num = 1 << (rewardid - 1);
if ((num & this.rewardrecord) != 0) {
this.send_notice("你已领过该阶段的奖励了");
return;
}
let list = ChargeConfig.shared.reward_list;
for (let item of list) {
if (item.id == rewardid) {
choose_item = item;
break;
}
}
let chargesum = ChargeSum.shared.getPlayerChargeSum(this.roleid);
if (!choose_item || chargesum < choose_item.money) {
this.send_notice("你的充值积分不够");
this.send("s2c_charge_reward", { flag: MsgCode.FAILED });
return;
}
this.send("s2c_charge_reward", { flag: MsgCode.SUCCESS });
for (let item of choose_item.reward) {
this.addItem(item.gid, item.count, true, '充值奖励');
}
this.rewardrecord |= num;
this.send('s2c_player_data', this.getData());
}
/*
* 充值奖励
*/
spChargeReward(data: any) {
let rewardid = data.rewardid;
let choose_item = null;
let num = 1 << (rewardid - 1);
if ((num & this.sprewardrecord) != 0) {
this.send_notice("你已领过该阶段的奖励了");
return;
}
let list = ChargeConfig.shared.spreward_list;
for (let item of list) {
if (item.id == rewardid) {
choose_item = item;
break;
}
}
let chargesum = ChargeSum.shared.getPlayerChargeSum(this.roleid);
if (!choose_item || chargesum < choose_item.money) {
this.send_notice("你的充值积分不够");
this.send("s2c_charge_reward", { flag: MsgCode.FAILED });
return;
}
this.send("s2c_charge_reward", { flag: MsgCode.SUCCESS });
for (let item of choose_item.reward) {
this.addItem(item.gid, item.count, true, '充值奖励');
}
this.sprewardrecord |= num;
this.send('s2c_player_data', this.getData());
}
// 领取首充奖励
reGetGift() {
if (this.getgift == 0) {
return MsgCode.GIFT_HAS_GOT;
}
let conf = GameUtil.game_conf.firstCharge;
if (conf) {
let message = ``;
for (let item of conf) {
message += `物品:${item.name},数量:${item.count}`;
this.addItem(item.prop, item.count, false, "首充奖励")
}
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "首充奖励",
operateResSerial: "",
operateResName: "",
operateContent: message
})
}
this.getgift = 0;
return MsgCode.SUCCESS;
}
getBang() {
if (this.bangid == 0) {
return null;
}
return BangMgr.shared.getBang(this.bangid);
}
// 称谓相关
addTitle(type: any, titleId: any, value = '', onload = false) {
let titlesList = this.getTitleItemByTitleId(type, titleId, value)
if (titlesList.length <= 0) {
//添加称谓
let title = { "type": type, "titleid": titleId, "value": value, "onload": onload }
this.titles.push(title);
}
}
delTitle(type: any, titleId: any, value = '') {
let delIndex = -1;
let delItem = this.titles.find((e: any, index: any): boolean => {
if (e.type == type && e.titleid == titleId && e.value == value) {
delIndex = index;
return true;
}
return false;
});
if (delIndex >= 0 && delItem) {
if (delItem.onload) {
this.titleId = -1;
this.titleType = -1;
this.titleVal = '';
}
this.titles.splice(delIndex, 1);
}
}
getTitles() {
this.send('s2c_title_info', {
titles: SKDataUtil.toJson(this.titles, "{}"),
});
}
//通过titleID获取title信息
getTitleItemByTitleId(type: any, titleId: any, value: any): any {
return this.titles.filter((e: any) => {
if (e.type == type && e.titleid == titleId && e.value == value) {
return true;
}
return false;
});
}
changeTitle(data: any) {
if (data.operatetype == 1) {
let res = this.titles.some((e: any) => {
e.onload = false;
return true;
});
if (res) {
this.titleId = -1;
this.titleType = -1;
this.titleVal = '';
this.onLoad = false;
this.send('s2c_title_change', {
ecode: MsgCode.SUCCESS,
titleid: 0,
type: -1,
value: '',
operatetype: data.operatetype
});
}
return;
} else {
this.titles.forEach((e: any) => {
if (e.type == data.type && e.titleid == data.titleid) {
if ((data.type == GameUtil.titleType.BroTitle || data.type == GameUtil.titleType.CoupleTitle) && e.value == data.value) {
e.onload = !e.onload;
this.onLoad = true;
this.titleVal = e.value;
} else {
this.onLoad = false;
e.onload = !e.onload;
this.titleVal = '';
}
this.titleId = e.titleid;
this.titleType = e.type;
}
});
this.send('s2c_title_change', {
ecode: MsgCode.SUCCESS,
title: this.titles,
titleid: this.titleId,
type: this.titleType,
value: this.titleVal,
operatetype: data.operatetype
});
}
}
/*
* 是否能进行皇城pk
*/
canPalaceFight() {
return (this.mapid == 1206 && this.battle_id == 0);
}
getIsOnline() {
return !this.offline;
}
//变身
shapeshift(data: any) {
}
setRoleColor(index1: any, index2: any) {
let rolecolor = GameUtil.require_ex('../../conf/prop_data/prop_rolecolor.json');
if (!rolecolor[this.resid]) {
SKLogger.debug(`prop_rolecolor 未找到${this.resid}`);
return;
}
let data1, data2;
let canset = true;
if (index1 != 0) {
data1 = rolecolor[this.resid]['color1_' + index1];
if (data1 && parseInt(data1.color, 16) != this.color1) {
if (!this.bag_list[data1.itemid] || this.bag_list[data1.itemid] < data1.count) {
canset = false;
}
}
}
if (index2 != 0) {
data2 = rolecolor[this.resid]['color2_' + index2];
if (data2 && parseInt(data2.color, 16) != this.color2) {
if (!this.bag_list[data2.itemid] || this.bag_list[data2.itemid] < data2.count) {
canset = false;
}
}
}
if (canset) {
if (data1) {
this.update_bagitem({
itemid: data1.itemid,
count: data1.count,
operation: 0,
});
this.color1 = parseInt(data1.color, 16);
}
else {
this.color1 = 0;
}
if (data2) {
this.update_bagitem({
itemid: data2.itemid,
count: data2.count,
operation: 0,
});
this.color2 = parseInt(data2.color, 16);
}
else {
this.color2 = 0;
}
SKLogger.debug(`玩家${this.roleid}成功的进行了染色color1:${this.color1},color2:${this.color2}`);
this.send('s2c_change_role_color', { color1: this.color1, color2: this.color2, });
this.send('s2c_notice', { strRichText: '玩家染色成功' });
// 更新染色部位
this.color_one_serial = index1;
this.color_two_serial = index2;
}
}
clone() {
let p: any = new Player();
for (const key in this) {
if (this.hasOwnProperty(key)) {
const info = this[key];
p[key] = info;
}
}
p.accountid = -1;
p.roleid = -1;
return p;
}
/*
* 消耗铃铛进行世界广播
*/
costBell(str: any) {
let bell_count = this.getBagItemNum(10205);
if (bell_count <= 0) {
return;
}
this.update_bagitem({
operation: 0,
count: 1,
itemid: 10205,
});
PlayerMgr.shared.broadcast('s2c_bell_msg', {
msg: str,
name: this.name,
roleid: this.roleid,
});
}
/*
* 设置玩家安全锁密码
*/
setSafePassword(pass: any, lock: any) {
this.safe_password = pass;
this.safe_lock = lock;
let safecode = this.safe_lock + ':' + this.safe_password;
DB.setSafecode(this.accountid, safecode, (ret: any) => {
if (ret == MsgCode.SUCCESS) {
this.send('s2c_safepass_msg', {
pass: this.safe_password,
lock: this.safe_lock,
});
}
else {
this.safe_password = '';
this.safe_lock = 0;
}
});
}
// 骑乘
ride(horseIndex: number) {
if (this.horseList.horseIndex == horseIndex) {
return;
}
this.horseList.horseIndex = horseIndex;
this.syncRide(horseIndex);
}
syncRide(horseIndex: number) {
let playerList = this.getWatcherPlayer();
if (playerList) {
for (const key in playerList) {
let player = playerList[key];
if (player.isPlayer()) {
player.send("s2c_sync_ride", {
onlyId: this.onlyid,
horseIndex: horseIndex,
});
}
}
}
}
// 下马
get_down() {
if (this.horseList.horseIndex == 0) {
return;
}
this.horseList.horseIndex = 0;
this.syncGetDown();
}
// 同步下马
syncGetDown() {
let mPlayers = this.getWatcherPlayer();
if (mPlayers) {
for (const key in mPlayers) {
let p = mPlayers[key];
if (p.isPlayer()) {
p.send('s2c_sync_get_down', {
onlyId: this.onlyid,
});
}
}
}
}
// 升级坐骑
upgradeHorse(data: any) {
this.horseList.addExp(data.itemId, data.horseIndex);
}
// 召唤兽管制改变
petControl(data: any) {
let petid = data.petid;
let control = SKDataUtil.clamp(data.control, 0, 4);
for (let pet of this.petList) {
if (pet.petid == petid) {
if (pet.control == control) {
return;
}
pet.control = control;
SKLogger.debug(`玩家[${this.roleid}:${this.name}]召唤兽[${pet.name}]管制改变:${control}`);
pet.calculateAttribute();
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: player.name,
operateType: Operate.PET,
operateDepict: "宠物管制",
operateResSerial: pet.petid,
operateResName: pet.name,
operateContent: ""
})
}
this.getPetlist();
return;
}
}
SKLogger.warn(`玩家[${this.roleid}:${this.name}]召唤兽管制找不到:${petid}:${control}`);
}
// 更新召唤兽管制属性
updatePetControl(control: number) {
let hasChange = false;
for (let pet of this.petList) {
if (pet.control == control) {
hasChange = true;
pet.calculateAttribute();
SKLogger.debug(`玩家[${this.name}(${this.roleid})]召唤兽[${pet.name}管制更新属性:${control}`)
}
}
if (hasChange) {
this.getPetlist();
}
}
//召唤兽天策符属性
petOfudaAttr(skill: SkillBase, addition: number, pet: any) {
let level = 0;
let bang = BangMgr.shared.getBang(this.bangid);
if (bang) {
let list = bang.rolelist;
for (let key in list) {
if (this.roleid == list[key].roleid) {
level = list[key].ofudalevel;
break;
}
}
}
if (pet != null) {
return pet.checkOfudaSkill(skill, addition, level);
} else {
return 0;
}
}
getPlayerInfoById() {
let fp = FivePhases.shared.getFivePhasesByRoleid(this.roleid);
let effid = SpecialEffect.shared.getSuiEffect(this.roleid);
let effectid = 0;
let oflevel = 0;
let score = 0;
if (effid > 0) {
effectid = effid;
}
let bang = BangMgr.shared.getBang(this.bangid);
if (bang) {
let list = bang.rolelist;
for (let key in list) {
if (this.roleid == list[key].roleid) {
oflevel = list[key].ofudalevel;
break;
}
}
}
//如果是龙族就去掉逆鳞技能
if (this.race == 5) {
delete this.skill_list[1045]
}
let listInfo = [];
for (let equip of this.currentEquips) {
let full = equip.getFullData();
if (full) {
score += Number(full.BaseScore);
let equip: Equip = this.equipObjs[full.EquipID];
listInfo.push(equip.toObj());
}
}
let petInfo = [];
for (let pet of this.petList) {
petInfo.push(pet.toObj())
}
let obj = {
roleid: this.roleid,
name: this.name,
resid: this.resid,
race: this.race,
sex: this.sex,
relive: this.relive,
level: this.level,
xiulevel: this.xiulevel,
bangname: this.bangname,
score: score,
color1: this.color1,
color2: this.color2,
wingId: this.wingId,
effectlist: SKDataUtil.toJson(SpecialEffect.shared.getUseingEffect(this.roleid), "{}"),
effectid: effectid,
weapon: this.getWeapon(),
oflevel: oflevel,
fplevel: fp == null ? 0 : fp.fplevel,
jin: fp == null ? 0 : fp.jinlevel,
mu: fp == null ? 0 : fp.mulevel,
shui: fp == null ? 0 : fp.shuilevel,
huo: fp == null ? 0 : fp.huolevel,
tu: fp == null ? 0 : fp.tulevel,
skill: SKDataUtil.toJson(this.skill_list, "{}"),
currentEquips: SKDataUtil.toJson(listInfo, "{}"),
petInfo: SKDataUtil.toJson(petInfo, "{}"),
}
return obj;
}
/**
* 分享世界
* 获取道具信息
* type 1装备2道具3宠物4坐骑5称谓
*/
goodsInfo(data: any) {
if (data.type == 1) {
// 装备信息
let callback = (ret: any, item: any) => {
if (ret == MsgCode.SUCCESS) {
item = item[0];
let player = PlayerMgr.shared.getPlayerByRoleId(item.roleid);
let obj: any = {};
// 判断玩家是否在线(查数据库)
if (player.offline) {
let equipdata: any = EquipMgr.shared.getEquipData({ resid: item.Type, type: item.EquipType });
if (equipdata == null) {
SKLogger.warn(`装备[${item.EquipID}:${this.name}]完整信息为空!`);
this.send_notice(`获取信息失败!`);
return;
}
obj.EquipID = item.EquipID;
obj.EquipType = item.EquipType;
obj.BaseAttr = SKDataUtil.toJson(item.BaseAttr, "{}");
obj.BaseScore = equipdata.BaseScore;
obj.EDesc = equipdata.EDesc;
obj.Detail = equipdata.Detail;
obj.Dynamic = equipdata.Dynamic;
obj.Grade = item.Grade;
obj.EIndex = item.EIndex;
obj.JiLv = equipdata.JiLv;
obj.MaxEmbedGemCnt = equipdata.MaxEmbedGemCnt;
obj.MaxEndure = equipdata.MaxEndure;
obj.EName = equipdata.EName;
obj.NeedGrade = equipdata.NeedGrade;
obj.NeedRei = equipdata.NeedRei;
obj.NextType = equipdata.NextType;
obj.Overlap = equipdata.Overlap;
obj.Quan = equipdata.Quan;
obj.Race = equipdata.Race;
obj.Rarity = equipdata.Rarity;
obj.RndRange = equipdata.RndRange;
obj.RndWeight = equipdata.RndWeight;
obj.Sex = equipdata.Sex;
obj.Shape = equipdata.Shape;
obj.Shuxingxuqiu = SKDataUtil.toJson(item.Shuxingxuqiu, "{}");
obj.Type = item.Type;
obj.GemCnt = item.GemCnt;
obj.LianhuaAttr = SKDataUtil.toJson(item.LianhuaAttr, "{}");
obj.OwnerRoleId = equipdata.OwnerRoleId;
obj.refine = SKDataUtil.toJson(item.refine, "{}");
obj.recast = SKDataUtil.toJson(item.recast, "{}");
} else { // 在线则查缓存中的数据
let equip: Equip = player.equipObjs[item.EquipID];
if (equip != null && equip != undefined) {
obj = equip.toObj();
} else {
this.send_notice(`获取信息失败!`);
return;
}
}
obj.name = item.name;
obj.roleid = item.roleid;
this.send('s2s_goods_info', {
type: data.type,
info: SKDataUtil.toJson(obj, "{}")
});
} else {
this.send_notice(`获取信息失败!`);
}
callback = null;
}
DB.equipInfo(data, callback);
} else if (data.type == 3) {
// 宠物信息
let callback = (ret: any, item: any) => {
if (ret == MsgCode.SUCCESS) {
let obj: any = item[0];
if (obj) {
let player = PlayerMgr.shared.getPlayerByRoleId(obj.roleid);
// 判断玩家是否在线(查数据库)
if (player == null || player == undefined) {
DB.loginByRoleid(obj.roleid, (code: any, info: any) => {
let pet: any = new Pet(obj.dataid);
let player = new Player();
player.setDB(info);
pet.setDB(obj);
pet.setOwner(player)
// 坐骑
player.horseList.setDB(info.horseRows);
player.horseList.horseIndex = SKDataUtil.clamp(info.horse_index, ERaceType.HUMEN, ERaceType.DRAGON);
// 坐骑技能
player.horseSkill.setDB(info.horseSkillRows);
// 发送前端
this.sendPetInfo(pet, item[0], data.type, obj.PetName, player.horseSkill.getList(obj.control));
});
} else { // 在线则查缓存中的数据
let arr = player.petList;
let pet = arr.find(function (pet) {
return pet.petid === Number(data.id)
})
// 发送前端
this.sendPetInfo(pet, item[0], data.type, obj.PetName, this.horseSkill.getList(pet.control));
}
} else {
this.send_notice(`获取信息失败!`);
}
} else {
this.send_notice(`获取信息失败!`);
}
callback = null;
}
DB.petInfo(data, callback);
} else if (data.type == 2 || data.type == 5 || data.type == 6) {
// 道具信息
let obj: any = {};
obj.id = data.id
this.send('s2s_goods_info', {
type: data.type,
info: JSON.stringify(obj)
});
}
// 查询队伍信息
else if (data.type == 9) {
this.send('s2s_goods_info', {
type: data.type,
info: SKDataUtil.toJson(TeamMgr.shared.teamListInfo(data.id), "{}")
});
}
else {
this.send_notice(`该道具查询未生效!`);
return;
}
}
/**
* 发送宠物详情
* @param pet 宠物信息
* @param item 角色信息
* @param type 返回类型
* @param petName 角色名称
* @param horseSkill 坐骑技能
*/
sendPetInfo(pet: any, item: any, type: number, petName: string, horseSkill: any) {
let obj = pet.toObj();
obj.PetName = petName;
obj.name = item.name;
obj.roleid = item.roleid;
obj.horseSkill = horseSkill;
this.send('s2s_goods_info', {
type: type,
info: SKDataUtil.toJson(obj, "{}")
});
}
//检查是否可以兑换
checkExchange(code: any) {
if (this.exchange.hasCode(code)) {
this.send_notice(`您的兑换码[${code}]已经兑换过了!`);
return;
}
this.exchange.checkCode(code, this);
}
// 获得坐骑技能列表
getHorseSkill() {
let params = this.horseSkill.toObj();
this.send('s2c_horse_skill', params);
}
// 升级坐骑技能
upgradeHorseSkill(data: any) {
let skill = this.horseSkill.getSkill(data.position);
if (skill == null) {
return;
}
let exp = SKDataUtil.clamp(skill.exp + 150, 0, 20000);
if (skill.exp >= exp) {
this.send('s2c_notice', {
strRichText: `坐骑技能[${skill.skill_name}]熟练度已升满!`
});
return;
}
let itemData = ItemUtil.getItemData(GameUtil.horseSkillUpItemId);
let count = ItemUtil.getBagItemCount(this, itemData.id);
if (count < 3) {
this.send('s2c_notice', {
strRichText: `您需要至少3个[${itemData.name}]才能升级坐骑技能!`
});
return;
}
let old = skill.exp;
skill.exp = exp;
this.addItem(itemData.id, -3, false, "升级坐骑技能");
SKLogger.debug(`玩家[${this.roleid}:${this.name}]坐骑技能[${skill.skill_name}]升级经验:${old}->${skill.exp}`);
let player = PlayerMgr.shared.getPlayerByRoleId(this.roleid);
if (player) {
//cxf坐骑技能升级
SKCxfUtil.getCxfRecordOperate({
roleId: player.roleid,
roleName: player.name,
operateType: Operate.HORSE,
operateDepict: "坐骑技能升级",
operateResSerial: skill.skill_id,
operateResName: skill.skill_name,
operateContent: ""
})
}
this.updatePetControl(Math.floor(data.position / 3) + 1);
let params = this.horseSkill.toObj();
this.send("s2c_horse_skill", params);
}
// 坐骑洗炼
horseRefining(data: any) {
this.horseSkill.refining(data);
}
// 领取每日充值奖励
dayReward(data: any) {
let key = data.money;
let receive = (this.dayMap[`day_${key}`] || 0);
if (receive > 0) {
this.send('s2c_notice', {
strRichText: `您已领取每日充值${key}元奖励!`
});
return;
}
if ((this.getBagItemAllKindNum() + 4) >= this.bagKindNum) {
this.send('s2c_notice', {
strRichText: `背包没有足够的空间,无法领取每日充值${key}元奖励!`
});
return;
}
let reward = ChargeSum.shared.dayReward[key];
let message = ``;
for (let item of reward) {
message += `物品:${item.item_name},数量:${item.count}`;
this.addItem(item.item_id, item.count, true, `每日充值${key}元奖励`);
}
this.dayMap[`day_${key}`] = 1;
this.send(`s2c_day_reward`, {
dayMap: SKDataUtil.toJson(this.dayMap, "{}")
});
SKCxfUtil.getCxfRecordOperate({
roleId: this.roleid,
roleName: this.name,
operateType: Operate.ITEM,
operateDepict: "每日充值奖励",
operateResSerial: "",
operateResName: "",
operateContent: message
})
}
//新用户绑定
roleBinding(bPlayer: any) {
let list = PaiHangMgr.shared.bind_player_list;
for (let key in list) {
let bplayer = list[key];
if (this.roleid == bplayer.roleid) {
this.send_notice("您已经绑定过玩家了!");
return;
}
}
PaiHangMgr.shared.bind_player_list.push({
roleid: this.roleid,
name: this.name,
resid: this.resid,
relive: this.relive,
level: this.level,
bind_roleid: bPlayer.roleid,
bind_name: bPlayer.name,
bind_resid: bPlayer.resid,
bind_relive: bPlayer.relive,
bind_level: bPlayer.level
})
let sql = `INSERT INTO qy_binding(roleid, name, resid, relive, level, bind_roleid, bind_name, bind_resid, bind_relive, bind_level) VALUES(${this.roleid},'${this.name}',${this.resid},${this.relive},${this.level},${bPlayer.roleid},'${bPlayer.name}',${bPlayer.resid},${bPlayer.relive},${bPlayer.level});`;
DB.query(sql, (error: any, rows: any) => {
if (error) {
let info = DB.errorInfo(error);
SKLogger.warn(`数据插入错误[${info}]`);
return;
}
if (rows.length == 0) {
return;
}
})
this.send('s2c_notice', {
strRichText: `绑定成功!`
})
}
// 领取VIP每日奖励
vipReward(data: any) {
let type = data.type;
let vipLevel = data.vipLevel;
let chargeSum = ChargeSum.shared.getPlayerChargeSum(this.roleid);
let myVip = VIPUtil.getVipLevel(chargeSum);
if (vipLevel > myVip) {
this.send('s2c_notice', {
strRichText: `您不能领取高于自己VIP${vipLevel}每日奖励!`
});
return;
}
let receive = (this.dayMap[`vip_${vipLevel}`] || 0);
if (receive > 0) {
this.send('s2c_notice', {
strRichText: `您已领取VIP${vipLevel}每日奖励!`
});
return;
}
if ((this.getBagItemAllKindNum() + 4) >= this.bagKindNum) {
this.send('s2c_notice', {
strRichText: `背包没有足够的空间无法领取VIP${vipLevel}每日奖励!`
});
return;
}
let reward = VIPUtil.getVipReward(vipLevel);
if (reward == null) {
this.send('s2c_notice', {
strRichText: `奖励物品错误无法领取VIP${vipLevel}每日奖励!`
});
return;
}
for (let itemData of reward) {
this.addItem(itemData.id, itemData.count, true, `VIP${vipLevel}每日奖励`);
}
this.dayMap[`vip_${vipLevel}`] = 1;
this.send(`s2c_vip_reward`, {
dayMap: SKDataUtil.toJson(this.dayMap, "{}")
});
}
// 挖宝列表
dugList(data: any) {
let type = data.type;
let dug = this.dayMap[`dug_${type}`];
if (!DugMgr.enabled) {
this.send('s2c_notice', {
strRichText: `今日挖宝活动已关闭,何时开启另行通知!`,
});
if (dug == null) {
this.dayMap[`dug_${type}`] = DugMgr.shared.update(type);
}
this.send(`s2c_dug_list`, {
dayMap: SKDataUtil.toJson(this.dayMap, "{}")
});
return;
};
if (dug == null) {
this.dayMap[`dug_${type}`] = DugMgr.shared.update(type);
} else {
let count = (dug.count != null ? dug.count : -1);
if (count < 0) {
// 10万仙玉刷新
let updateJade = DugMgr.updateJade;
if (this.jade < updateJade) {
this.send('s2c_notice', {
strRichText: `挖宝刷新需要消耗${this.jade}仙玉不足`,
});
} else {
this.addMoney(GameUtil.goldKind.Jade, -100000, `挖宝刷新消耗仙玉${updateJade}`, MsgCode.SUCCESS);
this.dayMap[`dug_${type}`] = DugMgr.shared.update(type);
}
}
}
this.send(`s2c_dug_list`, {
dayMap: SKDataUtil.toJson(this.dayMap, "{}")
});
}
// 开挖
dug(data: any) {
let index = data.index;
if (!DugMgr.enabled) {
this.send('s2c_notice', {
strRichText: `今日挖宝活动已关闭,何时开启另行通知!`,
});
this.send(`s2c_dug`, {
state: 0,
index: index
});
return;
};
let type = data.type;
let dug = this.dayMap[`dug_${type}`];
if (dug == null) {
return;
}
if (index == -1) {
this.dayMap[`dug_${type}`] = DugMgr.shared.start(dug);
this.send(`s2c_dug_list`, {
dayMap: SKDataUtil.toJson(this.dayMap, "{}")
});
} else {
// 已挖处理
if (dug.list[index].done == 1) {
this.send('s2c_notice', {
strRichText: `您第${dug.count + 1}次挖宝奖励已挖!`,
});
return;
}
// 扣除仙玉
let reward = dug.list[index];
let itemData = ItemUtil.getItemData(reward.item_id);
if (itemData == null) {
this.send_notice(`您第${dug.count + 1}次挖宝奖励不存在!`);
this.send(`s2c_dug`, {
state: 0,
index: index
});
return;
}
let jade = DugMgr.shared.getJade(dug.count);
if (this.jade < jade) {
this.send_notice(`您第${dug.count + 1}次挖宝消耗仙玉${jade}不足`);
this.send(`s2c_dug`, {
state: 0,
index: index
});
return;
}
this.addMoney(GameUtil.goldKind.Jade, -jade, `您第${dug.count + 1}次挖宝消耗仙玉${jade}`, MsgCode.SUCCESS);
dug.count = dug.count + 1;
dug.list[index].done = 1;
this.addItem(reward.item_id, reward.count, true, `挖宝奖励`);
SKLogger.info(`玩家[${this.roleid}:${this.name}]第${dug.count + 1}次挖宝消耗仙玉${jade},获得奖励[${itemData.name}]${reward.count}`);
this.send(`s2c_dug`, {
state: 1,
index: index
});
}
}
// ------------------------------------------------------- 公共方法 ---------------------------------------------------
/**
* 发送信息
* @param msg 内容
*/
send_notice(msg: string) {
this.send('s2c_notice', {
strRichText: msg,
});
}
/**
* 发送信息 - 信息
* @param msg 内容
*/
send_message(msg: string) {
this.send('s2c_game_chat', {
scale: 7,
msg: msg,
name: '',
resid: 0,
teamid: 0,
});
}
/**
* 跳转地图
* @param id 地图编号
*/
map_transfer(id: any, coordx: number = 0, coordy: number = 0) {
this.send('s2c_map_transfer', {
mapId: id,
coordx: coordx,
coordy: coordy,
});
}
/**
* 刷新队伍信息
*/
refresh_team_data() {
// 判断玩家是否在队伍中
if (this.teamid > 0) {
TeamMgr.shared.sendInfoToMember(this.teamid)
}
}
getZhenFaInfo() {
var json = this.ZFMgr.toJson()
this.send('s2c_getZhenFaInfo', {
info: json
});
}
upLevelZhenFa(index: number, level: number) {
var lv = this.ZFMgr.getZhenFaLevelByPos(index)
const l = level - lv
if (0 >= l) {
this.send_notice(`该阵法位置等级信息错误,请稍后再试!`);
return false
}
const count = ItemUtil.getBagItemCount(this, 2000030)
const _count = (l * 5)
if (count < _count) {
this.send_notice(`您的荒玉道具不足,请及时购买!`);
return false
}
this.addBagItem(2000030, 0 - _count, false)
this.ZFMgr.upLevel(index, level)
this.onZhenFaChange()
return true
}
equipXwItem(data: any) {
if (!this.bag_list[data.itemID]) {//如果没有在背包中
if (!!this.ZFMgr.isEquip(data.itemID)) {
var index = this.ZFMgr.getEquipIndex(data.itemID)//获取装备位
if (-1 != index) {
if (!!this.ZFMgr.dumpXw(index)) {//卸下信物
var oldXw = this.ZFMgr.equipXw(data.pos, data.itemID)
if (0 != oldXw)
this.addBagItem(oldXw, 1, false)
this.onZhenFaChange()
} else {
SKLogger.warn(`卸下信物失败!`);
}
} else {
SKLogger.warn(`在阵法对应位置上未找到该信物!`);
}
} else {
this.send_notice(`您没有该信物,请通过多宝商店进行购买!`);
}
} else if (!!this.bag_list[data.itemID]) {//如果在背包中
this.addBagItem(data.itemID, -1, false)
var oldXw = this.ZFMgr.equipXw(data.pos, data.itemID)
if (0 != oldXw)
this.addBagItem(oldXw, 1, false)
this.onZhenFaChange()
} else {
this.send_notice(`您没有该信物,请通过多宝商店进行购买!`);
}
}
//激活阵法位
active_zhenfa_position(data: any) {
this.ZFMgr.saveActiveInde(data.index)//保存激活位
var list = this.ZFMgr.getZhenFaItem()//获取阵法上的所有装备
if (0 < list.length) {
const count = list.length
for (var i = 0; i < count; ++i) {
this.addBagItem(list[i], 1, false)
}
}
this.ZFMgr.clearInfo()//清空阵法信息
var list = ItemUtil.getBagXwItem(this)
var info = ZhenFaUtil.getZhenFaInfo(data.index)//获取阵法位信息
const count = info.valid_pos.length
for (var i = 0; i < count; ++i) {
//随机信物道具
if (0 < list.length) {
var index = Math.floor((Math.random() * 100)) % list.length
if (!!this.ZFMgr.active(info.valid_pos[i], list[index].id)) {
this.addBagItem(list[index].id, -1, false)
list.splice(index, 1)
}
} else {
this.ZFMgr.active(info.valid_pos[i], 0)
}
}
this.onZhenFaChange()
return true
}
onZhenFaChange() {
this.calculateAttr();
for (let pet of this.petList) {
pet.calculateAttribute();
}
this.send('s2c_player_data', this.getData());
this.getZhenFaInfo()
}
succinct(data: any) {
let cnt = ItemUtil.getBagItemCount(this, 2000031)
if (cnt < 1) {
return this.send("s2c_xw_normal_succinct", {
ret: 1, // 缺少五色石
})
}
let money = this.GetMoney(GameUtil.goldKind.Money)
if (money < 300000) {
return this.send("s2c_xw_normal_succinct", {
ret: 2, // 缺少银两
})
}
this.update_bagitem({ operation: 0, itemid: 2000031, count: 1 })
this.addMoney(GameUtil.goldKind.Jade, -300000)
this.list.splice(0, this.list.length)
var info = this.XWMgr.succinct(data.itemID)
if (!!info) {
this.XWMgr.setNewAttrInfo(data.itemID, info)
this.list.push(info)
}
this.send("s2c_xw_normal_succinct", {
ret: 0,
list: SKDataUtil.toJson(this.list, "{}")
})
}
//获取属性信息
getAttrInfo(data: any) {
var info: any = this.XWMgr.getAttrInfo(data.itemID)
this.send("s2c_getXwAttrInfo", {
pos1: info.pos1,
attr1: info.attr1,
value1: info.value1,
pos2: info.pos2,
attr2: info.attr2,
value2: info.value2,
pos3: info.pos3,
attr3: info.attr3,
value3: info.value3,
max1: info.max1,
max2: info.max2,
max3: info.max3
})
}
getAllAttrInfo(data: any) {
var attr_info = this.XWMgr.getAttrInfo(data.itemID)
console.log("attr_info:", attr_info)
var new_info = this.XWMgr.getNewAttrInfo(data.itemID)
console.log("new_info:", new_info)
this.send("s2c_getAttrInfo", {
attrList: SKDataUtil.toJson(attr_info, "{}"),
succintAttrList: SKDataUtil.toJson({ list: new_info }, "{}")
})
}
replaceAttribute(data: any) {
var code = this.XWMgr.replaceAttr(data.itemID)
if (0 == code) {
var item = this.XWMgr.getXwItem(data.itemID)
if (!!item) {
var attr_info = this.XWMgr.getAttrInfo(data.itemID)
var new_info = this.XWMgr.getNewAttrInfo(data.itemID)
this.send("s2c_replaceattribute", {
itemID: data.itemID,
attrList: SKDataUtil.toJson(attr_info, "{}"),
succintAttrList: SKDataUtil.toJson(new_info, "{}"),
})
}
} else if (1 == code) {
this.send_notice("洗练失败不能替换信物属性")
} else if (2 == code) {
this.send_notice("没有找到该信物")
}
this.getZhenFaInfo()
this.calculateAttr();
this.send('s2c_player_data', this.getData());
}
getBabySkillConfig(data: any) {
//todo
let msg = GameUtil.require_ex("../../conf/prop_data/prop_baby_skill.json")
this.send("s2c_getBabySkillConfig", {
config: SKDataUtil.toJson(msg, "{}"),
})
}
adoptBaby(data: any) {
let baby = this.BabyMgr.AdoptBaby(data.sex)
let ret = 1
let jsonBaby = ""
if (baby != null) {
ret = 0
jsonBaby = baby.ToJson()
this.addMoney(GameUtil.goldKind.Jade, -6000000)
}
this.send("s2c_adoptBaby", {
ret: ret,
baby: jsonBaby
})
if (this.BabyMgr.BabyList.length == 1) {
this.BabyMgr.SetBattle(baby.ID)
this.send("s2c_babyBattle", {
ret: ret,
baby: baby.ToJson()
})
}
}
babyBattle(data: any) {
let baby = this.BabyMgr.SetBattle(data.id)
let ret = 1
let jsonBaby = ""
if (baby != null) {
ret = 0
jsonBaby = baby.ToJson()
}
this.send("s2c_babyBattle", {
ret: ret,
baby: baby.ToJson()
})
}
babySkillBless(data: any) {
let hasCnt = ItemUtil.getBagItemCount(this, 9651)
if (hasCnt < 1) {
this.send("s2c_babySkillBless", {
ret: 1,
id: data.id,
})
return
}
let skill = this.BabyMgr.Bless(data.id)
let ret = 1
let jsonSkill = ""
if (skill != null) {
ret = 0
jsonSkill = SKDataUtil.toJson(skill, "{}")
this.update_bagitem({ operation: 0, itemid: 9651, count: 1 })
}
this.send("s2c_babySkillBless", {
ret: ret,
id: data.id,
skill: jsonSkill
})
}
babySkillUpgrade(data: any) {
let _skill = this.BabyMgr.GetBabySkill(data.id, data.skillId)
if (_skill == null) {
this.send("s2c_babySkillUpgrade", {
ret: 1,
id: data.id,
})
return
}
if (_skill.level >= 100) {
this.send("s2c_babySkillUpgrade", {
ret: 3,
id: data.id,
})
return
}
let need = _skill.level * 5
let hasCnt = ItemUtil.getBagItemCount(this, 9650)
let hasMoney = this.GetMoney(GameUtil.goldKind.Money)
if (hasCnt < need || hasMoney < 1000000) {
this.send("s2c_babySkillUpgrade", {
ret: 1,
id: data.id,
})
return
}
let ret = this.BabyMgr.Upgrade(data.id, data.skillId)
let jsonSkill = ""
if (ret == 0) {
let skill = this.BabyMgr.GetBabySkill(data.id, data.skillId)
jsonSkill = SKDataUtil.toJson(skill, "{}")
this.addMoney(GameUtil.goldKind.Money, -1000000)
this.update_bagitem({ operation: 0, itemid: 9650, count: need })
}
this.send("s2c_babySkillUpgrade", {
ret: ret,
id: data.id,
skill: jsonSkill
})
}
babySkillBattle(data: any) {
let skill = this.BabyMgr.SkillBattle(data.id, data.skillId)
let ret = 1
let jsonSkill = ""
if (skill != null) {
ret = 0
jsonSkill = SKDataUtil.toJson(skill, "{}")
}
this.send("s2c_babySkillBattle", {
ret: ret,
id: data.id,
skill: jsonSkill
})
}
babyPracticeConfig(data?: any) {
let config = GameUtil.require_ex("../../conf/prop_data/prop_baby_practice.json")
this.send("s2c_babyPracticeConfig", {
config: SKDataUtil.toJson(config, "{}")
})
}
//0 成功 1 失败 2 疲劳已满 3 属性已加至最高
babyPractice(data: any) {
let ret = this.BabyMgr.Practice(data.id, data.type, data.class)
let babyJson = ""
if (ret == 0) {
let baby = this.BabyMgr.GetBabyByID(data.id)
babyJson = baby.ToJson()
}
this.send("s2c_babyPractice", {
ret: ret,
baby: babyJson
})
}
BabyEatCandy(babyId: number): boolean {
let ret = this.BabyMgr.EatCandy(babyId)
let babyJson = ""
if (ret == 0) {
let baby = this.BabyMgr.GetBabyByID(babyId)
babyJson = baby.ToJson()
}
this.send("s2c_babyPractice", {
ret: ret,
baby: babyJson
})
return ret == 0
}
ReadingBook(babyId: number): boolean {
let ret = this.BabyMgr.ReadingBook(babyId)
let babyJson = ""
if (ret == 0) {
let baby = this.BabyMgr.GetBabyByID(babyId)
babyJson = baby.ToJson()
}
this.send("s2c_babyPractice", {
ret: ret,
baby: babyJson
})
return ret == 0
}
//获取新属性信息
getNewAttrInfo(data: any) {
var info: any = this.XWMgr.getNewAttrInfo(data.itemID)
var strList = SKDataUtil.toJson([info], "{}")
this.send("s2c_getNewAttrInfo", {
list: strList
})
}
//清除所有新属性信息
clearNewAttrInfo() {
this.XWMgr.clearNewAttrInfo()
}
upgradeStar(data: any) {
let ret = this.StarMgr.Upgrade(data.starid, data.upgrade)
if (ret != 0) {
return this.send("s2c_upgradeStar", { ret: ret })
}
let star = this.StarMgr.GetStarByID(data.starid)
let msg = {
ret: 0,
starid: data.starid,
level: star.Level,
equip: SKDataUtil.toJson(star.EquipAttr, "[]"),
fresh: SKDataUtil.toJson(star.FreshAttr, "[]")
}
this.send("s2c_upgradeStar", msg)
this.calculateAttr()
this.send('s2c_player_data', this.getData());
}
getNewStarAttr(data: any) {
let ret = this.StarMgr.GetNewStarAttr(data.starid)
if (ret != 0) {
return this.send("s2c_getNewStarAttr", { ret: ret })
}
let star = this.StarMgr.GetStarByID(data.starid)
let msg = {
ret: 0,
starid: data.starid,
attr: SKDataUtil.toJson(star.FreshAttr, "[]")
}
this.send("s2c_getNewStarAttr", msg)
}
replaceStarAttr(data: any) {
let ret = this.StarMgr.ReplaceStarAttr(data.starid)
if (ret != 0) {
return this.send("s2c_replaceStarAttr", { ret: ret })
}
let star = this.StarMgr.GetStarByID(data.starid)
let msg = {
ret: 0,
starid: data.starid,
attr: SKDataUtil.toJson(star.EquipAttr, "[]")
}
this.send("s2c_replaceStarAttr", msg)
this.calculateAttr()
this.send('s2c_player_data', this.getData());
}
equipStar(data: any) {
let ret = this.StarMgr.EquipStar(data.starid)
if (ret == 0) {
this.calculateAttr()
this.send('s2c_player_data', this.getData());
}
let msg = {
ret: ret,
starid: data.starid
}
return this.send("s2c_equipStar", msg)
}
}