战力:获取显示数据
This commit is contained in:
@@ -15,7 +15,6 @@ import { addItems, getFriendPointObject, handleCost } from "../../../services/ro
|
||||
import { RewardInter } from "../../../pubUtils/interface";
|
||||
import { FriendPresentLogModel } from '../../../db/FriendPresentLog';
|
||||
import { HeroModel, EPlace } from "../../../db/Hero";
|
||||
import { getPlayerMainAttribute } from "../../../services/pvpService";
|
||||
import { FRIEND } from "../../../pubUtils/dicParam";
|
||||
import { PlayerDetail, PlayerDetailHero } from "../../../domain/battleField/guild";
|
||||
import { createPrivateMsg, pushMsgToRole, pushPresent } from "../../../services/chatService";
|
||||
@@ -23,6 +22,7 @@ import { Rank } from "../../../services/rankService";
|
||||
import { checkTaskWithRoles, checkTask } from "../../../services/task/taskService";
|
||||
import { ComBattleTeamModel } from "../../../db/ComBattleTeam";
|
||||
import { JewelModel } from "../../../db/Jewel";
|
||||
import { getHeroesAttributes } from "../../../services/playerCeService";
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -719,9 +719,12 @@ export class FriendHandler {
|
||||
|
||||
let jewels = await JewelModel.findMapbyRoleAndHids(hisRoleId, hids);
|
||||
|
||||
let attrByHid = await getHeroesAttributes(hisRoleId);
|
||||
let list: HeroDetailParam[] = [];
|
||||
for (let hero of heroList) {
|
||||
let attributes = getPlayerMainAttribute(hero.attr, role.attr);
|
||||
let attr = attrByHid.get(hero.hid);
|
||||
if(!attr) continue;
|
||||
let attributes = attr.getMainAttributes();
|
||||
let heroParam = new HeroDetailParam(hero);
|
||||
heroParam.setAttributes(attributes);
|
||||
heroParam.setJewels(jewels);
|
||||
|
||||
@@ -16,7 +16,6 @@ import { isNumber, pick } from 'underscore';
|
||||
import { updateEplaces } from '../../../services/equipService';
|
||||
import { addConsumeToHero, checkUnlockTalentCondition, initSkinTalent, updateSkinTalent } from '../../../services/roleService';
|
||||
import { JewelModel, jewelUpdate } from '../../../db/Jewel';
|
||||
import { CalHeroCe } from '../../../services/role/_calCe';
|
||||
import { HERO, REBORN } from '../../../pubUtils/dicParam';
|
||||
import { createHero, createHeroes } from '../../../services/role/createHero';
|
||||
import { CheckMeterial } from '../../../services/role/checkMaterial';
|
||||
|
||||
@@ -25,7 +25,7 @@ import Counter from '../../../db/Counter';
|
||||
import { UserModel } from '../../../db/User';
|
||||
import { checkFilterWords, reportTAEvent, treatRoleName } from '../../../services/sdkService';
|
||||
import { createHeroes } from '../../../services/role/createHero';
|
||||
import { calculateCeWithHero, calculateWithRole } from '../../../services/playerCeService';
|
||||
import { calculateCeWithHero, calculateCeWithRole } from '../../../services/playerCeService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -50,7 +50,7 @@ export class RoleHandler {
|
||||
let checkName = await RoleModel.checkName(roleName, serverId);
|
||||
if (checkName) return resResult(STATUS.NAME_HAS_USED);
|
||||
|
||||
let { resultHeroes: heroes } = await createHeroes(roleId, roleName, sid, serverId, DEFAULT_HEROES.map(hid => ({hid, count: 1})), { roleName, hasInit: true, title: role.title, teraphs: role.teraphs });
|
||||
let { resultHeroes: heroes } = await createHeroes(roleId, roleName, sid, serverId, DEFAULT_HEROES.map(hid => ({hid, count: 1})), { roleName, hasInit: true, title: role.title, teraphs: role.teraphs, lv: DEFAULT_LV });
|
||||
// role = await RoleModel.updateRoleInfo(roleId, { roleName, hasInit: true }); // 在算战力的时候一起更新
|
||||
session.set('roleName', roleName);
|
||||
session.push('roleName', () => { });
|
||||
@@ -95,7 +95,7 @@ export class RoleHandler {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let update = { title: title + 1 }
|
||||
let { curRole } = await calculateWithRole(HERO_SYSTEM_TYPE.TITLE, roleId, serverId, sid, update);
|
||||
let { curRole } = await calculateCeWithRole(HERO_SYSTEM_TYPE.TITLE, roleId, serverId, sid, update);
|
||||
|
||||
// 任务
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TITLE, { oldTitle: title, title: update.title });
|
||||
@@ -128,7 +128,7 @@ export class RoleHandler {
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let { curRole } = await calculateWithRole(HERO_SYSTEM_TYPE.TERAPH, roleId, serverId, sid, { teraphs }, { teraphId: id });
|
||||
let { curRole } = await calculateCeWithRole(HERO_SYSTEM_TYPE.TERAPH, roleId, serverId, sid, { teraphs }, { teraphId: id });
|
||||
|
||||
// 任务
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, { count });
|
||||
@@ -171,7 +171,7 @@ export class RoleHandler {
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.TERAPH_QUALITY_UP);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
let { curRole } = await calculateWithRole(HERO_SYSTEM_TYPE.TERAPH_UP, roleId, serverId, sid, { teraphs }, { teraphId: id });
|
||||
let { curRole } = await calculateCeWithRole(HERO_SYSTEM_TYPE.TERAPH_UP, roleId, serverId, sid, { teraphs }, { teraphId: id });
|
||||
|
||||
// 神像进阶,进阶一次就触发一次礼包弹框
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TERAPH_STAGE_UP);
|
||||
@@ -228,7 +228,7 @@ export class RoleHandler {
|
||||
}
|
||||
|
||||
await SchoolModel.updateBySclAndPos(roleId, schoolId, positionId, { hid, isOpen })
|
||||
await calculateWithRole(HERO_SYSTEM_TYPE.SCHOOL, roleId, serverId, sid, {}, { schoolId, hero: curHero, schoolHid: hid, preSchoolHid: preHid });
|
||||
await calculateCeWithRole(HERO_SYSTEM_TYPE.SCHOOL, roleId, serverId, sid, {}, { schoolId, hero: curHero, schoolHid: hid, preSchoolHid: preHid });
|
||||
|
||||
// 任务
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_SCHOOL_PUT_HERO, { hid, preHid });
|
||||
|
||||
@@ -97,7 +97,7 @@ export function getDungeonBuyCountCost(num:number) {
|
||||
}
|
||||
|
||||
export async function saveDungeonFirst(role: RoleType, warId: number, battleRecord: BattleRecordType) {
|
||||
let userInfo = new RankParam(role, true);
|
||||
let userInfo = new RankParam(role);
|
||||
let lineup = battleRecord.record.lineup;
|
||||
let dicWar = gameData.war.get(warId);
|
||||
await DungeonFirstModel.createDungeonFirst(role.serverId, dicWar.movePoint, warId, {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getRandEelm, } from '../pubUtils/util';
|
||||
import { EPlace, Stone } from "../db/Hero";
|
||||
import { gameData, getRandEffectByGroupAndLevel } from "../pubUtils/data";
|
||||
import { gameData, getJewelConditionByLvAndSeId, getRandEffectByGroupAndLevel } from "../pubUtils/data";
|
||||
import { JewelType, RandSe } from '../db/Jewel';
|
||||
import { DicRandomEffectPool } from '../pubUtils/dictionary/DicRandomEffectPool';
|
||||
import { getJewelRandSe } from './role/rewardService';
|
||||
@@ -145,3 +145,17 @@ export function getJewelByEquip(oldEquip: EPlace, newEquip: EPlace, jewels: Jewe
|
||||
let newJewel = jewels.find(cur => cur && cur.seqId == newEquip.jewel);
|
||||
return { oldJewel, newJewel }
|
||||
}
|
||||
|
||||
export function isRandSeUnLock(jewelId: number, randSeId: number, stones: Stone[]) {
|
||||
let dicJewel = gameData.jewel.get(jewelId);
|
||||
let dicJewelCondition = getJewelConditionByLvAndSeId(dicJewel.lv, randSeId);
|
||||
let stoneCnt = 0, stoneLv = 0;
|
||||
for(let { stone } of stones) {
|
||||
let dicStone = gameData.stone.get(stone);
|
||||
if(dicStone) {
|
||||
stoneCnt++;
|
||||
stoneLv += dicStone.lv;
|
||||
}
|
||||
}
|
||||
return stoneCnt >= dicJewelCondition.stoneCnt && stoneLv >= dicJewelCondition.stoneLv;
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
|
||||
import { ExpeditionPointModel } from '../db/ExpeditionPoint';
|
||||
import Role, { CeAttrDataRole, RoleModel } from '../db/Role';
|
||||
import Role, { RoleModel } from '../db/Role';
|
||||
import { shouldRefresh, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { LINEUP_NUM, EXPEDITION_WAR_RECORD_STATUS } from '../consts';
|
||||
import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
|
||||
import { CeAttrData, HeroType } from '../db/Hero';
|
||||
import { HeroType } from '../db/Hero';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { getTimeFunD } from '../pubUtils/timeUtil';
|
||||
import { ExpeditionRecordModel } from '../db/ExpeditionRecord';
|
||||
import { Attribute, AttributeCal } from '../domain/roleField/attribute';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
import { getSumCe } from './playerCeService';
|
||||
import { getHeroesAttributes, getSumCe } from './playerCeService';
|
||||
|
||||
/**
|
||||
* 获取远征关卡列表
|
||||
@@ -137,7 +137,7 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
let index = Math.floor(Math.random() * resultRange.length);
|
||||
let role = resultRange[index];
|
||||
let {roleId, topLineup, topLineupCe } = role;
|
||||
let { attr: roleAttrs } = role;
|
||||
let attrByHid = await getHeroesAttributes(roleId);
|
||||
|
||||
enemyObj.enemyFrom = 1;
|
||||
enemyObj.enemyId = roleId;
|
||||
@@ -150,9 +150,10 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
if(hero) {
|
||||
let h = <HeroType>hero.hero;
|
||||
if(h) {
|
||||
let { star, lv, attr: heroAttrs, ce } = h;
|
||||
let { star, lv, ce } = h;
|
||||
let dicHero = gameData.hero.get(hero.hid);
|
||||
let { attribute } = getPlayerAttribute(lv, heroAttrs, roleAttrs);
|
||||
let attr = attrByHid.get(hero.hid);
|
||||
let attribute = attr.getAttributesToString();
|
||||
let heroInfo = {
|
||||
actorId: hero.hid,
|
||||
skinId: h.skinId,
|
||||
@@ -281,32 +282,18 @@ export async function getResetRemainCnt(curTime: Date, roleId: string, role?: Ro
|
||||
let newAttribute = new AttributeCal();
|
||||
newAttribute.setLv(lv);
|
||||
newAttribute.setByWarJson(subAttrs); // 次级属性
|
||||
let subAttrCe = newAttribute.calSubAttrCeAndReduce() * enemyCount;
|
||||
let subAttrCe = newAttribute.calSubAttrCe() * enemyCount;
|
||||
if(ce * ratio > subAttrCe) {
|
||||
let mainAttrCe = ce * ratio - subAttrCe;
|
||||
newAttribute.setByWarJson(mainAttrs, mainAttrCe / enemyCe);
|
||||
let attrArr = newAttribute.getReduceAttributesToString();
|
||||
let newCe = newAttribute.calCelAndReduce();
|
||||
let attrArr = newAttribute.getAttributesToString();
|
||||
let newCe = newAttribute.calCe();
|
||||
return { attribute: attrArr, ce: newCe };
|
||||
} else {
|
||||
newAttribute = new AttributeCal();
|
||||
newAttribute.setByWarJson(mainAttrs, ce * ratio / enemyCe);
|
||||
let attrArr = newAttribute.getReduceAttributesToString();
|
||||
let newCe = newAttribute.calCelAndReduce();
|
||||
let attrArr = newAttribute.getAttributesToString();
|
||||
let newCe = newAttribute.calCe();
|
||||
return { attribute: attrArr, ce: newCe };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据玩家数据获取到他的属性
|
||||
* @param ceAttr hero表的ceAttr
|
||||
* @param globalCeAttr role表中的globalCeAttr
|
||||
*/
|
||||
export function getPlayerAttribute(lv: number, heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) {
|
||||
let newAttribute = new AttributeCal();
|
||||
newAttribute.setLv(lv);
|
||||
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
||||
let attribute = newAttribute.getReduceAttributesToString();
|
||||
let ce = newAttribute.calCelAndReduce();
|
||||
return { attribute, ce };
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ServerlistModel } from "../../db/Serverlist";
|
||||
import { RoleModel } from "../../db/Role";
|
||||
import { reduceCe } from "../../pubUtils/util";
|
||||
import { GUILDACTIVITY } from "../../pubUtils/dicParam";
|
||||
import { gameData, getGuildAuctionRewards, getCityActivityRewards } from "../../pubUtils/data";
|
||||
import { getCurDay, nowSeconds, getTimeFun } from "../../pubUtils/timeUtil";
|
||||
@@ -82,7 +81,7 @@ export async function setPreDayActiveData() {
|
||||
}
|
||||
}
|
||||
|
||||
await ServerRecordModel.updateData(server.id, { activePlayerCnt, activePlayerCe: reduceCe(activePlayerCe), activePlayers, activeGuilds });
|
||||
await ServerRecordModel.updateData(server.id, { activePlayerCnt, activePlayerCe, activePlayers, activeGuilds });
|
||||
}
|
||||
return servers;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { findIndex } from 'underscore';
|
||||
import { sismemberAsync, smembersAsync, saddAsync, delAsync, getRoleOnlineInfo } from '../services/redisService';
|
||||
import { pinus } from 'pinus';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { reduceCe, resResult, shouldRefresh } from '../pubUtils/util';
|
||||
import { resResult, shouldRefresh } from '../pubUtils/util';
|
||||
import { BattleRecordModel } from '../db/BattleRecord';
|
||||
import { getArmyBossRank, gameData, getAuctionRewardByPoolId } from '../pubUtils/data';
|
||||
import { sendMailToGuildByContent } from '../services/mailService';
|
||||
@@ -197,8 +197,6 @@ export async function getBossHp(serverId: number, guildCode: string, dicBossBase
|
||||
activeCe += activePlayers[i].topLineupCe;
|
||||
}
|
||||
}
|
||||
activeCe = reduceCe(activeCe);
|
||||
|
||||
console.log(`getBossHp activeCe ${activeCe}`);
|
||||
let B = activeCe/6/GUILDACTIVITY.GATEACTIVITY_ENEMYCE;
|
||||
console.log(`getBossHp B ${B}`);
|
||||
|
||||
@@ -4,7 +4,7 @@ import Role, { RoleModel, RoleType } from '../db/Role'
|
||||
import { getLvByExp, getExpByLv, gameData, getDicApByLv } from '../pubUtils/data';
|
||||
import { updateUserInfo } from './redisService';
|
||||
// import { switchOnFunc } from './funcSwitchService';
|
||||
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON, POP_UP_SHOP_CONDITION_TYPE } from '../consts';
|
||||
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON, POP_UP_SHOP_CONDITION_TYPE, HERO_SYSTEM_TYPE } from '../consts';
|
||||
import { BackendSession, pinus } from 'pinus';
|
||||
import { REDIS_KEY } from '../consts';
|
||||
import { Rank } from './rankService';
|
||||
@@ -16,6 +16,7 @@ import { LineupParam } from '../domain/rank';
|
||||
import { WarStar } from '../domain/dbGeneral';
|
||||
import { uniq } from 'underscore';
|
||||
import { checkPopUpCondition } from './activity/popUpShopService';
|
||||
import { calculateCeWithRole } from './playerCeService';
|
||||
|
||||
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
@@ -47,6 +48,7 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin
|
||||
await checkTask(serverId, roleId, session.get('sid'), TASK_TYPE.ROLE_LV, { oldLv: lv, lv: newLv });
|
||||
// 弹出礼包
|
||||
await checkPopUpCondition(serverId, roleId, POP_UP_SHOP_CONDITION_TYPE.LV_TO, { oldLv: lv, newLv })
|
||||
await calculateCeWithRole(HERO_SYSTEM_TYPE.ROLE_LV, roleId, serverId, sid, { lv: newLv });
|
||||
|
||||
}
|
||||
let actordata: { lv: number, exp: number, getExp: number, mostExp: number }[] = [];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { pinus } from 'pinus';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
|
||||
import { resResult, reduceCe } from '../pubUtils/util';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { HeroModel, HeroType, HeroUpdate } from '../db/Hero';
|
||||
|
||||
import { RoleUpdate, RoleType, RoleModel } from '../db/Role';
|
||||
@@ -19,6 +19,7 @@ import { PvpDefenseModel } from '../db/PvpDefense';
|
||||
import { saveCeChangeLog } from '../pubUtils/logUtil';
|
||||
import { JewelType } from '../db/Jewel';
|
||||
import { SchoolModel } from '../db/School';
|
||||
import { AttributeCal } from '../domain/roleField/attribute';
|
||||
|
||||
interface Param {
|
||||
isInitRole?: boolean,
|
||||
@@ -46,7 +47,7 @@ export async function calculateCeWithHero(type: HERO_SYSTEM_TYPE, roleId: string
|
||||
return { heroes, curHero, curRole }
|
||||
}
|
||||
|
||||
export async function calculateWithRole(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, roleUpdate: RoleUpdate, param: Param = {}) {
|
||||
export async function calculateCeWithRole(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, roleUpdate: RoleUpdate, param: Param = {}) {
|
||||
let { heroes, curRole } = await calculateCes(type, roleId, serverId, sid, new Map(), roleUpdate, {}, param);
|
||||
return { heroes, curRole };
|
||||
}
|
||||
@@ -64,8 +65,10 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
|
||||
calCe.setJob(hid, job, jobStage);
|
||||
}
|
||||
console.log('####### roleUpdate', param.isInitRole, roleUpdate)
|
||||
if(param.isInitRole) {
|
||||
let { title, teraphs } = roleUpdate;
|
||||
let { title, teraphs, lv } = roleUpdate;
|
||||
calCe.setRoleLv(lv)
|
||||
calCe.setTitle(title);
|
||||
calCe.setTeraph(teraphs);
|
||||
}
|
||||
@@ -286,6 +289,12 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HERO_SYSTEM_TYPE.ROLE_LV: // 31. 玩家等级
|
||||
{
|
||||
let { lv } = roleUpdate;
|
||||
calCe.setRoleLv(lv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let { heroCe, roleInc } = calCe.getCeInc(); // 计算战力,获得有变化的武将战力
|
||||
let changeHids: number[] = [];
|
||||
@@ -346,7 +355,7 @@ async function updateRank(roleId: string, serverId: number, topLineupCe: number,
|
||||
|
||||
// 最强阵容
|
||||
let r = new Rank(REDIS_KEY.TOP_LINEUP_RANK, { serverId });
|
||||
await r.setRankWithRoleInfo(roleId, reduceCe(topLineupCe), 0, role);
|
||||
await r.setRankWithRoleInfo(roleId, topLineupCe, 0, role);
|
||||
|
||||
// 最强武将
|
||||
for(let { hid, ce } of pushHeros) {
|
||||
@@ -359,7 +368,7 @@ async function updateRank(roleId: string, serverId: number, topLineupCe: number,
|
||||
|
||||
// 总战力
|
||||
let r3 = new Rank(REDIS_KEY.SUM_CE_RANK, { serverId });
|
||||
await r3.setRankWithRoleInfo(roleId, reduceCe(role.ce), 0, role);
|
||||
await r3.setRankWithRoleInfo(roleId, role.ce, 0, role);
|
||||
|
||||
// 更新最强五人阵容信息
|
||||
let r5 = new Rank(REDIS_KEY.TOP_LINEUP_INFO, { serverId });
|
||||
@@ -383,3 +392,15 @@ export async function getSumCe(roleId: string, num: number) {
|
||||
}
|
||||
return ce;
|
||||
}
|
||||
|
||||
export async function getHeroesAttributes(roleId: string) {
|
||||
let roleCe = await RoleCeModel.findByRoleId(roleId);
|
||||
let attrByHid = new Map<number, AttributeCal>();
|
||||
for(let { hid, attrs } of roleCe.attributes||[]) {
|
||||
let cal = new AttributeCal();
|
||||
cal.setLv(roleCe.roleLv);
|
||||
cal.setByWarJson(attrs);
|
||||
attrByHid.set(hid, cal);
|
||||
}
|
||||
return attrByHid;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
import { PvpDefenseModel, PvpDefenseType, pvpUpdateInter } from '../db/PvpDefense';
|
||||
import { Defense, Attack, LineupCe, OppPlayer, HeroScore, HeroReward, OppPlayerReturn, AttackHero, DefenseHero } from '../domain/battleField/pvp';
|
||||
import { RoleType, CeAttrDataRole } from '../db/Role';
|
||||
import { RoleType } from '../db/Role';
|
||||
import { PVP_HERO_POS, REDIS_KEY, PVP_CONST, COUNTER, TASK_TYPE, MAIL_TYPE, TA_EVENT } from '../consts';
|
||||
import { dicPvpOpponent, DicPvpOpponent } from "../pubUtils/dictionary/DicPvpOpponent";
|
||||
import { getRandSingleIndex, genCode, shouldRefresh, getChineseName, makeRobotId, robotIdComBack, getRandSingleEelm } from '../pubUtils/util';
|
||||
@@ -11,7 +11,7 @@ import { PVP } from '../pubUtils/dicParam';
|
||||
import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig'
|
||||
import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil';
|
||||
import { HeroesRecord, PvpRecordPlayerInfo } from '../db/PvpRecord';
|
||||
import { HeroModel, CeAttrData, HeroType } from '../db/Hero';
|
||||
import { HeroModel, HeroType } from '../db/Hero';
|
||||
import { AttributeCal } from '../domain/roleField/attribute';
|
||||
import { PvpEnemies, PvpHeroInfo, PvpOtherHeroes } from '../domain/dbGeneral';
|
||||
import { DicWarJson } from '../pubUtils/dictionary/DicWarJson';
|
||||
@@ -27,6 +27,7 @@ import { sendMailByContent } from './mailService';
|
||||
import { RoleRankInfo } from '../domain/rank';
|
||||
import { reportTAEvent } from './sdkService';
|
||||
import { getVipPvpChallengeMaxCnt } from './activity/monthlyTicketService';
|
||||
import { getHeroesAttributes } from './playerCeService';
|
||||
|
||||
/**
|
||||
* 返回对手三人信息
|
||||
@@ -203,6 +204,7 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, roleId: string, pos
|
||||
let heroes = new Array<PvpEnemies>();
|
||||
let otherHeroes = new Array<PvpOtherHeroes>(); // 阵容外的所有武将信息
|
||||
let defCe = 0;
|
||||
let attrByHid = await getHeroesAttributes(role.roleId);
|
||||
for (let dbHero of dbHeroes) {
|
||||
let h = defenseHeroes.find(cur => cur.actorId == dbHero.hid); // 阵容里是否有这个武将
|
||||
let hs = heroScores.find(cur => cur.hid == dbHero.hid); // 这个武将是否有这个得分
|
||||
@@ -213,7 +215,10 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, roleId: string, pos
|
||||
let heroInfo = new PvpHeroInfo();
|
||||
heroInfo.setHeroInfo(dbHero);
|
||||
// heroInfo.setOutIndex(h.order);
|
||||
let { attribute, ce } = getPlayerAttribute(dbHero.lv, dbHero.attr, role.attr);
|
||||
let attr = attrByHid.get(h.actorId);
|
||||
if(!attr) continue;
|
||||
let attribute = attr.getAttributesToString();
|
||||
let ce = attr.calCe();
|
||||
heroInfo.setAttribute(attribute);
|
||||
let enemy = new PvpEnemies(warJson, heroInfo, hs ? hs.score : 0, ce);
|
||||
enemy.setOutIndex(h.order);
|
||||
@@ -372,37 +377,11 @@ export function getRobotAttribute(hid: number, posRatio: number, score: number)
|
||||
let newAttribute = new AttributeCal();
|
||||
newAttribute.setLv(difficultRatio.enemyLv);
|
||||
newAttribute.setByMap(dicHero.baseAbilityArr, difficultRatio.value / 10000 * posRatio);
|
||||
let attrArr = newAttribute.getReduceAttributesToString();
|
||||
let newCe = newAttribute.calCelAndReduce();
|
||||
let attrArr = newAttribute.getAttributesToString();
|
||||
let newCe = newAttribute.calCe();
|
||||
return { attribute: attrArr, ce: newCe, lv: difficultRatio.enemyLv };
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据玩家数据获取到他的属性
|
||||
* @param ceAttr hero表的ceAttr
|
||||
* @param globalCeAttr role表中的globalCeAttr
|
||||
*/
|
||||
export function getPlayerAttribute(lv: number, heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) {
|
||||
let newAttribute = new AttributeCal();
|
||||
newAttribute.setLv(lv);
|
||||
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
||||
let attribute = newAttribute.getReduceAttributesToString();
|
||||
let ce = newAttribute.calCelAndReduce();
|
||||
return { attribute, ce };
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据玩家数据获取到他的主属性
|
||||
* @param ceAttr
|
||||
* @param globalCeAttr
|
||||
*/
|
||||
export function getPlayerMainAttribute(heroAttrs: CeAttrData[], roleAttrs: CeAttrDataRole[]) {
|
||||
let newAttribute = new AttributeCal();
|
||||
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
||||
let mainAttributes = newAttribute.getReduceMainAttributes();
|
||||
return mainAttributes;
|
||||
}
|
||||
|
||||
// 获取我方战报记录
|
||||
export async function generMyRecInfo(pvpDefense: PvpDefenseType, role: RoleType, isSuccess: boolean, pos: number, myHeroes: pvpEndParamInter[]) {
|
||||
let { attack, defense, heroScores, winStreakNum, hisWinStreakNum = 0, score, hisScore } = pvpDefense;
|
||||
|
||||
@@ -243,13 +243,13 @@ export class Rank {
|
||||
if (!role) {
|
||||
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true);
|
||||
}
|
||||
let param = new RankParam(role, true);
|
||||
let param = new RankParam(role);
|
||||
await this.setUserInfo(infoKey, { roleId }, param);
|
||||
} else if (infoKey == REDIS_KEY.GUILD_INFO) {
|
||||
if (!guild) {
|
||||
guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK)
|
||||
}
|
||||
let param = new GuildRankParam(guild, true);
|
||||
let param = new GuildRankParam(guild);
|
||||
await this.setUserInfo(infoKey, { guildCode }, param);
|
||||
} else if (infoKey == REDIS_KEY.TOP_LINEUP_INFO) {
|
||||
if (!role) {
|
||||
@@ -436,13 +436,13 @@ export class Rank {
|
||||
if (!role) {
|
||||
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true);
|
||||
}
|
||||
param = new RoleRankInfo(role, true);
|
||||
param = new RoleRankInfo(role);
|
||||
param.setInfo(0, { roleId }, score, time);
|
||||
} else {
|
||||
const info = await redisClient().hgetAsync(this.infoKey, roleId);
|
||||
const userInfo = JSON.parse(info);
|
||||
|
||||
param = new RoleRankInfo(userInfo, false);
|
||||
param = new RoleRankInfo(userInfo);
|
||||
param.setInfo(0, { roleId }, score, time);
|
||||
}
|
||||
|
||||
@@ -462,12 +462,12 @@ export class Rank {
|
||||
if (!guild) {
|
||||
guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK);
|
||||
}
|
||||
param = new GuildRankInfo(guild, true);
|
||||
param = new GuildRankInfo(guild);
|
||||
param.setInfo(0, { guildCode }, score, time);
|
||||
} else {
|
||||
const info = await redisClient().hgetAsync(this.infoKey, guildCode);
|
||||
const guildInfo = JSON.parse(info);
|
||||
param = new GuildRankInfo(guildInfo, false);
|
||||
param = new GuildRankInfo(guildInfo);
|
||||
param.setInfo(0, { guildCode }, score, time);
|
||||
}
|
||||
|
||||
@@ -487,12 +487,12 @@ export class Rank {
|
||||
if (!guild) {
|
||||
guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK);
|
||||
}
|
||||
param = new GuildRankInfo(guild, true);
|
||||
param = new GuildRankInfo(guild);
|
||||
param.setInfo2(0, { guildCode }, score, time, active);
|
||||
} else {
|
||||
const info = await redisClient().hgetAsync(this.infoKey, guildCode);
|
||||
const guildInfo = JSON.parse(info);
|
||||
param = new GuildRankInfo(guildInfo, false);
|
||||
param = new GuildRankInfo(guildInfo);
|
||||
param.setInfo2(0, { guildCode }, score, time, active);
|
||||
}
|
||||
|
||||
@@ -512,13 +512,13 @@ export class Rank {
|
||||
if (!role) {
|
||||
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true);
|
||||
}
|
||||
param = new RoleRankInfo(role, true);
|
||||
param = new RoleRankInfo(role);
|
||||
param.setInfo(0, { roleId, hid }, score, time);
|
||||
} else {
|
||||
const info = await redisClient().hgetAsync(this.infoKey, roleId);
|
||||
const userInfo = JSON.parse(info);
|
||||
|
||||
param = new RoleRankInfo(userInfo, false);
|
||||
param = new RoleRankInfo(userInfo);
|
||||
param.setInfo(0, { roleId, hid }, score, time);
|
||||
}
|
||||
|
||||
@@ -710,14 +710,14 @@ export class Rank {
|
||||
if (nowSeconds() - userInfo.updatedAt > 2 * 30 * 24 * 60 * 60) {
|
||||
continue;
|
||||
}
|
||||
param = new RoleRankInfo(userInfo, false);
|
||||
param = new RoleRankInfo(userInfo);
|
||||
param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]);
|
||||
} else if (this.infoKey == REDIS_KEY.GUILD_INFO) {
|
||||
if(this.key == REDIS_KEY.GUILD_LV_RANK) {
|
||||
param = new GuildRankInfo(userInfo, false);
|
||||
param = new GuildRankInfo(userInfo);
|
||||
param.setInfo2(Math.floor(ii / 2) + 1, myId, scores[0], scores[1], scores[2]);
|
||||
} else {
|
||||
param = new GuildRankInfo(userInfo, false);
|
||||
param = new GuildRankInfo(userInfo);
|
||||
param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]);
|
||||
}
|
||||
}
|
||||
@@ -759,14 +759,14 @@ export class Rank {
|
||||
if (nowSeconds() - userInfo.updatedAt > 2 * 30 * 24 * 60 * 60) {
|
||||
continue;
|
||||
}
|
||||
param = new RoleRankInfo(userInfo, false);
|
||||
param = new RoleRankInfo(userInfo);
|
||||
param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]);
|
||||
} else if (this.infoKey == REDIS_KEY.GUILD_INFO) {
|
||||
if(this.key == REDIS_KEY.GUILD_LV_RANK) {
|
||||
param = new GuildRankInfo(userInfo, false);
|
||||
param = new GuildRankInfo(userInfo);
|
||||
param.setInfo2(Math.floor(ii / 2) + 1, myId, scores[0], scores[1], scores[2]);
|
||||
} else {
|
||||
param = new GuildRankInfo(userInfo, false);
|
||||
param = new GuildRankInfo(userInfo);
|
||||
param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]);
|
||||
}
|
||||
}
|
||||
@@ -1083,7 +1083,7 @@ export async function getGeneralRank(role: RoleType & { rankReceived: number[] }
|
||||
let r = new Rank(redisKey, { serverId }, false, 1);
|
||||
let ranks = await r.getRankByRange();
|
||||
// if (ranks.length > 0) {
|
||||
let param = new GeneralRankParam(id, ranks[0] || new RoleRankInfo({}, false), general, received);
|
||||
let param = new GeneralRankParam(id, ranks[0] || new RoleRankInfo({}), general, received);
|
||||
result.push({...param, general});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,249 +0,0 @@
|
||||
import { ABI_STAGE, ABI_STAGE_TO_TYPE, ABI_TYPE, ABI_TYPE_MAIN, HERO_CE_RATIO, HERO_SYSTEM_TYPE, SEID_TYPE } from "../../consts";
|
||||
import { HeroModel, HeroUpdate, CeAttrData } from "../../db/Hero";
|
||||
import { CeAttrDataRole, RoleUpdate } from "../../db/Role";
|
||||
import { gameData, getHeroStarByQuality, getHeroWakeByQuality } from "../../pubUtils/data";
|
||||
import { DicRandomEffectPool } from "../../pubUtils/dictionary/DicRandomEffectPool";
|
||||
import { DicSe } from "../../pubUtils/dictionary/DicSe";
|
||||
import { deepCopy } from "../../pubUtils/util";
|
||||
import { AttributeCal } from "../../domain/roleField/attribute";
|
||||
|
||||
export class CalRoleCe {
|
||||
private roleInfo: RoleUpdate;
|
||||
private roleCeWithAttr: Map<ABI_TYPE, CeAttrDataRole> = new Map();
|
||||
|
||||
constructor(roleInfo?: RoleUpdate) {
|
||||
this.roleInfo = roleInfo;
|
||||
}
|
||||
|
||||
public cal(type: HERO_SYSTEM_TYPE) {
|
||||
switch (type) {
|
||||
case HERO_SYSTEM_TYPE.INIT:
|
||||
this.calTitleAbility();
|
||||
this.calTeraphMainAttr();
|
||||
break;
|
||||
}
|
||||
return this.getRoleAttr();
|
||||
}
|
||||
|
||||
private calTitleAbility() {
|
||||
let { title } = this.roleInfo;
|
||||
|
||||
let dicTitle = gameData.title.get(title)||{ mainAttrValue: new Map(), assiAttrValue: new Map() };
|
||||
|
||||
for (let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) {
|
||||
if (dicTitle.mainAttrValue.has(i)) {
|
||||
let fixUp = dicTitle.mainAttrValue.get(i) || 0;
|
||||
this.getSingleAttrObj(i).updateAttr({ inc: { fixUp } });
|
||||
}
|
||||
if (dicTitle.assiAttrValue.has(i)) {
|
||||
let fixUp = dicTitle.assiAttrValue.get(i) || 0;
|
||||
this.getSingleAttrObj(i).updateAttr({ inc: { fixUp } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private calTeraphMainAttr(id?: number) {
|
||||
let { teraphs = [] } = this.roleInfo;
|
||||
for(let teraph of teraphs) {
|
||||
if(id == undefined || teraph.id == id) {
|
||||
for(let [attrId, val] of teraph.attr) {
|
||||
this.getSingleAttrObj(attrId).updateAttr({ inc: { fixUp: val } });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取一个CeAttrData对象,没有就新建
|
||||
public getSingleAttrObj(attrId: ABI_TYPE) {
|
||||
if(!this.roleCeWithAttr.has(attrId)) {
|
||||
let calSingleAttr = new CeAttrDataRole(attrId);
|
||||
this.roleCeWithAttr.set(attrId, calSingleAttr);
|
||||
}
|
||||
return this.roleCeWithAttr.get(attrId);
|
||||
}
|
||||
|
||||
private getRoleAttr() {
|
||||
let attr: CeAttrDataRole[] = [];
|
||||
this.roleCeWithAttr.forEach(value => {
|
||||
if(value.ratioUp > 0 || value.fixUp > 0) {
|
||||
attr.push(value);
|
||||
}
|
||||
});
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
|
||||
export class CalHeroCe {
|
||||
private hid: number;
|
||||
private heroInfo: HeroUpdate;
|
||||
private heroCeWithAttr: Map<ABI_TYPE, CeAttrData> = new Map();
|
||||
|
||||
constructor(hid: number, heroInfo?: HeroUpdate) {
|
||||
this.hid = hid;
|
||||
if(heroInfo) this.heroInfo = heroInfo;
|
||||
}
|
||||
|
||||
public async setHeroInfoByHid(roleId: string) {
|
||||
let hero = await HeroModel.findByHidAndRole(this.hid, roleId);
|
||||
this.heroInfo = hero;
|
||||
}
|
||||
|
||||
// 主要接口
|
||||
public cal(type: HERO_SYSTEM_TYPE) {
|
||||
switch (type) {
|
||||
case HERO_SYSTEM_TYPE.INIT:
|
||||
case HERO_SYSTEM_TYPE.REBIRTH:
|
||||
this.calBaseAbility();
|
||||
this.calSkinSeid();
|
||||
this.calJobAbility();
|
||||
break;
|
||||
}
|
||||
return this.getHeroAttr()
|
||||
}
|
||||
|
||||
// 计算基础属性
|
||||
private calBaseAbility() {
|
||||
let { star, starStage, quality, colorStar, colorStarStage, lv, skinId } = this.heroInfo;
|
||||
const dicHero = gameData.hero.get(skinId);
|
||||
if(!dicHero) {
|
||||
console.error(`not found hero: ${skinId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
for (let stage = ABI_STAGE.START + 1; stage <= ABI_STAGE.END; stage++) {
|
||||
let attrId = ABI_STAGE_TO_TYPE.get(stage);
|
||||
|
||||
const isWake = colorStar > 0; // 是否觉醒,只要激活了觉醒,彩星就会 > 1
|
||||
// console.log('*isUpstar', isUpStar, originStar, star, originColorStar, colorStar)
|
||||
|
||||
const dicStar = isWake ? getHeroWakeByQuality(dicHero.jobClass, dicHero.quality, colorStarStage < stage? colorStar - 1: colorStar) : getHeroStarByQuality(dicHero.jobClass, quality, starStage < stage? star - 1: star); // 星级表
|
||||
|
||||
let heroAttr = dicHero.baseAbilityArr.get(attrId); // 武将表hp等
|
||||
let heroUpAttr = dicHero.baseAbilityUpArr.get(attrId); // 武将表hp_up等
|
||||
let starUp = 0; // 星级成长
|
||||
if (!!dicStar && !!dicStar.ceAttr) {
|
||||
starUp = dicStar.ceAttr.get(stage);
|
||||
}
|
||||
let base = heroAttr + lv * (heroUpAttr + starUp);
|
||||
this.getSingleAttrObj(attrId).updateAttr({ set: { base } });
|
||||
};
|
||||
}
|
||||
|
||||
// 计算职业属性
|
||||
private calJobAbility() {
|
||||
let { job, jobStage } = this.heroInfo;
|
||||
|
||||
const dicJob = gameData.job.get(job);
|
||||
for(let i = 1; i <= dicJob.maxStage; i++) {
|
||||
if(jobStage >= i) {
|
||||
let { id, attr } = dicJob.ceAttr.get(i);
|
||||
this.getSingleAttrObj(id).updateAttr({ inc: { fixUp: attr } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 计算皮肤属性
|
||||
private calSkinSeid() {
|
||||
let { skinId, star: _star, colorStar: _colorStar } = this.heroInfo;
|
||||
|
||||
let seidList = new Map<number, number>(); // type => seid
|
||||
let dicHero = gameData.hero.get(skinId);
|
||||
let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(dicHero.skill);
|
||||
for (let { star, value, type } of starSeidArr) {
|
||||
if (_star >= star) {
|
||||
seidList.set(type, value);
|
||||
}
|
||||
}
|
||||
for (let { star, value, type } of colorStarSeidArr) {
|
||||
if (_colorStar >= star) {
|
||||
seidList.set(type, value);
|
||||
}
|
||||
}
|
||||
let list: number[] = [];
|
||||
for(let [_type, value] of seidList) list.push(value);
|
||||
addSeidEffect.bind(this, list);
|
||||
}
|
||||
|
||||
public getHeroAttr() {
|
||||
let attr: CeAttrData[] = [];
|
||||
this.heroCeWithAttr.forEach(value => {
|
||||
if(value.base > 0 || value.equipUp > 0 || value.fixUp > 0 || value.ratioUp > 0) {
|
||||
attr.push(value);
|
||||
}
|
||||
});
|
||||
return attr;
|
||||
}
|
||||
|
||||
// 获取一个CeAttrData对象,没有就新建
|
||||
public getSingleAttrObj(attrId: ABI_TYPE) {
|
||||
if(!this.heroCeWithAttr.has(attrId)) {
|
||||
let calSingleAttr = new CeAttrData(attrId);
|
||||
this.heroCeWithAttr.set(attrId, calSingleAttr);
|
||||
}
|
||||
return this.heroCeWithAttr.get(attrId);
|
||||
}
|
||||
|
||||
public getCalculatedCe(roleAttr: CeAttrDataRole[]) {
|
||||
let attrCal = new AttributeCal();
|
||||
attrCal.setLv(this.heroInfo.lv);
|
||||
attrCal.setByDbData(roleAttr, this.getHeroAttr());
|
||||
return attrCal.calCe();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加技能增加的被动属性
|
||||
function addSeidEffect(this: CalRoleCe|CalHeroCe, seidList: number[]) {
|
||||
// console.log('******addSeidEffect',this, seidList)
|
||||
|
||||
// console.log('addSeidList', addSeidList.join())
|
||||
// console.log('removeSeidList', removeSeidList.join())
|
||||
let effectList: DicSe[] = []; // any: dic_zyz_se表内容
|
||||
|
||||
for (let ii = 0; ii < seidList.length; ii += 2) {
|
||||
let seid = seidList[ii];
|
||||
let rand = seidList[ii + 1] || 0;
|
||||
let dicSeid: DicSe | DicRandomEffectPool = gameData.se.get(seid);
|
||||
if (!dicSeid) dicSeid = gameData.randomEffectPool.get(seid);
|
||||
if (dicSeid && dicSeid.id > 0) {
|
||||
addSeid(effectList, dicSeid.id, rand, dicSeid.gainValueArr)
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('effectList', JSON.stringify(effectList));
|
||||
for (let { type, gainValueArr: [ability, value] } of effectList) {
|
||||
if (type == SEID_TYPE.TYPE101) { // 加值
|
||||
this.getSingleAttrObj(ability).updateAttr({ inc: { fixUp: value } });
|
||||
} else if (type == SEID_TYPE.TYPE103) { // 主属性加百分比
|
||||
if(ABI_TYPE_MAIN.includes(ability)) {
|
||||
this.getSingleAttrObj(ability).updateAttr({ inc: {ratioUp: value / 1000} });
|
||||
}
|
||||
} else if (type == SEID_TYPE.TYPE104) { // 次级属性加百分比
|
||||
if(!ABI_TYPE_MAIN.includes(ability)) {
|
||||
this.getSingleAttrObj(ability).updateAttr({ inc: { fixUp: value * 100 * HERO_CE_RATIO } });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 获取dic_zyz_se内容
|
||||
function addSeid(effectList: (DicSe | DicRandomEffectPool)[], seidId: number, rand: number, seidValue: number[] = []) {
|
||||
let curSeid: DicSe | DicRandomEffectPool = gameData.se.get(seidId);
|
||||
if (!curSeid) curSeid = gameData.randomEffectPool.get(seidId);
|
||||
if (!curSeid) { console.log("seidId not found:" + seidId); return; }
|
||||
if (!seidValue) seidValue = curSeid.gainValueArr;
|
||||
|
||||
if (curSeid.type === SEID_TYPE.TYPE999) {
|
||||
for (let i = 0; i < seidValue.length; i++) {
|
||||
addSeid(effectList, seidValue[i], rand);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let seid: DicSe | DicRandomEffectPool = deepCopy(curSeid);
|
||||
if (curSeid.index > 0) {
|
||||
seid.gainValueArr[curSeid.index - 1] = rand;
|
||||
}
|
||||
effectList.push(seid);
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { ABI_STAGE, ABI_STAGE_TO_TYPE, ABI_TYPE_MAIN, LINEUP_NUM, SEID_TYPE, TAL
|
||||
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Stone, Talent } from "../../db/Hero";
|
||||
import { JewelType } from "../../db/Jewel";
|
||||
import { RoleUpdate, Teraph } from "../../db/Role";
|
||||
import { AttrCell, EquipAttr, HeroAttr, RoleCeType, SchoolAttr } from "../../db/RoleCe";
|
||||
import { AttrCell, Attribute, EquipAttr, HeroAttr, RoleCeType, SchoolAttr } from "../../db/RoleCe";
|
||||
import { TopHero } from "../../domain/dbGeneral";
|
||||
import { AttributeCal } from "../../domain/roleField/attribute";
|
||||
import { gameData, getEquipQualityIdByEquipIdAndPoint, getEquipStarAttrByStage, getEquipStrenthenAttr, getEquipSuitByHero, getFriendShipById, getHeroStarByQuality, getHeroWakeByQuality, getJewelConditionByLvAndSeId, getJobByGradeAndClass, getSchoolRateByStar, getScollByStar, getTeraph } from "../../pubUtils/data";
|
||||
@@ -14,6 +14,7 @@ export class CalCe {
|
||||
originCes: Map<number, number> = new Map(); // hid => ce
|
||||
resultCes: Map<number, number> = new Map(); // hid => ce
|
||||
data: CalCeData;
|
||||
attrsByHid: Map<number, { id: number, val: number, str: string }[]> = new Map();
|
||||
|
||||
constructor(roleId: string) {
|
||||
this.roleId = roleId;
|
||||
@@ -25,35 +26,43 @@ export class CalCe {
|
||||
}
|
||||
|
||||
public getRoleCeTable() {
|
||||
return this.data.getRoleCeTable(this.roleId);
|
||||
let attributes: Attribute[] = [];
|
||||
for(let [hid, attrs] of this.attrsByHid) {
|
||||
attributes.push({ hid, attrs })
|
||||
}
|
||||
return this.data.getRoleCeTable(this.roleId, attributes);
|
||||
}
|
||||
|
||||
public calHeroCe() {
|
||||
let ces = new Map<number, { id: number, val: number }[]>(); // hid => [{attrId, val}]
|
||||
let attrs = new Map<number, { id: number, val: number, str: string }[]>(); // hid => [{attrId, val}]
|
||||
for(let [hid, keys] of this.data.heroAttrsByHid) {
|
||||
let lv = this.data.heroLv.get(hid)||1;
|
||||
for(let key of keys) {
|
||||
let { attrId, mainBase = 0, subBase = 0, job = 0, starUp = 0, connect = 0, favour = 0, talent = 0, equipQuality = 0, equipStrength = 0, equipStar = 0, equipSuit = 0, jewel = 0, stone = 0 } = this.data.heroAttrs.get(key);
|
||||
let { school = 0, teraph = 0, title = 0, scroll = 0, skin = 0 } = this.data.getGlobalAttrById(attrId);
|
||||
let val = 0;
|
||||
if(ABI_TYPE_MAIN.indexOf(attrId)) {
|
||||
// {[hp1 + lv * hp2 + hp3 * ( 1 + hp4 )] * (1 + hp5 ) + [( hp6 + hp7 ) * ( 1 + hp8 )] } * ( 1 + hp9 ) + hp10 + hp11
|
||||
let val = 0, str = '';
|
||||
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
|
||||
// {[hp1 + lv * hp2 + hp3 * ( 1 + hp4 )] * (1 + hp5 ) + [( hp6 + hp7 ) * ( 1 + hp8 )] } * ( 1 + hp9 ) + hp10 + hp11
|
||||
val = ((mainBase + job + lv * starUp + connect * ( 1 + favour )) * ( 1 + school + talent ) + (( equipQuality + equipStrength ) * ( 1 + ( equipStar + equipSuit ))) ) * ( 1 + jewel ) + stone + teraph + title + scroll + skin;
|
||||
str += `{[${mainBase}+${job}+${lv}*${starUp}+${connect}*(1+${favour})]*(1+${school}+${talent})+[(${equipQuality}+${equipStrength})*(1+${equipStar}+${equipSuit})]}*(1+${jewel})+${stone}+${teraph}+${title}+${scroll}+${skin}`;
|
||||
} else {
|
||||
// attr1 + attr2 + attr3 + attr4 + attr5 + attr6 + attr7 + attr8 + attr9
|
||||
// attr1 + attr2 + attr3 + attr4 + attr5 + attr6 + attr7 + attr8 + attr9
|
||||
val = subBase + job + talent + teraph + school + title + jewel + skin + equipStar;
|
||||
str += `${subBase}+${job}+${talent}+${teraph}+${school}+${title}+${jewel}+${skin}+${equipStar}`;
|
||||
}
|
||||
if(!ces.has(hid)) ces.set(hid, []);
|
||||
ces.get(hid).push({ id: attrId, val });
|
||||
if(!attrs.has(hid)) attrs.set(hid, []);
|
||||
attrs.get(hid).push({ id: attrId, val, str });
|
||||
}
|
||||
}
|
||||
let result = new Map<number, number>();
|
||||
for(let [hid, arr] of ces) {
|
||||
for(let [hid, arr] of attrs) {
|
||||
let obj = new AttributeCal();
|
||||
obj.setLv(this.data.roleLv);
|
||||
obj.setByWarJson(arr);
|
||||
let ce = obj.calCe();
|
||||
this.resultCes.set(hid, ce);
|
||||
result.set(hid, ce);
|
||||
this.attrsByHid.set(hid, arr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -102,6 +111,10 @@ export class CalCe {
|
||||
return { topLineup, topLineupCe };
|
||||
}
|
||||
|
||||
// 玩家等级
|
||||
public setRoleLv(lv: number) {
|
||||
this.data.roleLv = lv;
|
||||
}
|
||||
|
||||
// 武将基础&成长
|
||||
public setHeroBase(hid: number, skinId: number) {
|
||||
@@ -475,6 +488,7 @@ export class CalCe {
|
||||
}
|
||||
|
||||
class CalCeData {
|
||||
roleLv: number = 1; // 玩家等级
|
||||
// 全局
|
||||
globalAttrs: Map<number, GlobalMainAttr|GlobalSubAttr> = new Map(); // attrId => GlobalAttr
|
||||
// 武将
|
||||
@@ -549,7 +563,7 @@ class CalCeData {
|
||||
}
|
||||
|
||||
public getHeroAttrsByHid(hid: number) {
|
||||
let keys = this.heroAttrsByHid.get(hid);
|
||||
let keys = this.heroAttrsByHid.get(hid)||[];
|
||||
return keys.map(key => this.heroAttrs.get(key));
|
||||
}
|
||||
|
||||
@@ -573,7 +587,7 @@ class CalCeData {
|
||||
}
|
||||
|
||||
public clearHeroAttrByHid(hid: number, field: string) {
|
||||
let heroAttrs = this.getHeroAttrsByHid(hid);
|
||||
let heroAttrs = this.getHeroAttrsByHid(hid)||[];
|
||||
for(let heroAttr of heroAttrs) {
|
||||
heroAttr[field] = 0;
|
||||
}
|
||||
@@ -656,7 +670,7 @@ class CalCeData {
|
||||
}
|
||||
|
||||
public clearSchoolAttr(hid: number) {
|
||||
let schoolAttrs = this.getSchoolAttrsByHid(hid);
|
||||
let schoolAttrs = this.getSchoolAttrsByHid(hid)||[];
|
||||
for(let schoolAttr of schoolAttrs) {
|
||||
schoolAttr.ce = 0;
|
||||
this.calSchoolAttrsToGlobal(schoolAttr.attrId);
|
||||
@@ -715,7 +729,7 @@ class CalCeData {
|
||||
this.heroObjectId.set(hero.hid, hero._id);
|
||||
}
|
||||
|
||||
public getRoleCeTable(roleId: string) {
|
||||
public getRoleCeTable(roleId: string, attributes: Attribute[]) {
|
||||
let globalAttrs: AttrCell[] = [];
|
||||
for(let [_, globalAttr] of this.globalAttrs) {
|
||||
globalAttrs.push(globalAttr.getGlobalAttr());
|
||||
@@ -751,7 +765,7 @@ class CalCeData {
|
||||
schoolAttrs.push({ hid, attrId, value: ce });
|
||||
}
|
||||
return {
|
||||
roleId, globalAttrs, heroAttrs, equipAttrs, schoolAttrs
|
||||
roleLv: this.roleLv, roleId, globalAttrs, heroAttrs, equipAttrs, schoolAttrs, attributes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ import { SkinModel } from "../../db/Skin";
|
||||
import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../../db/Hero";
|
||||
import { SkinUpdate } from "../../db/Skin";
|
||||
import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { getRandSingleEelm, reduceCe, resResult } from "../../pubUtils/util";
|
||||
import { CreateHeroParam, HeroParam, HeroShowParam } from "../../domain/roleField/hero";
|
||||
import { resResult } from "../../pubUtils/util";
|
||||
import { CreateHeroParam, HeroShowParam } from "../../domain/roleField/hero";
|
||||
import { pinus } from "pinus";
|
||||
import { Rank } from "../rankService";
|
||||
import { checkTaskInCreateHero } from "../task/taskService";
|
||||
import { ItemInter, RewardInter } from "../../pubUtils/interface";
|
||||
import { transPiece } from "./util";
|
||||
import { addItems, combineFigureInfo, unlockFigure, } from "./rewardService";
|
||||
import { addItems, unlockFigure, } from "./rewardService";
|
||||
import { CounterModel } from "../../db/Counter";
|
||||
import { calculateCes } from "../playerCeService";
|
||||
import { RoleUpdate } from "../../db/Role";
|
||||
@@ -63,7 +61,7 @@ import { RoleUpdate } from "../../db/Role";
|
||||
if(initRoleInfos) {
|
||||
roleUpdata = { ...initRoleInfos, ...roleUpdata }
|
||||
}
|
||||
let { heroes } = await calculateCes(HERO_SYSTEM_TYPE.INIT, roleId, serverId, sid, heroInfos, roleUpdata, { heroNum: incHeroNum });
|
||||
let { heroes } = await calculateCes(HERO_SYSTEM_TYPE.INIT, roleId, serverId, sid, heroInfos, roleUpdata, { heroNum: incHeroNum }, { isInitRole: !!initRoleInfos });
|
||||
for(let hero of heroes) {
|
||||
showHeroes.push(new HeroShowParam(hero));
|
||||
resultHeroes.push(hero);
|
||||
|
||||
@@ -24,7 +24,7 @@ import { JewelModel, JewelType, jewelUpdate, RandSe } from '../../db/Jewel';
|
||||
import { updateEplaces } from '../equipService';
|
||||
import { combineItems, getCoinEventProperties, getGoldEventProperties, sortItems } from './util';
|
||||
import { nowSeconds } from '../../pubUtils/timeUtil';
|
||||
import { calculateCeWithHero, calculateWithRole } from '../playerCeService';
|
||||
import { calculateCeWithHero, calculateCeWithRole } from '../playerCeService';
|
||||
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@ export async function addSkin(roleId: string, roleName: string, sid: string, ski
|
||||
if(skin.hid && !hero) hero = await HeroModel.findByHidAndRole(skin.hid, roleId);
|
||||
let condition = { type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: skinId };
|
||||
await unlockFigure(sid, roleId, [condition]); // 解锁头像
|
||||
await calculateWithRole(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, hero.serverId, sid, {}, { skinId }); // 全局加成
|
||||
await calculateCeWithRole(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, hero.serverId, sid, {}, { skinId }); // 全局加成
|
||||
|
||||
if (hero) { // 有武将的,将皮肤链接到武将上
|
||||
let curSkin = hero.skins.find(cur => cur.id == skinId);
|
||||
|
||||
@@ -22,8 +22,7 @@ import { getZeroPoint } from "../../pubUtils/timeUtil";
|
||||
import { resResult } from "../../pubUtils/util";
|
||||
import { getActivities, getActivitiesByType, getActivityByServerId } from "../activity/activityService";
|
||||
import { getRoleCreateTime, getRoleOnlineInfo, getServerCreateTime } from "../redisService";
|
||||
import { getEquipById, getJewelByEquip } from "../equipService";
|
||||
import { isRandSeUnLock } from "../../pubUtils/playerCe";
|
||||
import { getEquipById, getJewelByEquip, isRandSeUnLock } from "../equipService";
|
||||
|
||||
export class CheckTask {
|
||||
serverId: number; // 区id
|
||||
|
||||
@@ -306,7 +306,7 @@ export default class GMUsers extends Service {
|
||||
let list = heroes.map(cur => {
|
||||
let cal = new AttributeCal();
|
||||
cal.setByDbData(roleMap.get(cur.roleId), cur.attr);
|
||||
return {...cur, calculatedAttr: cal.getReduceAttributesToArr(), env: ctx.app.config.realEnv}
|
||||
return {...cur, calculatedAttr: cal.getAttributesToArr(), env: ctx.app.config.realEnv}
|
||||
})
|
||||
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total })
|
||||
|
||||
@@ -31,6 +31,7 @@ export enum HERO_SYSTEM_TYPE {
|
||||
JEWEL_QUENCH = 28, // 天晶石淬炼
|
||||
REBIRTH = 29, // 武将重生
|
||||
TALENT = 30, // 天赋
|
||||
ROLE_LV = 31, // 玩家等级
|
||||
};
|
||||
|
||||
// 武将上限
|
||||
@@ -47,10 +48,8 @@ export const JOB_TYPE = {
|
||||
MAGIC: 2
|
||||
}
|
||||
|
||||
// 武将战力放大系数
|
||||
export const HERO_CE_RATIO = 100;
|
||||
// 次级属性放大系数
|
||||
export const HERO_SUB_ATTR_RATIO = 1000 * 100;
|
||||
export const HERO_SUB_ATTR_RATIO = 1000;
|
||||
|
||||
export const HERO_INITIAL_QUALITY = {
|
||||
BLUE: 1,
|
||||
|
||||
@@ -14,14 +14,14 @@ export enum ROLE_SELECT {
|
||||
COM_BATTLE = 'lv head frame spine heads frames spines topLineupCe',
|
||||
GET_HEADS = 'heads head frames frame spines spine',
|
||||
// 排行榜基础数据
|
||||
RANK = 'roleId roleName lv vLv head frame spine heads frames spines title guildName ce isReducedCe topLineup towerLv towerUpTime topLineupCe heroNum updatedAt heroNumUpdatedAt dungeonWarId dungeonUpdatedAt dungeonHeroes mainWarId mainUpdatedAt mainEliteWarId mainEliteUpdatedAt showLineup hasGuild',
|
||||
RANK = 'roleId roleName lv vLv head frame spine heads frames spines title guildName ce topLineup towerLv towerUpTime topLineupCe heroNum updatedAt heroNumUpdatedAt dungeonWarId dungeonUpdatedAt dungeonHeroes mainWarId mainUpdatedAt mainEliteWarId mainEliteUpdatedAt showLineup hasGuild',
|
||||
};
|
||||
|
||||
export enum HERO_SELECT {
|
||||
ENTRY = '-_id -attr',
|
||||
HERO_DETAIL = 'roleId roleName hid hName ce isReducedCe lv star colorStar quality job skins attr ePlace skinId',
|
||||
HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins attr ePlace skinId',
|
||||
// 排行榜中lineup字段
|
||||
RANK_LINEUP = 'seqId roleId hid star colorStar lv quality job ce isReducedCe updatedAt skinId'
|
||||
RANK_LINEUP = 'seqId roleId hid star colorStar lv quality job ce updatedAt skinId'
|
||||
}
|
||||
|
||||
export enum EQUIP_SELECT {
|
||||
|
||||
@@ -3,7 +3,6 @@ import { index, getModelForClass, prop, DocumentType, Ref, mongoose } from '@typ
|
||||
import Role, { RoleType } from './Role';
|
||||
import { GUILD_STRUCTURE, GUILD_STATUS, GUILD_PER_PAGE, GUILD_SELECT, REDIS_KEY, SHOP_REFRESH_TYPE } from '../consts';
|
||||
import { getZeroPoint, getZeroPointD, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { reduceCe } from '../pubUtils/util';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { SearchGuildParam } from '../domain/backEndField/search';
|
||||
|
||||
@@ -77,12 +76,9 @@ export default class Guild extends BaseModel {
|
||||
@prop({ required: true, default: new Date(), select: false })
|
||||
refTimeDaily: Date;
|
||||
|
||||
@prop({ required: true, default: 0, get: (val:number) => reduceCe(val), set: (val: number) => val })
|
||||
@prop({ required: true, default: 0 })
|
||||
guildCe: number; // 总战力
|
||||
|
||||
@prop({ required: false, set: (val: boolean) => val, get: () => true })
|
||||
isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true
|
||||
|
||||
@prop({ required: true, type: String, default: [], select: false })
|
||||
members: string[]; // 军团成员的roleId,用于增加战力的时候加入总战力
|
||||
|
||||
|
||||
@@ -1,56 +1,12 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, Ref, mongoose, DocumentType } from '@typegoose/typegoose';
|
||||
// import Equip, { } from './Equip';
|
||||
import { CounterModel } from './Counter';
|
||||
import { COUNTER, DEFAULT_HERO_LV, HERO_CE_RATIO } from '../consts';
|
||||
import { reduceCe } from '../pubUtils/util';
|
||||
import { DEFAULT_HERO_LV } from '../consts';
|
||||
import Skin, { SkinUpdate } from './Skin';
|
||||
import { SearchHeroParam } from '../domain/backEndField/search';
|
||||
import { Reward } from '../domain/battleField/pvp';
|
||||
import { gameData, getHeroExpByLv, getHeroInitTalent } from '../pubUtils/data';
|
||||
|
||||
type CeAttrUpdate = Partial<CeAttrData>;
|
||||
export class CeAttrData {
|
||||
@prop({ required: true })
|
||||
id: number = 0;
|
||||
@prop({ required: true })
|
||||
base: number = 0;
|
||||
@prop({ required: true })
|
||||
ratioUp: number = 0;
|
||||
@prop({ required: true })
|
||||
fixUp: number = 0;
|
||||
@prop({ required: true })
|
||||
equipUp: number = 0;
|
||||
|
||||
constructor(id: number) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public copyFromHero(data: CeAttrData) {
|
||||
this.base = data.base;
|
||||
this.ratioUp = data.ratioUp;
|
||||
this.fixUp = data.fixUp;
|
||||
this.equipUp = data.equipUp;
|
||||
}
|
||||
|
||||
public updateAttr(update: { inc?: CeAttrUpdate, set?: CeAttrUpdate }) {
|
||||
if(update.inc) {
|
||||
let { base, equipUp, fixUp, ratioUp } = update.inc;
|
||||
if(base != undefined) this.base += base * HERO_CE_RATIO;
|
||||
if(equipUp != undefined) this.equipUp += equipUp * HERO_CE_RATIO;
|
||||
if(fixUp != undefined) this.fixUp += fixUp * HERO_CE_RATIO;
|
||||
if(ratioUp != undefined) this.ratioUp += ratioUp;
|
||||
}
|
||||
if(update.set) {
|
||||
let { base, equipUp, fixUp, ratioUp } = update.set;
|
||||
if(base != undefined) this.base = base * HERO_CE_RATIO;
|
||||
if(equipUp != undefined) this.equipUp = equipUp * HERO_CE_RATIO;
|
||||
if(fixUp != undefined) this.fixUp = fixUp * HERO_CE_RATIO;
|
||||
if(ratioUp != undefined) this.ratioUp = ratioUp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 英雄表
|
||||
*/
|
||||
@@ -162,12 +118,8 @@ export default class Hero extends BaseModel {
|
||||
exp: number; // 经验值
|
||||
@prop({ required: true, default: 1 })
|
||||
lv: number; // 武将等级
|
||||
@prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) })
|
||||
@prop({ required: true, default: 0 })
|
||||
ce: number; // 武将战力
|
||||
@prop({ required: false, set: (val: boolean) => val, get: () => true })
|
||||
isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true
|
||||
@prop({ required: true, type: CeAttrData, default: [], _id: false })
|
||||
attr: CeAttrData[]; // 影响战力的属性
|
||||
|
||||
@prop({ required: true, default: 1 })
|
||||
star: number; // 星级
|
||||
|
||||
@@ -1,42 +1,14 @@
|
||||
import { ROLE_TERAPH, ROLE_SELECT, ABI_TYPE, HERO_CE_RATIO, BLOCK_TYPE } from './../consts';
|
||||
import { ROLE_TERAPH, ROLE_SELECT, ABI_TYPE, BLOCK_TYPE } from './../consts';
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, Ref, mongoose } from '@typegoose/typegoose';
|
||||
import User from './User';
|
||||
import { shouldRefresh, reduceCe } from '../pubUtils/util';
|
||||
import { shouldRefresh } from '../pubUtils/util';
|
||||
import { nowSeconds, getTimeFunD } from '../pubUtils/timeUtil';
|
||||
import { Figure } from '../domain/dbGeneral';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
import Hero from './Hero';
|
||||
import { SearchRoleParam } from '../domain/backEndField/search';
|
||||
|
||||
type CeAttrUpdate = Partial<CeAttrDataRole>;
|
||||
// role表属性格式
|
||||
export class CeAttrDataRole {
|
||||
@prop({ required: true })
|
||||
id: number = 0;
|
||||
@prop({ required: true })
|
||||
ratioUp: number = 0;
|
||||
@prop({ required: true })
|
||||
fixUp: number = 0;
|
||||
|
||||
constructor(id: number) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public updateAttr(update: { inc?: CeAttrUpdate, set?: CeAttrUpdate }) {
|
||||
if(update.inc) {
|
||||
let { fixUp, ratioUp } = update.inc;
|
||||
if(fixUp != undefined) this.fixUp += fixUp * HERO_CE_RATIO;
|
||||
if(ratioUp != undefined) this.ratioUp += ratioUp;
|
||||
}
|
||||
if(update.set) {
|
||||
let { fixUp, ratioUp } = update.set;
|
||||
if(fixUp != undefined) this.fixUp = fixUp * HERO_CE_RATIO;
|
||||
if(ratioUp != undefined) this.ratioUp = ratioUp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class TopHero {
|
||||
@prop({ required: true })
|
||||
hid: number; // 武将id
|
||||
@@ -185,16 +157,12 @@ export default class Role extends BaseModel {
|
||||
exp: number; // 经验值
|
||||
@prop({ required: true, default: 1 })
|
||||
lv: number; // 主公等级
|
||||
@prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) })
|
||||
@prop({ required: true, default: 0 })
|
||||
ce: number; // 总战力
|
||||
@prop({ required: true, type: CeAttrDataRole, default: [], _id: false })
|
||||
attr: CeAttrDataRole[]; // 总战力
|
||||
@prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) })
|
||||
@prop({ required: true, default: 0 })
|
||||
topLineupCe: number; // 最强x人战力
|
||||
@prop({ required: true, type: TopHero, default: [], _id: false })
|
||||
topLineup: Array<TopHero>; // 总战力
|
||||
@prop({ required: false, set: (val: boolean) => val, get: () => true })
|
||||
isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true
|
||||
|
||||
@prop({ required: true, default: 100 })
|
||||
gold: number; // 总金币
|
||||
|
||||
@@ -45,7 +45,7 @@ export class SchoolAttr {
|
||||
}
|
||||
|
||||
// 名将谱加成
|
||||
class ScrollAttr {
|
||||
export class ScrollAttr {
|
||||
@prop({ required: true })
|
||||
hid: number; // 武将id
|
||||
@prop({ required: true })
|
||||
@@ -54,6 +54,24 @@ class ScrollAttr {
|
||||
value: number; // 百家学宫有多个武将,单独拎出来方便计算,计算之后结果存到globaAttrs的global1
|
||||
}
|
||||
|
||||
|
||||
// 属性结果
|
||||
export class SingleAttribute {
|
||||
@prop({ required: true })
|
||||
id: number; // 属性id
|
||||
@prop({ required: true })
|
||||
val: number; // 值
|
||||
@prop({ required: true })
|
||||
str: string; // 公式
|
||||
}
|
||||
|
||||
export class Attribute {
|
||||
@prop({ required: true })
|
||||
hid: number;
|
||||
@prop({ required: true, type: SingleAttribute, _id: false })
|
||||
attrs: SingleAttribute[]; // 属性id
|
||||
}
|
||||
|
||||
/**
|
||||
* 属性表
|
||||
*/
|
||||
@@ -66,6 +84,9 @@ export default class RoleCe extends BaseModel {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色 id
|
||||
|
||||
@prop({ required: true })
|
||||
roleLv: number; // 玩家等级
|
||||
|
||||
@prop({ required: true, type: AttrCell, _id: false })
|
||||
globalAttrs: AttrCell[]
|
||||
|
||||
@@ -81,6 +102,9 @@ export default class RoleCe extends BaseModel {
|
||||
@prop({ required: true, type: ScrollAttr, _id: false })
|
||||
scrollAttrs: ScrollAttr[];
|
||||
|
||||
@prop({ required: true, type: Attribute, _id: false })
|
||||
attributes: Attribute[];
|
||||
|
||||
public static async findByRoleId(roleId: string) {
|
||||
let result: RoleCeType = await RoleCeModel.findOne({ roleId }).lean();
|
||||
return result;
|
||||
|
||||
@@ -65,10 +65,15 @@ export default class User extends BaseModel {
|
||||
guestTime: number; // 游客体验时间
|
||||
|
||||
// 防沉迷相关
|
||||
@prop({ required: false, default: false })
|
||||
@prop({ required: false, default: true })
|
||||
hasAuthenticated: boolean; // 是否是已认证
|
||||
@prop({ required: false })
|
||||
@prop({ required: false, default: '1990-01-01' })
|
||||
birthday: string; // 生日年月
|
||||
// 暂时不使用内部防沉迷
|
||||
// @prop({ required: false, default: false })
|
||||
// hasAuthenticated: boolean; // 是否是已认证
|
||||
// @prop({ required: false })
|
||||
// birthday: string; // 生日年月
|
||||
@prop({ required: false })
|
||||
pi: string; // 已通过实名认证用户唯一标识
|
||||
@prop({ required: false, default: 0 })
|
||||
|
||||
@@ -4,7 +4,7 @@ import { DungeonFirstType } from '../../db/DungeonFirst';
|
||||
class DungeonUserInfo extends RankParam {
|
||||
roleId: string;
|
||||
constructor(roleId: string, userInfo: RankParam) {
|
||||
super(userInfo, false);
|
||||
super(userInfo);
|
||||
this.roleId = roleId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { EXTERIOR } from "../pubUtils/dicParam";
|
||||
import { WoodenHorse } from "./battleField/guildActivity";
|
||||
import { RoleUpdate, RoleType } from "../db/Role";
|
||||
import { reduceCe } from "../pubUtils/util";
|
||||
import { GuildUpdateParam } from "../db/Guild";
|
||||
import { HeroUpdate, } from "../db/Hero";
|
||||
import { getSeconds } from "../pubUtils/timeUtil";
|
||||
@@ -38,7 +37,7 @@ export class RankParam {
|
||||
@prop({ required: true })
|
||||
updatedAt?: number = 0;
|
||||
|
||||
constructor(role: RoleUpdate|RankParam, fromDb: boolean) {
|
||||
constructor(role: RoleUpdate|RankParam) {
|
||||
if(role.roleName) this.roleName = role.roleName;
|
||||
if(role.lv) this.lv = role.lv;
|
||||
if(role.head) this.head = role.head;
|
||||
@@ -46,13 +45,7 @@ export class RankParam {
|
||||
if(role.spine) this.spine = role.spine;
|
||||
if(role.title) this.title = role.title;
|
||||
if(role.guildName) this.guildName = role.guildName||"";
|
||||
if(role.ce) {
|
||||
if(fromDb && !(<RoleUpdate>role).isReducedCe) {
|
||||
this.ce = reduceCe(role.ce);
|
||||
} else {
|
||||
this.ce = role.ce;
|
||||
}
|
||||
}
|
||||
if(role.ce) this.ce = role.ce;
|
||||
if(role.updatedAt) {
|
||||
if(typeof role.updatedAt == 'number') {
|
||||
this.updatedAt = role.updatedAt;
|
||||
@@ -178,27 +171,14 @@ export class GuildRankParam {
|
||||
@prop({ required: true })
|
||||
guildCe: number;
|
||||
|
||||
constructor(guild: GuildUpdateParam, fromDb: boolean) {
|
||||
constructor(guild: GuildUpdateParam) {
|
||||
this.icon = guild.icon;
|
||||
this.name = guild.name;
|
||||
this.lv = guild.lv;
|
||||
let leader = <RoleType>guild.leader;
|
||||
let _leader = new GuildLeader(leader);
|
||||
this.leader = _leader;
|
||||
// console.log('*****', guild.isReducedCe, guild.guildCe, reduceCe(guild.guildCe))
|
||||
if(guild.isReducedCe) {
|
||||
this.guildCe = guild.guildCe;
|
||||
} else {
|
||||
this.guildCe = reduceCe(guild.guildCe);
|
||||
}
|
||||
|
||||
if(fromDb && !(<GuildUpdateParam>guild).isReducedCe) {
|
||||
this.guildCe = reduceCe(guild.guildCe);
|
||||
} else {
|
||||
this.guildCe = guild.guildCe;
|
||||
}
|
||||
|
||||
|
||||
this.guildCe = guild.guildCe;
|
||||
this.memberCnt = guild.memberCnt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { HERO_CE_RATIO, getAtrrNameById, ABI_TYPE_MAIN } from '../../consts';
|
||||
import { CeAttrDataRole } from '../../db/Role';
|
||||
import { CeAttrData } from '../../db/Hero';
|
||||
import { getAtrrNameById, ABI_TYPE_MAIN } from '../../consts';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
import { decodeArrayListStr, reduceCe } from '../../pubUtils/util';
|
||||
import { decodeArrayListStr } from '../../pubUtils/util';
|
||||
import { ATTRIBUTE } from '../../pubUtils/dicParam';
|
||||
|
||||
export class AttributeCal {
|
||||
@@ -14,34 +12,12 @@ export class AttributeCal {
|
||||
this.lv = lv;
|
||||
}
|
||||
|
||||
public setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) {
|
||||
for(let { id, fixUp: roleFix, ratioUp: roleRatio } of roleAttrs) {
|
||||
let heroAttr = heroAttrs.find(heroAttr => heroAttr.id == id);
|
||||
if(heroAttr) {
|
||||
let { fixUp: heroFix, base: heroBase, ratioUp: heroRatio, equipUp: heroEquip } = heroAttr;
|
||||
let value = this.calAttrValue(roleFix, roleRatio, heroBase, heroFix, heroRatio, heroEquip);
|
||||
this.attrs.set(id, value);
|
||||
} else {
|
||||
let value = this.calAttrValue(roleFix, roleRatio, 0, 0, 0, 0);
|
||||
this.attrs.set(id, value);
|
||||
}
|
||||
}
|
||||
|
||||
for(let { id, base: heroBase, fixUp: heroFix, ratioUp: heroRatio, equipUp: heroEquip } of heroAttrs) {
|
||||
let roleAttr = roleAttrs.find(roleAttr => roleAttr.id == id);
|
||||
if(!roleAttr) {
|
||||
let value = this.calAttrValue(0, 0, heroBase, heroFix, heroRatio, heroEquip);
|
||||
this.attrs.set(id, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setByWarJson(attributes: {id: number, val: number}[], ratio: number = 1) {
|
||||
for(let {id, val} of attributes) {
|
||||
if(ABI_TYPE_MAIN.includes(id)) {
|
||||
this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO));
|
||||
this.attrs.set(id, Math.floor(val * ratio));
|
||||
} else {
|
||||
this.attrs.set(id, Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO));
|
||||
this.attrs.set(id, Math.floor(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,58 +25,42 @@ export class AttributeCal {
|
||||
public setByMap( attributes: Map<number, number>, ratio: number = 1 ) {
|
||||
for(let [id, val] of attributes) {
|
||||
if(ABI_TYPE_MAIN.includes(id)) {
|
||||
this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO));
|
||||
this.attrs.set(id, Math.floor(val * ratio));
|
||||
} else {
|
||||
this.attrs.set(id, Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO));
|
||||
this.attrs.set(id, Math.floor(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private calAttrValue(roleFix: number = 0, roleRatio: number = 0, heroBase: number = 0, heroFix: number = 0, heroRatio: number = 0, heroEquip: number = 0) {
|
||||
return (heroFix + heroEquip + roleFix) * HERO_CE_RATIO + heroBase * ( HERO_CE_RATIO + heroRatio + roleRatio );
|
||||
}
|
||||
|
||||
// private getRealAttrToMap() {
|
||||
// let newMap = new Map<number, number>();
|
||||
// for(let [id, val] of this.attrs) {
|
||||
// if(ABI_TYPE_MAIN.includes(id)) { // 主属性
|
||||
// newMap.set(id, val / HERO_CE_RATIO / HERO_CE_RATIO);
|
||||
// } else {
|
||||
// newMap.set(id, val / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO);
|
||||
// }
|
||||
// }
|
||||
// return newMap;
|
||||
// }
|
||||
|
||||
private getReduceAttrMap() {
|
||||
private getAttrMap() {
|
||||
let newMap = new Map<number, number>();
|
||||
for(let [id, val] of this.attrs) {
|
||||
newMap.set(id, reduceCe(val));
|
||||
newMap.set(id, val);
|
||||
}
|
||||
return newMap
|
||||
}
|
||||
|
||||
public getReduceAttributes() {
|
||||
public getAttributes() {
|
||||
let attrs = new Attribute();
|
||||
attrs.setByMap(this.getReduceAttrMap());
|
||||
attrs.setByMap(this.getAttrMap());
|
||||
return attrs;
|
||||
}
|
||||
|
||||
public getReduceAttributesToArr() {
|
||||
public getAttributesToArr() {
|
||||
let arr: {id: number, val: number}[] = [];
|
||||
for(let [id, val] of this.getReduceAttrMap()) {
|
||||
for(let [id, val] of this.getAttrMap()) {
|
||||
arr.push({ id, val });
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public getReduceAttributesToString() {
|
||||
let arr = this.getReduceAttributesToArr();
|
||||
public getAttributesToString() {
|
||||
let arr = this.getAttributesToArr();
|
||||
return arr.map(cur => `${cur.id}&${cur.val}`).join('|');
|
||||
}
|
||||
|
||||
public getReduceMainAttributes() {
|
||||
let attribute = this.getReduceAttributes();
|
||||
public getMainAttributes() {
|
||||
let attribute = this.getAttributes();
|
||||
return attribute.getMainAttr();
|
||||
}
|
||||
|
||||
@@ -126,12 +86,8 @@ export class AttributeCal {
|
||||
return Math.floor(ce);
|
||||
}
|
||||
|
||||
public calSubAttrCeAndReduce() {
|
||||
return Math.floor(this.calCe(3) / HERO_CE_RATIO / HERO_CE_RATIO);
|
||||
}
|
||||
|
||||
public calCelAndReduce() {
|
||||
return Math.floor(this.calCe() / HERO_CE_RATIO / HERO_CE_RATIO);
|
||||
public calSubAttrCe() {
|
||||
return Math.floor(this.calCe(3));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Talent } from '../../db/Hero';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
import { reduceCe } from '../../pubUtils/util';
|
||||
export interface CreateHeroParam extends HeroUpdate {
|
||||
hid: number;
|
||||
count: number;
|
||||
@@ -73,11 +72,7 @@ export class HeroParam {
|
||||
this.hName = hero.hName;
|
||||
this.exp = hero.exp;
|
||||
this.lv = hero.lv;
|
||||
if(hero.isReducedCe) {
|
||||
this.ce = hero.ce;
|
||||
} else {
|
||||
this.ce = reduceCe(hero.ce);
|
||||
}
|
||||
this.ce = hero.ce;
|
||||
this.star = hero.star;
|
||||
this.starStage = hero.starStage;
|
||||
this.colorStar = hero.colorStar;
|
||||
|
||||
@@ -335,7 +335,7 @@ export function getBossHpByWarId(warId: number) {
|
||||
if (relation === 2) {
|
||||
let newAttr = new AttributeCal();
|
||||
newAttr.setByWarJson(attribute, 1);
|
||||
let attrJson = newAttr.getReduceAttributes();
|
||||
let attrJson = newAttr.getAttributes();
|
||||
|
||||
const hp = attrJson.hp || 0;
|
||||
if (hp > 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// 装备强化表
|
||||
import { readFileAndParse, parseGoodStr, decodeArrayListStr } from '../util'
|
||||
import { readFileAndParse, decodeArrayListStr } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
|
||||
export interface DicEquipStrengthAttr {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,21 +1,17 @@
|
||||
import { STATUS } from './../consts/statusCode';
|
||||
|
||||
import { HeroModel, HeroType } from '../db/Hero';
|
||||
import { isNumber } from 'underscore';
|
||||
|
||||
const csprng = require('csprng');
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, WAR_TYPE, LINEUP_NUM } from '../consts';
|
||||
import { ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, WAR_TYPE } from '../consts';
|
||||
|
||||
import { findIndex } from 'underscore';
|
||||
import { getTimeFunM } from './timeUtil';
|
||||
import { Floor } from '../domain/activityField/gachaField';
|
||||
import { WhiteListModel } from '../db/RegionWhiteList';
|
||||
import { RewardInter } from './interface';
|
||||
import { RoleType } from '../db/Role';
|
||||
import { RoleCeModel } from '../db/RoleCe';
|
||||
import { CalCe } from '../services/role/calCe';
|
||||
const randomName = require("chinese-random-name");
|
||||
const moment = require('moment');
|
||||
const crypto = require('crypto');
|
||||
@@ -564,17 +560,6 @@ export function mergeSameGoods(goods: Array<{ id: number, count: number }>) {
|
||||
return resGoods;
|
||||
}
|
||||
|
||||
export function returnHeroCeRatio(hero: HeroType) {
|
||||
let ce = reduceCe(hero.ce);
|
||||
return Object.assign(hero, { ce });
|
||||
}
|
||||
|
||||
// 缩小战力
|
||||
export function reduceCe(ce: number = 0) {
|
||||
return Math.floor(ce / HERO_CE_RATIO / HERO_CE_RATIO)
|
||||
}
|
||||
|
||||
|
||||
// 获取全部属性
|
||||
export function getAllAttrStage() {
|
||||
let attrs = new Array<number>(); // 有升级的属性 1-hp 2-atk 3-def 4-mdef 5-agi 6-luk
|
||||
|
||||
Reference in New Issue
Block a user