装备穿戴战力bug

This commit is contained in:
mamengke01
2020-12-29 19:48:01 +08:00
parent 93f6ee0499
commit d70cabfdbb
5 changed files with 114 additions and 134 deletions

View File

@@ -307,7 +307,7 @@ function pushEventMsg(sid: string, roleId: string, msg: any ) {
* @param status 状态id
*/
export function checkEventStatus(type: number, status: number) {
console.log('type = '+ type + ' status = '+status);
let flag: boolean; // 检查状态是否正确
if(type == EVENT_TYPE.BATTLE||type ==EVENT_TYPE.QUIZ) {
if(status == EVENT_RECORD_STATUS.BATTLE_SUCCESS) {

View File

@@ -135,7 +135,6 @@ export const STATUS = {
// 武将训练,好感度,羁绊,时装相关 30300 - 30399
HERO_NOT_FIND: {code: 30300, simStr: '武将不存在' },
HERO_JOB_REACH_MAX_STAGE: {code: 30300, simStr: '武将已达到最大的职业阶级'},
HERO_JOB_STAGE_REACH_MAX_STAGE: {code: 30301, simStr: '武将已训练到最大阶段'},
NOT_REACH_UNLOCK_LEVEL: {code: 30302, simStr: '未达到解锁等级'},
HERO_SKIN_NOT_FIND: {code: 30303, simStr: '时装不存在'},
@@ -144,7 +143,8 @@ export const STATUS = {
HERO_CONECTION_IS_MAX_LEVEL: {code: 30306, simStr: '羁绊已达到最大等级'},
HERO_CONECTION_IS_NOT_EXIT: {code: 30307, simStr: '羁绊不存在'},
ROLE_SHORT_HERO_CONECTION:{code: 30308, simStr: '未拥有羁绊武将'},
HERO_FAVOUR_LEVEL_REACH_MAXT:{code: 30308, simStr: '武将好感等级以达到最大'},
HERO_FAVOUR_LEVEL_REACH_MAXT:{code: 30309, simStr: '武将好感等级以达到最大'},
HERO_JOB_REACH_MAX_STAGE: {code: 30310, simStr: '武将已达到最大的职业阶级'},
// 装备养成 30400-30499
ROLE_EQUIP_PLACE_NOT_ENOUGH: {code: 30400, simStr: '装备栏未装备或无可强化'},
@@ -163,21 +163,21 @@ export const STATUS = {
EQUIP_IS_EQUIPED_NOT_DECOMPOSE: {code: 30503, simStr: '装备已穿戴,不能分解'},
EQUIP_HOLE_NOT_FIND: {code: 30504, simStr: '装备孔不存在' },
EQUIP_HOLE_IS_DUG: {code: 30505, simStr: '装备已经打过孔' },
EQUIP_HOLE_IS_NOT_DUG: {code: 30505, simStr: '装备未打过孔' },
JEWEL_IS_NOT_FIND: {code: 30506, simStr: '宝石不存在' },
EQUIP_NOT_FILL_HOLE: {code: 30506, simStr: '未穿戴宝石' },
EQUIP_NOT_EQUIPED_HERO: {code: 30507, simStr: '装备不能被该武将穿戴'},
EQUIP_LEVEL_LIMIT: {code: 30508, simStr: '装备穿戴等级限制'},
EQUIP_NOT_MATCH_JEWEL: {code: 30504, simStr: '装备不能镶嵌该宝石' },
//全局养成30500-30699
ROLE_REACH_MAX_TITLE_LEVEL: {code: 30500, simStr: '玩家已达到最高的爵位'},
ROLE_TERAPH_NOT_STRENGTHEN: {code: 30501, simStr: '玩家神像不能强化'},
ROLE_TERAPH_NOT_QUILITY: {code: 30502, simStr: '玩家神像不能进阶'},
EQUIP_HOLE_IS_NOT_DUG: {code: 30506, simStr: '装备未打过孔' },
JEWEL_IS_NOT_FIND: {code: 30507, simStr: '宝石不存在' },
EQUIP_NOT_FILL_HOLE: {code: 30508, simStr: '未穿戴宝石' },
EQUIP_NOT_EQUIPED_HERO: {code: 30509, simStr: '装备不能被该武将穿戴'},
EQUIP_LEVEL_LIMIT: {code: 30510, simStr: '装备穿戴等级限制'},
EQUIP_NOT_MATCH_JEWEL: {code: 30511, simStr: '装备不能镶嵌该宝石' },
//全局养成30600-30799
ROLE_REACH_MAX_TITLE_LEVEL: {code: 30600, simStr: '玩家已达到最高的爵位'},
ROLE_TERAPH_NOT_STRENGTHEN: {code: 30601, simStr: '玩家神像不能强化'},
ROLE_TERAPH_NOT_QUILITY: {code: 30602, simStr: '玩家神像不能进阶'},
ROLE_SCHOOL_HERO_USED: {code: 30600, simStr: '该武将已配置'},
ROLE_SCHOOL_POSITION_LOCKED: {code: 30601, simStr: '该位置未解锁'},
ROLE_SCHOOL_POSITION_UNLOCK_NOT_NEED: {code: 30602, simStr: '该位置已解锁'},
ROLE_SCROLL_REACH_MAX: {code: 30603, simStr: '已经升到可以升的最高等级'},
ROLE_SCHOOL_HERO_USED: {code: 30603, simStr: '该武将已配置'},
ROLE_SCHOOL_POSITION_LOCKED: {code: 30604, simStr: '该位置未解锁'},
ROLE_SCHOOL_POSITION_UNLOCK_NOT_NEED: {code: 30605, simStr: '该位置已解锁'},
ROLE_SCROLL_REACH_MAX: {code: 30606, simStr: '已经升到可以升的最高等级'},
// 社交相关状态 40000 - 49999
// 运营模块相关状态 50000 - 59999

View File

@@ -12,79 +12,79 @@ const SALT_WORK_FACTOR = 5
@index({ uid: 1 })
export default class GMUser extends BaseModel {
@prop({ required: true })
uid: number;
@prop({ required: true })
uid: number;
@prop({ required: true })
name: string;
@prop({ required: true })
name: string;
@prop({ required: true })
username: string;
@prop({ required: true })
username: string;
@prop({ required: true })
password: string;
@prop({ required: true })
password: string;
@prop({ required: true })
salt: string;
@prop({ required: true })
salt: string;
@prop({ required: true })
token: string;
@prop({ required: true })
token: string;
private static async encryptPass(password: string, salt?: string) {
if(!salt) {
salt = await bcrypt.genSalt(SALT_WORK_FACTOR);
private static async encryptPass(password: string, salt?: string) {
if (!salt) {
salt = await bcrypt.genSalt(SALT_WORK_FACTOR);
}
let npassword = await bcrypt.hash(password, salt);
return { npassword, salt };
}
let npassword = await bcrypt.hash(password, salt);
return {npassword, salt};
}
public static async getGmAccountList(lean = true) {
const user: GMUserType[] = await GMUserModel.find().select('uid username name token').lean(lean);
return user;
}
public static async getGmAccountByToken(token: string, lean = true) {
// console.log(token)
const user: GMUserType = await GMUserModel.findOne({token}).select('uid username name token').lean(lean);
return user;
}
public static async getGmAccountByUid(uid: number, lean = true) {
const user: GMUserType = await GMUserModel.findOne({uid}).select('uid username name token').lean(lean);
return user;
}
public static async getGmAccountByUsername(username: string, lean = true) {
const user: GMUserType = await GMUserModel.findOne({username}).select('uid username name token').lean(lean);
return user;
}
public static async login(username: string, password: string, token: string, lean = true) {
const user: GMUserType = await GMUserModel.findOne({username}).select('salt').lean();
if(user) {
let { salt } = user;
let { npassword } = await this.encryptPass(password, salt);
const checkUser: GMUserType = await GMUserModel.findOneAndUpdate({username, password: npassword}, { token }).select('uid username name token').lean(lean);
return checkUser;
} else {
return null
public static async getGmAccountList(lean = true) {
const user: GMUserType[] = await GMUserModel.find().select('uid username name token').lean(lean);
return user;
}
}
public static async createGmAccount(username: string, password: string, name: string, token: string, lean = true) {
const uid = await CounterModel.getNewCounter(COUNTER.GMUID);
let r = await this.encryptPass(password);
const user: GMUserType = await GMUserModel.findOneAndUpdate({username}, {uid, password: r.npassword, salt: r.salt, name, token}, {upsert: true, new: true}).select('uid username name').lean(lean);
return user;
}
public static async getGmAccountByToken(token: string, lean = true) {
// console.log(token)
const user: GMUserType = await GMUserModel.findOne({ token }).select('uid username name token').lean(lean);
return user;
}
public static async changePass(uid: number, password: string, lean = true) {
let r = await this.encryptPass(password);
const user: GMUserType = await GMUserModel.findOneAndUpdate({uid}, { password: r.npassword, salt: r.salt}).select('uid username name').lean(lean);
return user;
}
public static async getGmAccountByUid(uid: number, lean = true) {
const user: GMUserType = await GMUserModel.findOne({ uid }).select('uid username name token').lean(lean);
return user;
}
public static async getGmAccountByUsername(username: string, lean = true) {
const user: GMUserType = await GMUserModel.findOne({ username }).select('uid username name token').lean(lean);
return user;
}
public static async login(username: string, password: string, token: string, lean = true) {
const user: GMUserType = await GMUserModel.findOne({ username }).select('salt').lean();
if (user) {
let { salt } = user;
let { npassword } = await this.encryptPass(password, salt);
const checkUser: GMUserType = await GMUserModel.findOneAndUpdate({ username, password: npassword }, { token }).select('uid username name token').lean(lean);
return checkUser;
} else {
return null
}
}
public static async createGmAccount(username: string, password: string, name: string, token: string, lean = true) {
const uid = await CounterModel.getNewCounter(COUNTER.GMUID);
let r = await this.encryptPass(password);
const user: GMUserType = await GMUserModel.findOneAndUpdate({ username }, { uid, password: r.npassword, salt: r.salt, name, token }, { upsert: true, new: true }).select('uid username name').lean(lean);
return user;
}
public static async changePass(uid: number, password: string, lean = true) {
let r = await this.encryptPass(password);
const user: GMUserType = await GMUserModel.findOneAndUpdate({ uid }, { password: r.npassword, salt: r.salt }).select('uid username name').lean(lean);
return user;
}
}
export const GMUserModel = getModelForClass(GMUser);
export interface GMUserType extends Pick<DocumentType<GMUser>, keyof GMUser>{};
export interface GMUserType extends Pick<DocumentType<GMUser>, keyof GMUser> { };

View File

@@ -7,7 +7,7 @@ class Heroes {
@prop({ required: true })
actorName: string; // 武将名
@prop({ required: true })
attribute: {hp: number, atk: number, matk: number, def: number, mdef: number, agi: number, luk: number, speed: number, hit: number, cri: number, flee: number, antCri: number, damageIncrease: number, damageDecrease: number, defIgnore: number, bloodSuck: number, ap: number}; // 属性
attribute: { hp: number, atk: number, matk: number, def: number, mdef: number, agi: number, luk: number, speed: number, hit: number, cri: number, flee: number, antCri: number, damageIncrease: number, damageDecrease: number, defIgnore: number, bloodSuck: number, ap: number }; // 属性
@prop({ required: true })
lv: number; // 角色等级
@prop({ required: true })
@@ -18,8 +18,8 @@ class Heroes {
seid: string; // 技能
@prop({ required: false })
star: number; // 角色星级
}
}
@index({ roleId: 1 })
@index({ ce: 1 })
@@ -84,4 +84,4 @@ export default class PvpDefense extends BaseModel {
export const PvpDefenseModel = getModelForClass(PvpDefense);
export interface PvpDefenseType extends Pick<DocumentType<PvpDefense>, keyof PvpDefense>{};
export interface PvpDefenseType extends Pick<DocumentType<PvpDefense>, keyof PvpDefense> { };

View File

@@ -15,7 +15,7 @@ import { EquipType } from '../db/Equip';
import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
import { getGoodById } from './gamedata';
import { SchoolModel } from '../db/School';
import { getTeraphAttr } from '../consts/constModules/abilityConst'
import { getTeraphAttr, HEROTARIN } from '../consts/constModules/abilityConst'
import { PvpDefenseModel } from '../db/PvpDefense';
const HERO_CE_RATIO = 100;
const _ = require('underscore');
@@ -106,7 +106,6 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
let incHeroCe = calPlayerCe(role.globalCeAttr, hero, type, args);
incPlayerCe += incHeroCe;
// hero.ce += incHeroCe;
await calculateTopFive(role, hero.hid, hero.ce); // 计算更新最强五人战力
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
await PvpDefenseModel.updateCe(roleId, hero.hid, hero.ce); // 更新pvp防守阵最强五人战力
@@ -159,37 +158,11 @@ async function calculateTopFive(role: RoleType, hid: number, ce: number) {
// 初始战力
export function calHeroInitIncAttr(hero: HeroType, addSeidList: Array<number>, removeSeidList: Array<number>) {
let res1 = calHeroStarIncAttr(hero, HERO_SYSTEM_TYPE.INIT, hero.hid, [], addSeidList, removeSeidList);
let hero1 = combineHeroCeAttr(hero, res1);
let res = calHeroStarIncAttr(hero, HERO_SYSTEM_TYPE.INIT, hero.hid, [], addSeidList, removeSeidList);
let curSkin = hero.skins.find(cur => cur.enable);
let res2 = calHeroWearSkinIncAttr(hero1, [curSkin ? curSkin.id : 0, 0], addSeidList, removeSeidList, true);
let hero2 = combineHeroCeAttr(hero, res2);
calHeroJobStageUpIncAttr(hero2, [0], addSeidList, removeSeidList);
let result: CeAttr = {};
combineAttrResult(result, res1);
combineAttrResult(result, res2);
return res1
}
function combineAttrResult(target: CeAttr, origin: CeAttr) {
for (let attrName in origin) {
for (let attrKey in origin[attrName]) {
if (!target.hasOwnProperty(attrName)) {
target[attrName] = {};
}
if (!target[attrName].hasOwnProperty(attrKey)) {
target[attrName][attrKey] = 0;
}
if (origin[attrName][attrKey] > target[attrName][attrKey]) {
target[attrName][attrKey] = origin[attrName][attrKey];
}
}
}
calHeroWearSkinIncAttr(hero, [curSkin ? curSkin.id : 0, 0], addSeidList, removeSeidList, true, res);
calHeroJobAttr(hero, res, addSeidList, removeSeidList);
return res;
}
export function calRoleInitIncAttr(heros: HeroType[], globalCeAttr: CeAttrRole) {
@@ -203,21 +176,6 @@ export function calRoleInitIncAttr(heros: HeroType[], globalCeAttr: CeAttrRole)
return res;
}
// 将hero的ceAttr暂时更新不更新在originalHero本体上
function combineHeroCeAttr(originalHero: HeroType, result: CeAttr) {
let hero = deepCopy(originalHero);
if (!hero.ceAttr) hero.ceAttr = new CeAttr();
for (let attrName in result) {
if (!result[attrName]) continue;
if (!hero.ceAttr[attrName]) hero.ceAttr[attrName] = new CeAttrData();
for (let attrKey in result[attrName]) {
hero.ceAttr[attrName][attrKey] = parseInt(result[attrName][attrKey] || 0);
}
}
delete hero._id;
return hero;
}
/**
*
* @param hero HeroType 武将更新后的值
@@ -352,22 +310,44 @@ export function calHeroJobStageUpIncAttr(hero: HeroType, args: Array<number>, ad
return res;
}
export function calHeroJobAttr(hero: HeroType, res: CeAttr, addSeidList: Array<number>, removeSeidList: Array<number>) {
let currentJob = gameData.job.get(hero.job);
let jobGradeAndClass = getJobByGradeAndClass(currentJob.job_class, currentJob.grade - 1);
let lastJob;
if (!!jobGradeAndClass) {
lastJob = gameData.job.get(jobGradeAndClass.jobid);
}
for (let key in HEROTARIN) {
let attrName: string = HEROTARIN[key];
res[attrName] = res[attrName]||{ fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
if (hero.jobStage >= parseInt(key)) {
res[attrName].fixUp += currentJob[attrName] * HERO_CE_RATIO;
} else {
if (lastJob)
res[attrName].fixUp += lastJob[attrName] * HERO_CE_RATIO;
}
}
calHeroJobStageUpIncAttr(hero, [0], addSeidList, removeSeidList);
return res;
}
//穿戴时装
export function calHeroWearSkinIncAttr(hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>, isInit = false) {
let res: CeAttr = {};
export function calHeroWearSkinIncAttr(hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>, isInit = false, heroAttr?:CeAttr) {
let res: CeAttr = heroAttr||{};
let addSkin = gameData.fashion.get(args[0]);
let delSkin = gameData.fashion.get(args[1]);
let attrName: string;
if (delSkin) {
for (let attr of delSkin.actorAttr) {
attrName = getAtrrNameById(attr.id);
res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName] = res[attrName]||{ fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp -= attr.number * HERO_CE_RATIO;
}
}
for (let attr of addSkin.actorAttr) {
attrName = getAtrrNameById(attr.id);
res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName] = res[attrName]||{ fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp += attr.number * HERO_CE_RATIO;
}
@@ -563,7 +543,7 @@ export function calHeroEquipIncAttr(hero: HeroType) {
let originalCe = hero.ceAttr[attrName].equipUp || 0;
console.log('装备战力:', attrName, attrResult[attrName] * HERO_CE_RATIO, originalCe);
res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp, equipUp: originalCe };
res[attrName].equipUp += attrResult[attrName] * HERO_CE_RATIO - originalCe;
res[attrName].equipUp += attrResult[attrName] - originalCe;
}
return res;