Merge branch 'feature/ce'

This commit is contained in:
luying
2022-03-30 21:19:32 +08:00
54 changed files with 16380 additions and 2502 deletions

View File

@@ -4,7 +4,7 @@ import { ExpeditionRecordModel } from '../../../db/ExpeditionRecord';
import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
import { RoleModel } from '../../../db/Role';
import { calculateSumCE, genCode, getWarTypeName } from '../../../pubUtils/util';
import { genCode, getWarTypeName } from '../../../pubUtils/util';
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies, getExpeditionStatus } from '../../../services/expeditionService';
import { DEBUG_MAGIC_WORD, EXPEDITION_WAR_RECORD_STATUS, ITEM_CHANGE_REASON, KING_EXP_RATIO_TYPE, LINEUP_NUM, TASK_TYPE, TA_EVENT } from '../../../consts';
import { WarReward } from '../../../services/warRewardService';
@@ -18,6 +18,7 @@ import { gameData } from '../../../pubUtils/data';
import * as dicParam from '../../../pubUtils/dicParam';
import { getSeconds, nowSeconds } from '../../../pubUtils/timeUtil';
import { reportTAEvent } from '../../../services/sdkService';
import { getSumCe } from '../../../services/playerCeService';
export default function (app: Application) {
new HandlerService(app, {});
@@ -58,8 +59,8 @@ export class ExpeditionBattleHandler {
await ExpeditionRecordModel.hideRecord(roleId); // 刷掉旧关卡
// 我方战力(暂定)
let myCe = await calculateSumCE(roleId, 1, { num: LINEUP_NUM });
// 我方战力
let myCe = await getSumCe(roleId, LINEUP_NUM);
// 每一关的挑战状态
let { expeditionCode, heroes } = await ExpeditionRecordModel.createRecord({
roleId, roleName, heroes: [], myCe

View File

@@ -92,7 +92,6 @@ export class GuildRemote {
*/
private pushMessage(guildCode: string, path: string, message: any) {
let channel = this.getChannel(guildCode);
console.log('##### channel', guildCode, channel)
if (!!channel) {
channel.pushMessage(path, resResult(STATUS.SUCCESS, message));
}

View File

@@ -18,11 +18,10 @@ import { reportTAEvent } from '../../../services/sdkService';
import { sendMailByContent } from '../../../services/mailService';
import { GuildLeader } from '../../../domain/rank';
import { HeroModel } from '../../../db/Hero';
import { calAllHeroCe, calPlayerCeAndSave } from '../../../services/playerCeService';
import { SkinModel } from '../../../db/Skin';
import { PvpDefenseModel } from '../../../db/PvpDefense';
import { calculatetopLineup } from '../../../pubUtils/playerCe';
import { createHeroes } from '../../../services/role/createHero';
import { calculateCeWithHero } from '../../../services/playerCeService';
let timer: NodeJS.Timer;
export default function (app: Application) {
@@ -95,14 +94,16 @@ export class GmRoleHandler {
param.lv = newLv;
param['exp'] = exp;
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.STAR, sid, roleId, hero, param);
if(param.job > 0) {
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.STAGEUP, sid, roleId, hero, { job: param.job, jobStage: 0 });
}
await calculateCeWithHero(HERO_SYSTEM_TYPE.INIT, roleId, hero.serverId, sid, hid, param);
// if(param.job > 0) {
// await calculateCe(HERO_SYSTEM_TYPE.STAGEUP, roleId, hero.serverId, sid, param, {}, { hid });
if (hero.star != param.star) {
await calAllHeroCe(HERO_SYSTEM_TYPE.STAR, sid, roleId, {}, [hid, 1]); // 升星可能影响到百家学院全局加成
}
// hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.STAGEUP, sid, roleId, hero, { job: param.job, jobStage: 0 });
// }
// if (hero.star != param.star) {
// await calAllHeroCe(HERO_SYSTEM_TYPE.STAR, sid, roleId, {}, [hid, 1]); // 升星可能影响到百家学院全局加成
// }
return resResult(STATUS.SUCCESS);
}
@@ -116,9 +117,8 @@ export class GmRoleHandler {
await HeroModel.deleteHero(roleId, hid);
await SkinModel.deleteByHero(roleId, hid);
let role = await RoleModel.findByRoleId(roleId);
let { topLineup, topLineupCe } = await calculatetopLineup(role, hid, 0, null);
await PvpDefenseModel.deleteHero(roleId, hid);
await RoleModel.updateRoleInfo(roleId, { topLineup, topLineupCe, ce: role.ce - hero.ce });
await RoleModel.updateRoleInfo(roleId, { topLineup: role.topLineup.filter(cur => cur.hid != hid), topLineupCe: role.topLineupCe - hero.ce, ce: role.ce - hero.ce });
return resResult(STATUS.SUCCESS);
}

View File

@@ -5,7 +5,6 @@ import { ItemInter, RewardInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr } from "../../../pubUtils/util";
import { addItems, getJewelRandSe, handleCost } from "../../../services/role/rewardService";
import { HeroModel, EPlace } from "../../../db/Hero";
import { calPlayerCeAndSave } from "../../../services/playerCeService";
import { gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipStarIdByEquipId, getNextEquipStar } from "../../../pubUtils/data";
import { BAG, EQUIP } from "../../../pubUtils/dicParam";
import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, isLocked } from "../../../services/equipService";
@@ -17,6 +16,7 @@ import { pushEquipQualityMax, pushEquipStarMax } from "../../../services/sysChat
import { addConsumeToHero } from "../../../services/roleService";
import { CheckMeterial } from "../../../services/role/checkMaterial";
import { combineItems } from "../../../services/role/util";
import { calculateCeWithHero } from "../../../services/playerCeService";
export default function (app: Application) {
new HandlerService(app, {});
@@ -57,15 +57,15 @@ export class EquipHandler {
ePlace: newEplace,
consumes: addConsumeToHero(hero.consumes, dicEquip.composeMaterial),
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COMPOSE_EQUIP, sid, roleId, hero, update, [ePlaceId]);
await calculateCeWithHero(HERO_SYSTEM_TYPE.COMPOSE_EQUIP, roleId, serverId, sid, hid, update, { ePlaceId });
await checkTaskInComposeEquip(serverId, roleId, sid, oldEplace, newEplace);
return resResult(STATUS.SUCCESS, {
curHero: {
hid: hero.hid,
ePlace: [newEquip]
}
})
let curHero = {
hid,
ePlace: [newEquip]
}
return resResult(STATUS.SUCCESS, { curHero });
}
// 装备栏强化
@@ -105,7 +105,7 @@ export class EquipHandler {
ePlace: newEplace,
consumes: addConsumeToHero(hero.consumes, consumes)
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, update, [ePlaceId]);
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, roleId, serverId, sid, hid, update, { ePlaceIds: [ePlaceId] });
await checkTaskInEquipLvUp(serverId, roleId, sid, oldEplace, newEplace, [ePlaceId]);
const curHero = {
@@ -156,7 +156,7 @@ export class EquipHandler {
ePlace: newEplace,
consumes: addConsumeToHero(hero.consumes, consumes),
}
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, update, [...eplaceIds.keys()]);
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, roleId, serverId, sid, hid, update, { ePlaceIds: [...eplaceIds.keys()] });
await checkTaskInEquipLvUp(serverId, roleId, sid, ePlace, newEplace, [...eplaceIds.keys()]);
const curHero = {
@@ -223,7 +223,7 @@ export class EquipHandler {
ePlace: newEplace,
consumes: addConsumeToHero(hero.consumes, consumes),
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_QUALITY, sid, roleId, hero, update, [ePlaceId]);
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_QUALITY, roleId, serverId, sid, hid, update, { ePlaceId });
await checkTaskInEquipQualityUp(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, hid, isUpQuality);
pushEquipQualityMax(roleId, roleName, serverId, hid, newEquip, isUpQuality);
@@ -298,7 +298,7 @@ export class EquipHandler {
ePlace: newEplace,
consumes: addConsumeToHero(hero.consumes, consumes)
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STAR, sid, roleId, hero, update, [ePlaceId]);
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_STAR, roleId, serverId, sid, hid, update, { ePlaceId });
await checkTaskInEquipStarUp(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, hid, isUpStar);
pushEquipStarMax(roleId, roleName, serverId, hid, newEquip, isUpStar);
@@ -343,7 +343,7 @@ export class EquipHandler {
let canChange = originJewel && checkJewelCanPutOnEquip(originEquip, originJewel);
if(canChange) canSentMineToOrigin = true;
let { newEplace, updatedEplace } = updateEplace(originEplace, ePlaceId, { jewel: canChange? originJewel.seqId: 0 });
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, originHero, { ePlace: newEplace }, [ePlaceId], { oldJewel: jewel, newJewel: canChange? originJewel:null });
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_JEWEL, roleId, serverId, sid, jewel.hid, { ePlace: newEplace }, { ePlaceId, jewel: canChange? originJewel: null });
await checkTaskInPutJewel(serverId, roleId, sid, originEplace, newEplace, ePlaceId, jewel, canChange? originJewel:null);
originHeroResult = { hid: originHero.hid, ePlace: updatedEplace };
@@ -356,7 +356,7 @@ export class EquipHandler {
// 目标镶嵌上
let curJewel = await JewelModel.putOnOrOff(seqId, hid, ePlaceId);
let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, { jewel: seqId });
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId], { oldJewel: originJewel, newJewel: curJewel });
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_JEWEL, roleId, serverId, sid, hid, { ePlace: newEplace }, { ePlaceId, jewel: curJewel });
await checkTaskInPutJewel(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, originJewel, curJewel);
let curHero = {
@@ -384,7 +384,7 @@ export class EquipHandler {
let curJewel = await JewelModel.putOnOrOff(curEquip.jewel, 0, 0);
let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, { jewel: 0 });
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId], { oldJewel: curJewel });
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_JEWEL, roleId, serverId, sid, hid, { ePlace: newEplace }, { ePlaceId, jewel: null });
await checkTaskInPutJewel(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, null, curJewel);
let curHero = {
@@ -437,7 +437,7 @@ export class EquipHandler {
ePlace: newEplace,
consumes: updateConsumes,
}
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STONE, sid, roleId, hero, update, [ePlaceId], { jewel });
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_STONE, roleId, serverId, sid, hid, update, { ePlaceId, jewel });
await checkTaskInPutStone(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, jewel);
let curHero = {
@@ -557,7 +557,7 @@ export class EquipHandler {
// 更新战力
if(hid > 0) {
const hero = await HeroModel.findByHidAndRole(hid, roleId);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, sid, roleId, hero, {}, [ePlaceId], { oldJewel: jewel, newJewel });
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, roleId, serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceId, jewel: newJewel });
}
await checkTaskInEquipReset(serverId, roleId, sid);
@@ -639,7 +639,7 @@ export class EquipHandler {
// 更新战力
if(isSuccess && hid > 0) {
const hero = await HeroModel.findByHidAndRole(hid, roleId);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_QUENCH, sid, roleId, hero, {}, [ePlaceId], { oldJewel: jewel, newJewel });
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_QUENCH, roleId, serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceId, jewel: newJewel });
}
await checkTaskInEquipQuench(serverId, roleId, sid, isSuccess);
@@ -759,7 +759,8 @@ export class EquipHandler {
// 更新战力
if(targetJewel.hid > 0) {
const hero = await HeroModel.findByHidAndRole(targetJewel.hid, roleId);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, sid, roleId, hero, {}, [targetJewel.ePlaceId], { oldJewel: originJewel, newJewel });
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, roleId, serverId, sid, targetJewel.hid, { ePlace: hero.ePlace }, { ePlaceId: targetJewel.ePlaceId, jewel: newJewel });
}
await checkTaskInEquipReset(serverId, roleId, sid);

View File

@@ -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);

View File

@@ -1,7 +1,6 @@
import { Application, BackendSession, ChannelService, HandlerService, } from 'pinus';
import { handleCost, addItems, unlockFigure, getCoinObject, getGoldObject } from '../../../services/role/rewardService';
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
import { resResult, deepCopy, reduceCe, parseGoodStr } from '../../../pubUtils/util';
import { resResult, deepCopy, parseGoodStr } from '../../../pubUtils/util';
import { STATUS } from '../../../consts/statusCode';
import { HeroModel, Connect, HeroSkin, HeroUpdate, EPlace, Talent } from '../../../db/Hero';
import { CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ABI_STAGE, DEBUG_MAGIC_WORD, HERO_INITIAL_QUALITY, REDIS_KEY, TASK_TYPE, ITEM_CHANGE_REASON } from '../../../consts';
@@ -11,18 +10,17 @@ import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, g
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst'
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
import { calculatetopLineup } from '../../../pubUtils/playerCe';
import { PvpDefenseModel } from '../../../db/PvpDefense';
import { checkTask, checkTaskInHeroQUalityUp, checkTaskInHeroStarUp, checkTaskInHeroTrain, checkTaskInHeroWakeUp } from '../../../services/task/taskService';
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 '../../../domain/roleField/calCe';
import { HERO, REBORN } from '../../../pubUtils/dicParam';
import { createHero, createHeroes } from '../../../services/role/createHero';
import { CheckMeterial } from '../../../services/role/checkMaterial';
import { HeroParam } from '../../../domain/roleField/hero';
import { calculateCeWithHero } from '../../../services/playerCeService';
export default function (app: Application) {
new HandlerService(app, {});
@@ -85,7 +83,6 @@ export class HeroHandler {
let { lv: oldLv, exp: oldExp } = hero;
if (oldLv >= playerLv) return resResult(STATUS.ROLE_HERO_LV_OVER);
if (oldLv + addLv > playerLv) addLv = playerLv - oldLv;
console.log('******* addLv', addLv, oldLv, playerLv);
let nextExp = getHeroExpByLv(oldLv + addLv - 1);
console.log('nextExp', nextExp, oldLv + addLv - 1, oldExp)
@@ -127,15 +124,11 @@ export class HeroHandler {
consumes: addConsumeToHero(hero.consumes, material)
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, sid, roleId, hero, update);
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.LVUP, roleId, serverId, sid, hid, update);
// 任务
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_LV, { oldLv, hero });
const curHero = {
hid, lv: hero.lv, exp: hero.exp
}
return resResult(STATUS.SUCCESS, { curHero, cost: material });
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_LV, { oldLv, hero: curHero });
return resResult(STATUS.SUCCESS, { curHero: pick(curHero, ['hid', 'lv', 'exp']), cost: material });
}
@@ -191,21 +184,12 @@ export class HeroHandler {
consumes: addConsumeToHero(hero.consumes, consumes)
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.STAR, sid, roleId, hero, update);
if (isUpStar) {
await calAllHeroCe(HERO_SYSTEM_TYPE.STAR, sid, roleId, {}, [hid, isUpStar ? 1 : 0]); // 升星可能影响到百家学院全局加成
// 任务
await checkTaskInHeroStarUp(serverId, roleId, sid, hero, oldStar);
}
const curHero = {
hid,
star: hero.star,
starStage: hero.starStage,
colorStar: hero.colorStar,
colorStarStage: hero.colorStarStage
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.STAR, roleId, serverId, sid, hid, update, { hid, hero, isUpStar });
if (isUpStar) {
await checkTaskInHeroStarUp(serverId, roleId, sid, curHero, oldStar); // 任务
}
return resResult(STATUS.SUCCESS, { isUpStar, curHero });
return resResult(STATUS.SUCCESS, { isUpStar, curHero: pick(curHero, ['hid', 'star', 'starStage', 'colorStar', 'colorStarStage']) });
}
// 武将升品
@@ -248,16 +232,11 @@ export class HeroHandler {
quality: hero.quality + 1,
consumes: addConsumeToHero(hero.consumes, material)
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.QUALITY, sid, roleId, hero, update);
await calAllHeroCe(HERO_SYSTEM_TYPE.QUALITY, sid, roleId, {}, [hid, 0]); // 升品可能影响到百家学院全局加成
await checkTaskInHeroQUalityUp(serverId, roleId, sid, hero);
const curHero = {
hid,
quality: hero.quality
}
pushHeroQualityUpMsg(roleId, roleName, serverId, hero);
return resResult(STATUS.SUCCESS, { curHero });
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.QUALITY, roleId, serverId, sid, hid, update, { hero });
await checkTaskInHeroQUalityUp(serverId, roleId, sid, curHero);
pushHeroQualityUpMsg(roleId, roleName, serverId, curHero);
return resResult(STATUS.SUCCESS, { curHero: pick(curHero, ['hid', 'quality']) });
}
// 武将觉醒
@@ -319,25 +298,13 @@ export class HeroHandler {
consumes: addConsumeToHero(hero.consumes, consumes)
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COLORSTAR, sid, roleId, hero, update);
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.COLORSTAR, roleId, serverId, sid, hid, update, { hero, isUpStar });
if (isUpStar) {
await calAllHeroCe(HERO_SYSTEM_TYPE.COLORSTAR, sid, roleId, {}, [hid, isUpStar ? 1 : 0]); // 升星可能影响到百家学院全局加成
// 任务
await checkTaskInHeroWakeUp(serverId, roleId, sid, hero, oldColorStar);
await checkTaskInHeroWakeUp(serverId, roleId, sid, curHero, oldColorStar); // 任务
}
const curHero = {
hid,
quality: hero.quality,
star: hero.star,
starStage: hero.starStage,
colorStar: hero.colorStar,
colorStarStage: hero.colorStarStage
}
if (isWakeUp) pushHeroWakeUp(roleId, roleName, serverId, hero); // 第一次觉醒
pushHeroStarMax(roleId, roleName, serverId, hero);
return resResult(STATUS.SUCCESS, { isUpStar, curHero });
if (isWakeUp) pushHeroWakeUp(roleId, roleName, serverId, curHero); // 第一次觉醒
pushHeroStarMax(roleId, roleName, serverId, curHero);
return resResult(STATUS.SUCCESS, { isUpStar, curHero: pick(curHero, ['hid', 'quality', 'star', 'starStage', 'colorStar', 'colorStarStage']) });
}
//训练
@@ -380,14 +347,13 @@ export class HeroHandler {
//重算战力并下发
let update = {
job: hero.job,
jobStage: newJobStage,
consumes: addConsumeToHero(hero.consumes, consumes)
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TRAIN, sid, roleId, hero, update);
// 任务
await checkTaskInHeroTrain(serverId, roleId, sid, hero, trainCount);
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, job: hero.job, jobStage: hero.jobStage } });
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.TRAIN, roleId, serverId, sid, hid, update, { hero });
await checkTaskInHeroTrain(serverId, roleId, sid, curHero, trainCount); // 任务
return resResult(STATUS.SUCCESS, { curHero: pick(curHero, ['hid', 'job', 'jobStage'])});
}
//进阶
@@ -420,11 +386,10 @@ export class HeroHandler {
jobStage: 0,
consumes: addConsumeToHero(hero.consumes, consumes)
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.STAGEUP, sid, roleId, hero, update);
// 任务
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_STAGE_UP, { hero, stageUpCnt: 1 })
const heroResult = new HeroParam(hero);
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.STAGEUP, roleId, serverId, sid, hid, update, { hid, hero });
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_STAGE_UP, { hero: curHero, stageUpCnt: 1 }); // 任务
const heroResult = new HeroParam(curHero);
return resResult(STATUS.SUCCESS, { curHero: {...pick(heroResult, ['hid', 'job', 'jobStage', 'totalTalentPoint']) }});
}
@@ -477,11 +442,10 @@ export class HeroHandler {
consumes: addConsumeToHero(hero.consumes, consumes)
}
//重算战力并下发
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.CONNECT, sid, roleId, hero, update, [shipId]);
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.CONNECT, roleId, serverId, sid, hero.hid, update, { shipId, hero });
// 任务
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_CONNECT, { connectLv: level })
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, connections: hero.connections } });
return resResult(STATUS.SUCCESS, { curHero: pick(curHero, ['hid', 'connections']) });
}
//赠送(包括一键赠送)
@@ -554,17 +518,14 @@ export class HeroHandler {
consumes: updateConsume
}
//重算战力并下发
if (oldLv != newLv) {
await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.HERO_FAVOR, paramHid: hero.hid, paramFavourLv: hero.favourLv }]);
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.FAVOUR, sid, roleId, hero, update, [oldLv]);
let isFavourLvUp = oldLv != newLv;
// 任务
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_FAVOUR_LV, { hero, oldFavourLv: oldLv });
} else {
hero = await HeroModel.updateHeroInfo(roleId, hero.hid, update);
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.FAVOUR, roleId, serverId, sid, hero.hid, update, { isFavourLvUp, hero });
if(isFavourLvUp) {
await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.HERO_FAVOR, paramHid: curHero.hid, paramFavourLv: curHero.favourLv }]);
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_FAVOUR_LV, { hero: curHero, oldFavourLv: oldLv }); // 任务
}
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, favour: hero.favour, favourLv: hero.favourLv, cost: material } });
return resResult(STATUS.SUCCESS, { curHero: { ...pick(curHero, ['hid', 'favour', 'favourLv']), cost: material } });
}
//穿带时装
@@ -613,9 +574,14 @@ export class HeroHandler {
}
let { newEplace } = updateEplaces(oldEplace, eplaceIds);
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.SKIN, sid, roleId, hero, { skins: newHeroSkins, skinId: dicSkin.heroId, job: dicNewJob.jobid, ePlace: newEplace });
let resultHero = new HeroParam(hero);
let update = {
skins: newHeroSkins,
skinId: dicSkin.heroId,
job: dicNewJob.jobid,
ePlace: newEplace
}
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.SKIN, roleId, serverId, sid, hero.hid, update);
let resultHero = new HeroParam(curHero);
return resResult(STATUS.SUCCESS, { curHero: {...pick(resultHero, ['hid', 'skins', 'skinId', 'job', 'talent', 'usedTalentPoint']), ePlace: newEplace }});
}
@@ -634,6 +600,7 @@ export class HeroHandler {
let roleId: string = session.get('roleId');
let roleName: string = session.get('roleName');
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let { hid } = msg;
if(!isNumber(hid) && !hid) return resResult(STATUS.WRONG_PARMS);
@@ -654,9 +621,8 @@ export class HeroHandler {
let newSkins = initSkinTalent(skins);
let dicHeroScroll = getScollByStar(dicHero.quality, dicHero.initialStars, dicHero.quality, 0);
let initInfo = HeroModel.getInitInfo({
let initInfo = HeroModel.getInitInfo(hid, {
job: dicJob.jobid, skins: newSkins, skinId, ce,
star: dicHero.initialStars, quality: dicHero.quality,
scrollActive: scrollActive,
scrollId: scrollActive? dicHeroScroll.id: 0,
scrollStar: scrollActive? dicHeroScroll.stars: 0,
@@ -664,10 +630,6 @@ export class HeroHandler {
scrollColorStar: scrollActive? dicHeroScroll.colorstars: 0,
});
let calHeroCe = new CalHeroCe(hid, initInfo);
let heroAttr = calHeroCe.cal(HERO_SYSTEM_TYPE.REBIRTH);
await HeroModel.updateHeroInfo(roleId, hid, { ...initInfo, attr: heroAttr });
// 天晶石
let curJewels: jewelUpdate[] = [];
for(let { jewel, id } of hero.ePlace) {
@@ -681,9 +643,7 @@ export class HeroHandler {
}
}
let { heros } = await calAllHeroCe(HERO_SYSTEM_TYPE.REBIRTH, sid, roleId, {}, [hid], { originHero: hero, heroUpdate: initInfo });
let curHero = heros.find(cur => cur.hid == hid);
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.REBIRTH, roleId, serverId, sid, hid, initInfo, { });
let goods = await addItems(roleId, roleName, sid, consumes, ITEM_CHANGE_REASON.REBIRTH);
const heroResult = new HeroParam(curHero);
@@ -694,6 +654,7 @@ export class HeroHandler {
public async unlockTalent(msg: { hid: number, id: number }, session: BackendSession) {
let roleId = session.get('roleId');
let sid = session.get('sid');
let serverId = session.get('serverId');
let { hid, id } = msg;
let hero = await HeroModel.findByHidAndRole(hid, roleId);
@@ -722,9 +683,8 @@ export class HeroHandler {
let { newSkins } = updateSkinTalent(skins, new Talent(id), usedTalentPoint + needTalentPoint);
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TALENT, sid, roleId, hero, { skins: newSkins });
const heroResult = new HeroParam(hero);
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.TALENT, roleId, serverId, sid, hid, { skins: newSkins });
const heroResult = new HeroParam(curHero);
return resResult(STATUS.SUCCESS, { curHero: {...pick(heroResult, ['hid', 'talent', 'usedTalentPoint', 'totalTalentPoint']) }});
}
@@ -733,6 +693,7 @@ export class HeroHandler {
public async upgradeTalent(msg: { hid: number, id: number }, session: BackendSession) {
let roleId = session.get('roleId');
let sid = session.get('sid');
let serverId = session.get('serverId');
let { hid, id } = msg;
let hero = await HeroModel.findByHidAndRole(hid, roleId);
@@ -759,9 +720,8 @@ export class HeroHandler {
let { newSkins } = updateSkinTalent(skins, new Talent(id, talent.level + 1), usedTalentPoint + needTalentPoint);
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TALENT, sid, roleId, hero, { skins: newSkins });
const heroResult = new HeroParam(hero);
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.TALENT, roleId, serverId, sid, hid, { skins: newSkins });
const heroResult = new HeroParam(curHero);
return resResult(STATUS.SUCCESS, { curHero: {...pick(heroResult, ['hid', 'talent', 'usedTalentPoint', 'totalTalentPoint']) }});
}
@@ -769,6 +729,7 @@ export class HeroHandler {
public async resetTalent(msg: { hid: number }, session: BackendSession) {
let roleId = session.get('roleId');
let sid = session.get('sid');
let serverId = session.get('serverId');
let { hid } = msg;
let hero = await HeroModel.findByHidAndRole(hid, roleId);
@@ -784,9 +745,9 @@ export class HeroHandler {
let newSkins = initSkinTalent(skins);
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TALENT, sid, roleId, hero, { skins: newSkins });
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.TALENT, roleId, serverId, sid, hid, { skins: newSkins });
const heroResult = new HeroParam(hero);
const heroResult = new HeroParam(curHero);
return resResult(STATUS.SUCCESS, { curHero: {...pick(heroResult, ['hid', 'talent', 'usedTalentPoint', 'totalTalentPoint']) }});
}
@@ -844,7 +805,6 @@ export class HeroHandler {
await HeroModel.deleteHero(roleId, hid);
let role = await RoleModel.findByRoleId(roleId);
await calculatetopLineup(role, hid, 0, null);
await PvpDefenseModel.deleteHero(roleId, hid);
await RoleModel.updateRoleInfo(roleId, { topLineup: role.topLineup, topLineupCe: role.topLineupCe, ce: role.ce - hero.ce });
return resResult(STATUS.SUCCESS);

View File

@@ -1,17 +1,16 @@
import { STATUS } from '../../../consts/statusCode';
import { RoleModel, RoleUpdate } from './../../../db/Role';
import { HeroModel, HeroUpdate } from '../../../db/Hero';
import { HeroModel, HeroType, HeroUpdate } from '../../../db/Hero';
import { resResult, decodeIdCntArrayStr, parseGoodStr, genCode } from '../../../pubUtils/util';
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
import { handleCost, addItems, getGoldObject, getCoinObject } from '../../../services/role/rewardService';
import { getTitle, getTeraph, gameData, getScollByStar, getFriendLvByExp, getHeroExpByLv, getExpByLv } from '../../../pubUtils/data';
import { SCHOOL, SCROLL, EXTERIOR, SCRIPT } from '../../../pubUtils/dicParam';
import { getAtrrNameById } from '../../../consts/constModules/abilityConst'
import { findIndex } from 'underscore';
import { findIndex, pick } from 'underscore';
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
import { SchoolModel } from '../../../db/School';
import { getTeraphStrengthenResult, getSchoolList } from '../../../services/roleService'
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAULT_HEROES, DEFAULT_HERO_LV, DEFAULT_ITEMS, DEFAULT_EQUIPS, DEFAULT_GOLD, DEFAULT_COIN, DEBUG_MAGIC_WORD, COUNTER, DEFAULT_LV, ITEM_CHANGE_REASON } from '../../../consts';
import { checkBattleHeroesByHid, roleLevelup } from '../../../services/normalBattleService';
import { Rank } from '../../../services/rankService';
@@ -25,7 +24,8 @@ import * as dicParam from '../../../pubUtils/dicParam';
import Counter from '../../../db/Counter';
import { UserModel } from '../../../db/User';
import { checkFilterWords, reportTAEvent, treatRoleName } from '../../../services/sdkService';
import { CreateHeroes } from '../../../services/role/createHero';
import { createHeroes } from '../../../services/role/createHero';
import { calculateCeWithHero, calculateCeWithRole } from '../../../services/playerCeService';
export default function (app: Application) {
new HandlerService(app, {});
@@ -44,26 +44,14 @@ export class RoleHandler {
let { roleName } = msg;
let role = await RoleModel.findByRoleId(roleId, 'roleName hasInit', true);
let role = await RoleModel.findByRoleId(roleId, 'roleName hasInit title teraphs', true);
if (role.hasInit) return resResult(STATUS.ROLE_HAS_INIT);
let checkName = await RoleModel.checkName(roleName, serverId);
if (checkName) return resResult(STATUS.NAME_HAS_USED);
let initInfos: { role: RoleUpdate, initInfos: {heroInfo: HeroUpdate, skinInfo: SkinUpdate}[], figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }}
= this.app.get('initRoleInfos');
role = await RoleModel.updateRoleInfo(roleId, {...initInfos.role, roleName, hasInit: true});
let createHero = new CreateHeroes(roleId, roleName, serverId);
let infos = new Map();
for(let {heroInfo, skinInfo} of initInfos.initInfos) {
infos.set(heroInfo.hid, { heroInfo, skinInfo });
}
await createHero.createWithInitInfo(infos, initInfos.figureInfo);
await createHero.pushMessage(sid);
await createHero.updateRedisRank();
let heroes = createHero.getResultHeroes();
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: role.lv });
// role = await RoleModel.updateRoleInfo(roleId, { roleName, hasInit: true }); // 在算战力的时候一起更新
session.set('roleName', roleName);
session.push('roleName', () => { });
@@ -107,11 +95,11 @@ export class RoleHandler {
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
let update = { title: title + 1 }
let calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TITLE, sid, roleId, 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 });
return resResult(STATUS.SUCCESS, { roleId: calResult.role, title: role.title });
return resResult(STATUS.SUCCESS, { roleId, title: curRole.title });
}
//神像强化
@@ -140,12 +128,12 @@ export class RoleHandler {
if (!result)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
let calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TERAPH, sid, roleId, { teraphs }, [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 });
return resResult(STATUS.SUCCESS, { roleId, teraphs: calResult.role.teraphs, criAttr });
return resResult(STATUS.SUCCESS, { roleId, teraphs: curRole.teraphs, criAttr });
}
//神像进阶
@@ -183,13 +171,12 @@ 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 calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TERAPH_UP, sid, roleId, { teraphs }, [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);
return resResult(STATUS.SUCCESS, { roleId, teraphs: calResult.role.teraphs });
return resResult(STATUS.SUCCESS, { roleId, teraphs: curRole.teraphs });
}
// 获得百家学宫
@@ -217,14 +204,14 @@ export class RoleHandler {
return resResult(STATUS.DIC_DATA_NOT_FOUND);
}
let isOpen = !!dicPosition.get(positionId.toString()); // 该位置是否解锁
let curHero: HeroType = null;
if (hid > 0) {
let findHero = await SchoolModel.findByHid(roleId, hid);
if (!!findHero) {
return resResult(STATUS.ROLE_SCHOOL_HERO_USED);
}
let curHero = await HeroModel.findByHidAndRole(hid, roleId);
curHero = await HeroModel.findByHidAndRole(hid, roleId);
if (!curHero) return resResult(STATUS.HERO_NOT_FIND);
}
@@ -241,7 +228,7 @@ export class RoleHandler {
}
await SchoolModel.updateBySclAndPos(roleId, schoolId, positionId, { hid, isOpen })
await calAllHeroCe(HERO_SYSTEM_TYPE.SCHOOL, sid, roleId, {}, [schoolId, hid, 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 });
@@ -298,13 +285,13 @@ export class RoleHandler {
let { hid } = msg;
let curHero = await HeroModel.findByHidAndRole(hid, roleId, 'hid lv star colorStar quality scrollId scrollActive scrollStar scrollColorStar scrollQuality favour favourLv connections attr ce');
if (!curHero) return resResult(STATUS.HERO_NOT_FIND);
let hero = await HeroModel.findByHidAndRole(hid, roleId, 'hid lv star colorStar quality scrollId scrollActive scrollStar scrollColorStar scrollQuality favour favourLv connections attr ce');
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let dicHero = gameData.hero.get(hid);
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
let { star, colorStar, quality, scrollId, scrollActive, scrollStar, scrollColorStar, scrollQuality, favour, favourLv } = curHero;
let { star, colorStar, quality, scrollId, scrollActive, scrollStar, scrollColorStar, scrollQuality, favour, favourLv } = hero;
let update = {
scrollActive, scrollId, scrollStar, scrollColorStar, scrollQuality, favour, favourLv
@@ -331,23 +318,13 @@ export class RoleHandler {
let dicHeroScroll = getScollByStar(dicHero.quality, update.scrollStar, update.scrollQuality, update.scrollColorStar);
update.scrollId = dicHeroScroll ? dicHeroScroll.id : 0;
let hero = await HeroModel.updateHeroInfo(roleId, hid, update);
await calAllHeroCe(HERO_SYSTEM_TYPE.SCROLL, sid, roleId, {}, [hid]); // 全局增加战力
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.SCROLL, roleId, serverId, sid, hid, update);
// 任务
await checkTaskInActiveScroll(serverId, roleId, sid, scrollActive, hero);
return resResult(STATUS.SUCCESS, {
curHero: {
hid: hero.hid,
scrollActive: hero.scrollActive,
scrollId: hero.scrollId,
scrollStar: hero.scrollStar,
scrollColorStar: hero.scrollColorStar,
scrollQuality: hero.scrollQuality,
favour: hero.favour,
favourLv: hero.favourLv,
}
curHero: pick(curHero, ['hid', 'scrollActive', 'scrollId', 'scrollStar', 'scrollColorStar', 'scrollQuality', 'favour', 'favourLv'])
});
}

View File

@@ -5,14 +5,11 @@ import { HeroUpdate } from '../../../db/Hero';
import { RoleUpdate } from '../../../db/Role';
import { SkinUpdate } from '../../../db/Skin';
import { RankFirstModel, RankFirstType } from '../../../db/RankFirst';
import { DEFAULT_HEROES } from '../../../consts';
import { Figure } from '../../../domain/dbGeneral';
import { getDefaultRoleInfo } from '../../../services/roleService';
import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
import { treatRoleName, taflush } from '../../../services/sdkService';
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
import { errlogger } from '../../../util/logger';
import { getInitRoleInfo } from '../../../services/role/initRoleService';
export default function (app: Application) {
new HandlerService(app, {});
@@ -23,16 +20,12 @@ export class RoleRemote {
constructor(private app: Application) {
this.app = app;
this.channelService = app.get('channelService');
this.setInitRole();
// this.channelService = app.get('channelService');
this.loadRankFirst();
this.initPvpSeasonNum();
}
private channelService: ChannelService;
private initHeroes: Map<number, HeroUpdate> = new Map(); // hid => hero
private initRole: RoleUpdate = {};
private initSkins: Map<number, SkinUpdate> = new Map(); // hid => skin
private figureInfo: {heads: Figure[], frames: Figure[], spines: Figure[]};
// private channelService: ChannelService;
private rankFirstRewards: Map<number, Map<number, RankFirstType>> = new Map();
private async loadRankFirst() {
@@ -68,76 +61,6 @@ export class RoleRemote {
}
}
public setInitRole() {
try {
let result = getInitRoleInfo();
let { role, heroes, skins, figureInfo } = result;
for(let hero of heroes) {
this.initHeroes.set(hero.hid, hero);
}
for(let skin of skins) {
this.initSkins.set(skin.hid, skin);
}
this.initRole = role;
this.figureInfo = figureInfo;
const initRoleInfos = getDefaultRoleInfo(this.initHeroes, this.initSkins, this.initRole, this.figureInfo);
this.app.set('initRoleInfos', initRoleInfos);
this.app.set('initHeroes', this.initHeroes);
this.app.set('initSkins', this.initSkins);
} catch(e) {
errlogger.error(`remote ${__filename} \n ${e.stack}`);
}
}
public getInitRoleInfos() {
try {
let initRoleInfos = this.app.get('initRoleInfos');
if (!initRoleInfos) {
initRoleInfos = getDefaultRoleInfo(this.initHeroes, this.initSkins, this.initRole, this.figureInfo);
this.app.set('initRoleInfos', initRoleInfos);
}
return initRoleInfos;
} catch(e) {
errlogger.error(`remote ${__filename} \n ${e.stack}`);
}
}
public getInitHeroes() {
try {
let result: HeroUpdate[] = [];
for(let hid of DEFAULT_HEROES) {
result.push(this.initHeroes.get(hid));
}
return result;
} catch(e) {
errlogger.error(`remote ${__filename} \n ${e.stack}`);
}
}
public getInitSkins() {
try {
let result: SkinUpdate[] = [];
for(let hid of DEFAULT_HEROES) {
result.push(this.initSkins.get(hid));
}
return result;
} catch(e) {
errlogger.error(`remote ${__filename} \n ${e.stack}`);
}
}
public getInitHeroById(hid: number) {
try {
return {
heroInfo: this.initHeroes.get(hid),
skinInfo: this.initSkins.get(hid)
}
} catch(e) {
errlogger.error(`remote ${__filename} \n ${e.stack}`);
}
}
/**
* 重载json资源
*/

View File

@@ -222,8 +222,6 @@ export function getVipRegretCnt(vipStartTime: number) {
}
export function vipCanSkipTower(recommendCeSum: number, heroesCeSum: number, vipStartTime: number) {
console.log('####', recommendCeSum, heroesCeSum, vipStartTime, );
let ratio = vipStartTime > 0? VIP.VIP_TOWER_SKIP_CE_RATIO_WITH_VIP: VIP.VIP_TOWER_SKIP_CE_RATIO_WITHOUT_VIP;
console.log('#####', VIP.VIP_TOWER_SKIP_CE_RATIO_WITH_VIP, VIP.VIP_TOWER_SKIP_CE_RATIO_WITHOUT_VIP, ratio)
return heroesCeSum > recommendCeSum * ratio;
}

View File

@@ -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, {

View File

@@ -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';
@@ -126,4 +126,18 @@ export function getJewelByEquip(oldEquip: EPlace, newEquip: EPlace, jewels: Jewe
let oldJewel = jewels.find(cur => cur && cur.seqId == oldEquip.jewel);
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;
}

View File

@@ -1,15 +1,16 @@
import { ExpeditionPointModel } from '../db/ExpeditionPoint';
import Role, { CeAttrDataRole, RoleModel } from '../db/Role';
import { shouldRefresh, calculateSumCE, getRandSingleEelm } from '../pubUtils/util';
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 { getHeroesAttributes, getSumCe } from './playerCeService';
/**
* 获取远征关卡列表
@@ -24,7 +25,7 @@ export async function getExpeditionStatus(roleId: string, roleName: string) {
let expeditionRecord = await ExpeditionRecordModel.getCurRecord(roleId);
if (!expeditionRecord) { // 首次新建一条记录
// 我方战力
let myCe = await calculateSumCE(roleId, 1, { num: LINEUP_NUM });
let myCe = await getSumCe(roleId, LINEUP_NUM);
expeditionRecord = await ExpeditionRecordModel.createRecord({
roleId, roleName, heroes: [], myCe
});
@@ -136,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;
@@ -149,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,
@@ -280,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 };
}

View File

@@ -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;
}

View File

@@ -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}`);

View File

@@ -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 }[] = [];

View File

@@ -5,78 +5,358 @@
import { pinus } from 'pinus';
import { STATUS } from '../consts/statusCode';
import { resResult, reduceCe } from '../pubUtils/util';
import { calPlayerCeAndSave as pubCalPlayerCeAndSave, reCalAllHeroCe } from '../pubUtils/playerCe';
import { HeroType, HeroUpdate } from '../db/Hero';
import { resResult } from '../pubUtils/util';
import { HeroModel, HeroType, HeroUpdate } from '../db/Hero';
import { RoleUpdate, RoleType } from '../db/Role';
import { RoleUpdate, RoleType, RoleModel } from '../db/Role';
import { Rank } from './rankService';
import { REDIS_KEY } from '../consts';
import { HERO_SYSTEM_TYPE, REDIS_KEY } from '../consts';
import { updateUserInfo } from './redisService';
import { GuildType } from '../db/Guild';
import { GuildModel, GuildType } from '../db/Guild';
import { CalCe } from './role/calCe';
import { RoleCeModel } from '../db/RoleCe';
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 calPlayerReturn {
serverId: number;
role: RoleType;
guild?: GuildType;
hero?: HeroType;
pushHeros: {hid: number, ce: number, incHeroCe: number}[];
topLineupCe: number;
heros?: HeroType[]
interface Param {
isInitRole?: boolean,
hid?: number,
hero?: HeroType,
isUpStar?: boolean,
shipId?: number,
isFavourLvUp?: boolean,
ePlaceId?: number,
ePlaceIds?: number[],
jewels?: JewelType[],
jewel?: JewelType,
teraphId?: number,
schoolId?: number,
schoolHid?: number,
preSchoolHid?: number,
skinId?: number,
}
//修改并下发战力
export async function calPlayerCeAndSave(type: number, sid: string, roleId: string, originHero: HeroType, update: HeroUpdate, args?: Array<number>, params?: any) {
let result = await pubCalPlayerCeAndSave(type, roleId, originHero, update, args, params);
return await pushCalPlayerCe(roleId, sid, result);
export async function calculateCeWithHero(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, hid: number, heroUpdate: HeroUpdate, param: Param = {}) {
let heroUpdates = new Map<number, HeroUpdate>();
heroUpdates.set(hid, heroUpdate);
let { heroes, curRole } = await calculateCes(type, roleId, serverId, sid, heroUpdates, {}, {}, param);
let curHero = heroes.find(cur => cur.hid == hid);
return { heroes, curHero, curRole }
}
// 修改后战力的推送
export async function pushCalPlayerCe(roleId: string, sid: string, calResult: calPlayerReturn) {
let {role, pushHeros, topLineupCe, hero, guild, serverId} = calResult;
// console.log(JSON.stringify(pushHeros))
//下发战力
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 };
}
export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, heroUpdates: Map<number, HeroUpdate>, roleUpdate: RoleUpdate, roleIncUpdate: RoleUpdate, param: Param = {}) {
let calCe = new CalCe(roleId);
let roleCe = await RoleCeModel.findByRoleId(roleId);
calCe.setRoleCe(roleCe);
switch (type) {
case HERO_SYSTEM_TYPE.INIT:
{
for(let [hid, { skinId, lv, quality, star, starStage, colorStar, colorStarStage, job, jobStage, }] of heroUpdates) {
calCe.setHeroBase(hid, skinId);
calCe.setHeroLv(hid, lv);
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, lv } = roleUpdate;
calCe.setRoleLv(lv)
calCe.setTitle(title);
calCe.setTeraph(teraphs);
}
break;
}
case HERO_SYSTEM_TYPE.LVUP: // 1. 升级
{
for(let [hid, { lv }] of heroUpdates) {
calCe.setHeroLv(hid, lv);
}
break;
}
case HERO_SYSTEM_TYPE.STAR: // 2. 升星
{
for(let [hid, { star, starStage }] of heroUpdates) {
let { hero: { quality, job, colorStar, colorStarStage }, isUpStar } = param;
await treatHeroStar(calCe, roleId, hid, star, starStage, quality, colorStar, colorStarStage, job, isUpStar);
}
break;
}
case HERO_SYSTEM_TYPE.QUALITY: // 3. 升品
{
for(let [hid, { quality }] of heroUpdates) {
let { hero: { star, starStage, colorStar, colorStarStage, job } } = param;
await treatHeroStar(calCe, roleId, hid, star, starStage, quality, colorStar, colorStarStage, job, true);
}
break;
}
case HERO_SYSTEM_TYPE.COLORSTAR: // 4. 觉醒
{
for(let [hid, { quality, colorStar, colorStarStage }] of heroUpdates) {
let { hero: { star, starStage, job }, isUpStar } = param;
await treatHeroStar(calCe, roleId, hid, star, starStage, quality, colorStar, colorStarStage, job, isUpStar);
}
break;
}
case HERO_SYSTEM_TYPE.TRAIN: // 5. 训练
case HERO_SYSTEM_TYPE.STAGEUP: // 6. 职业进阶
{
for(let [hid, { job, jobStage }] of heroUpdates) {
calCe.setJob(hid, job, jobStage);
}
break;
}
case HERO_SYSTEM_TYPE.SKIN: // 7. 穿皮肤
{
let { hero: { quality, star, starStage, colorStar, colorStarStage, skins } } = param;
for(let [hid, { skinId, job, ePlace }] of heroUpdates) {
calCe.setHeroBase(hid, skinId);
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
for(let { id, equipId, quality, qualityStage, lv, star, starStage } of ePlace) {
calCe.setEquipQuality(hid, id, equipId, quality, qualityStage);
calCe.setEquipStrength(hid, id, equipId, lv);
calCe.setEquipStar(hid, id, equipId, star, starStage);
}
calCe.setTalent(hid, skins);
}
break;
}
case HERO_SYSTEM_TYPE.FAVOUR: // 8. 好感度
{
let { hero: { connections }, isFavourLvUp } = param;
console.log('####', connections, isFavourLvUp, heroUpdates)
if(isFavourLvUp) {
for(let [hid, { favourLv }] of heroUpdates) {
calCe.setFavour(hid, favourLv, connections);
}
}
break;
}
case HERO_SYSTEM_TYPE.CONNECT: // 9. 羁绊
{
for(let [ hid, { connections } ] of heroUpdates) {
let { shipId } = param;
calCe.setConnection(hid, shipId, connections);
}
break;
}
case HERO_SYSTEM_TYPE.ADD_SKIN: // 15. 第一次获得皮肤
{
let { skinId } = param;
calCe.setAddSkin(skinId);
break;
}
case HERO_SYSTEM_TYPE.SCHOOL: // 16. 放百家学宫
{
let { schoolId, schoolHid, preSchoolHid, hero } = param;
if(preSchoolHid) {
calCe.setSchool(false, preSchoolHid, schoolId, 0, 0, 0);
}
if(schoolHid) {
let { star, colorStar, quality } = hero;
calCe.setSchool(true, schoolHid, schoolId, star, colorStar, quality);
}
break;
}
case HERO_SYSTEM_TYPE.SCROLL: // 17. 名将谱
{
for(let [hid, { scrollStar, scrollQuality, scrollColorStar }] of heroUpdates) {
calCe.setScroll(hid, scrollStar, scrollQuality, scrollColorStar);
}
break;
}
case HERO_SYSTEM_TYPE.TITLE: // 18. 爵位
{
let { title } = roleUpdate;
calCe.setTitle(title);
break;
}
case HERO_SYSTEM_TYPE.TERAPH: // 19. 神像
case HERO_SYSTEM_TYPE.TERAPH_UP: // 20. 神像进阶
{
let { teraphs } = roleUpdate;
calCe.setTeraph(teraphs);
break;
}
case HERO_SYSTEM_TYPE.COMPOSE_EQUIP: // 21. 合成装备
{
let { ePlaceId } = param;
for(let [hid, { ePlace = [] }] of heroUpdates) {
for(let { id, equipId, quality, qualityStage, lv, star, starStage } of ePlace) {
if(ePlaceId == id) {
calCe.setEquipQuality(hid, id, equipId, quality, qualityStage);
calCe.setEquipStrength(hid, id, equipId, lv);
calCe.setEquipStar(hid, id, equipId, star, starStage);
}
}
calCe.setEquipSuit(hid, ePlace);
}
break;
}
case HERO_SYSTEM_TYPE.EQUIP_STRENGTH: // 22. 装备强化
{
let { ePlaceIds } = param;
for(let [hid, { ePlace = [] }] of heroUpdates) {
for(let { id, equipId, lv } of ePlace) {
if(ePlaceIds.indexOf(id) != -1) {
calCe.setEquipStrength(hid, id, equipId, lv);
}
}
}
break;
}
case HERO_SYSTEM_TYPE.EQUIP_QUALITY: // 23. 装备升品
{
let { ePlaceId } = param;
for(let [hid, { ePlace = [] }] of heroUpdates) {
for(let { id, equipId, quality, qualityStage } of ePlace) {
if(ePlaceId == id) {
calCe.setEquipQuality(hid, id, equipId, quality, qualityStage);
}
}
}
break;
}
case HERO_SYSTEM_TYPE.EQUIP_STAR: // 24. 装备升星
{
let { ePlaceId } = param;
for(let [hid, { ePlace = [] }] of heroUpdates) {
for(let { id, equipId, star, starStage } of ePlace) {
if(ePlaceId == id) {
calCe.setEquipStar(hid, id, equipId, star, starStage);
}
}
calCe.setEquipSuit(hid, ePlace);
}
break;
}
case HERO_SYSTEM_TYPE.EQUIP_JEWEL: // 25. 装备天晶
case HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE: // 27. 洗练
case HERO_SYSTEM_TYPE.JEWEL_QUENCH: // 28. 淬炼
{
let { ePlaceId, jewel: curJewel } = param;
for(let [hid, { ePlace = [] }] of heroUpdates) {
for(let { id, stones } of ePlace) {
if(ePlaceId == id) {
calCe.setJewel(hid, id, stones, curJewel);
}
}
calCe.setEquipSuit(hid, ePlace);
}
break;
}
case HERO_SYSTEM_TYPE.EQUIP_STONE: // 26. 装备地玉
{
let { ePlaceId, jewel: curJewel } = param;
for(let [hid, { ePlace = [] }] of heroUpdates) {
for(let { id, stones } of ePlace) {
if(ePlaceId == id) {
calCe.setJewel(hid, id, stones, curJewel);
}
}
calCe.setEquipSuit(hid, ePlace);
}
break;
}
case HERO_SYSTEM_TYPE.REBIRTH: // 29. 重生
{
for(let [hid, { skinId, lv, quality, star, starStage, colorStar, colorStarStage, job, jobStage, skins, ePlace, scrollStar, scrollQuality, scrollColorStar }] of heroUpdates) {
calCe.setHeroBase(hid, skinId);
calCe.setHeroLv(hid, lv);
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
calCe.setJob(hid, job, jobStage);
for(let { id, equipId, quality, qualityStage, lv, star, starStage } of ePlace) {
calCe.setEquipQuality(hid, id, equipId, quality, qualityStage);
calCe.setEquipStrength(hid, id, equipId, lv);
calCe.setEquipStar(hid, id, equipId, star, starStage);
}
calCe.setTalent(hid, skins);
calCe.setScroll(hid, scrollStar, scrollQuality, scrollColorStar);
}
break;
}
case HERO_SYSTEM_TYPE.TALENT: // 30. 天赋
{
for(let [hid, { skins }] of heroUpdates) {
calCe.setTalent(hid, skins);
}
break;
}
case HERO_SYSTEM_TYPE.ROLE_LV: // 31. 玩家等级
{
let { lv } = roleUpdate;
calCe.setRoleLv(lv);
break;
}
}
let { heroCe, roleInc } = calCe.getCeInc(); // 计算战力,获得有变化的武将战力
let changeHids: number[] = [];
let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>();
let heroes: HeroType[] = [];
for(let [hid, heroUpdate] of heroUpdates) {
if(heroCe.has(hid)) {
let { ce, inc } = heroCe.get(hid);
let heroUpdate = heroUpdates.get(hid)||{};
let hero = await HeroModel.updateHeroInfo(roleId, hid, { ...heroUpdate, ce });
calCe.setResultHero(hero);
heroes.push(hero);
await PvpDefenseModel.updateCe(roleId, hid, inc); // 更新pvp防守阵战力
pushHeros.push({ hid, ce, incHeroCe: inc });
changeHids.push(hid);
} else {
let hero = await HeroModel.updateHeroInfo(roleId, hid, heroUpdate);
heroes.push(hero);
}
}
for(let [hid, { ce, inc }] of heroCe) {
if(changeHids.indexOf(hid) == -1) {
let hero = await HeroModel.updateHeroInfo(roleId, hid, { ce });
pushHeros.push({ hid, ce: hero.ce, incHeroCe: inc });
changeHids.push(hid);
}
}
let { topLineup, topLineupCe } = calCe.getTopLineup();
let roleCeUpdate = calCe.getRoleCeTable();
roleCe = await RoleCeModel.updateRoleCe(roleId, roleCeUpdate);
let role = await RoleModel.incRoleInfo(roleId, { ...roleIncUpdate, ce: roleInc }, { ...roleUpdate, topLineup, topLineupCe });
let guild = await GuildModel.updateCe(roleId, roleInc); // 公会更新战力
saveCeChangeLog(role, roleInc, role.ce, type, changeHids);
updateRank(roleId, serverId, topLineupCe, role, pushHeros, guild);
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: pushHeros, topLineupCe: reduceCe(topLineupCe) }), uids);
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: role.ce, heros: pushHeros, topLineupCe }), uids);
if(guild) {
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }]);
}
updateRank(roleId, serverId, topLineupCe, role, pushHeros);
return hero;
return { heroes, curRole: role }
}
// 修改全局战力并下发
export async function calAllHeroCe(type:number, sid: string, roleId: string, update: RoleUpdate, args?:Array<number>, params?: any) {
let result = await reCalAllHeroCe(type, roleId, update, args, params);
if(result.pushHeros.length > 0) {
return await pushCalAllHeroCe(roleId, sid, result);
} else {
return result;
async function treatHeroStar(calCe: CalCe, roleId: string, hid: number, star: number, starStage: number, quality: number, colorStar: number, colorStarStage: number, job: number, isUpStar: boolean) {
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
if(isUpStar) {
let school = await SchoolModel.findByHid(roleId, hid);
if(school) calCe.setSchool(true, hid, school.schoolId, star, colorStar, quality);
}
}
// 修改全局战力的推送
export async function pushCalAllHeroCe(roleId: string, sid: string, calResult: calPlayerReturn) {
let {role, pushHeros, topLineupCe, guild, serverId } = calResult;
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce), heros: pushHeros, topLineupCe: reduceCe(topLineupCe) }), uids);
if(guild) {
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }]);
}
updateRank(roleId, serverId, topLineupCe, role, pushHeros);
return calResult;
}
// 更新排行榜数据
async function updateRank(roleId: string, serverId: number, topLineupCe: number, role: RoleType, pushHeros: {hid: number, ce: number}[]) {
async function updateRank(roleId: string, serverId: number, topLineupCe: number, role: RoleType, pushHeros: {hid: number, ce: number}[], guild?: GuildType) {
// 最强阵容
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) {
@@ -89,9 +369,39 @@ 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 });
await r5.generParamAndSet(REDIS_KEY.TOP_LINEUP_INFO, { roleId }, { role });
if(guild) {
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }]);
}
}
export async function getSumCe(roleId: string, num: number) {
let roleCe = await RoleCeModel.findByRoleId(roleId);
let calCe = new CalCe(roleId);
calCe.setRoleCe(roleCe);
let arr = calCe.getResultCeArr();
let ce = 0;
for(let i = 0; i < num; i++) {
if(arr[i]) {
ce += arr[i].ce;
}
}
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;
}

View File

@@ -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';
/**
* 返回对手三人信息
@@ -61,7 +62,6 @@ export async function getEnemies(oppPlayers: OppPlayer[], winStreakNum: number)
* @param pLv 我的排名
*/
export async function refreshEnemies(role: RoleType, seasonNum: number, sumScore: number, score: number, pLv: number) {
console.log('#####',seasonNum, sumScore, score, pLv)
let { roleId } = role;
let chosenOpps: string[] = [];
let pvpHistoryOppParam: PvpOppCreateParam[] = [];
@@ -204,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); // 这个武将是否有这个得分
@@ -214,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);
@@ -373,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;

View File

@@ -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});
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,218 +1,17 @@
import { FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, REDIS_KEY, STATUS, TASK_TYPE, HERO_SYSTEM_TYPE } from "../../consts";
import { FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, REDIS_KEY, STATUS, TASK_TYPE, HERO_SYSTEM_TYPE, LINEUP_NUM, COUNTER } from "../../consts";
import { SkinModel } from "../../db/Skin";
import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../../db/Hero";
import { RoleModel, RoleType, RoleUpdate } from "../../db/Role";
import { SkinUpdate } from "../../db/Skin";
import { Figure, TopHero } from "../../domain/dbGeneral";
import { TaskListReturn } from "../../domain/roleField/task";
import { GuildModel, GuildType } from "../../db/Guild";
import { PvpDefenseModel } from "../../db/PvpDefense";
import { pick } from "underscore";
import { calculatetopLineup } from "../../pubUtils/playerCe";
import { nowSeconds } from "../../pubUtils/timeUtil";
import { saveCeChangeLog } from "../../pubUtils/logUtil";
import { getRandSingleEelm, reduceCe, resResult } from "../../pubUtils/util";
import { AttributeCal } from "../../domain/roleField/attribute";
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 { getInitHeroById } from "../roleService";
import { addItems, combineFigureInfo, unlockFigureWithoutSave } from "./rewardService";
export class UpdateHeroes {
roleId: string;
roleName: string;
serverId: number;
incHeroNum: number = 0;
incRoleCe: number = 0;
pushHeroes: {hid: number, incHeroCe: number, ce: number, hero: HeroUpdate}[] = [];
roleUpdate: RoleUpdate;
role: RoleType;
guild: GuildType;
constructor(roleId: string, roleName: string, serverId: number) {
this.roleId = roleId;
this.roleName = roleName;
this.serverId = serverId;
}
public setRole(role: RoleType) {
this.role = role;
}
public async getRole() {
if(!this.role) {
this.role = await RoleModel.findByRoleId(this.roleId);
}
return this.role;
}
public addRoleUpdateParam(param: RoleUpdate) {
this.roleUpdate = {...this.roleUpdate, ...param};
}
public async updateDbCe(isCreate: boolean, heroInfo: HeroUpdate, originCe = 0) {
let role = await this.getRole();
if(isCreate) this.incHeroNum ++;
if(heroInfo != originCe) this.incRoleCe += heroInfo.ce - originCe;
this.addRoleUpdateParam(await calculatetopLineup(role, heroInfo.hid, heroInfo.ce, heroInfo._id ));
this.pushHeroes.push({ hid: heroInfo.hid, incHeroCe: heroInfo.ce - originCe, ce: heroInfo.ce, hero: heroInfo });
}
// 更新战力相关的各个表
public async saveCeToDb() {
let role = await this.getRole();
// 更新role表
this.role = await RoleModel.updateRoleInfo(this.roleId, {
heroNum: this.incHeroNum + role.heroNum, ce: this.incRoleCe + role.ce, heroNumUpdatedAt: nowSeconds(), ...this.roleUpdate
});
// 更新guild表
if(role.hasGuild) {
this.guild = await GuildModel.updateCe(this.roleId, this.incRoleCe, true); // 公会更新战力
}
for(let { hid, incHeroCe } of this.pushHeroes) {
await PvpDefenseModel.updateCe(this.roleId, hid, incHeroCe); // 更新pvp防守阵战力
}
saveCeChangeLog(this.role, this.incRoleCe, this.role.ce, HERO_SYSTEM_TYPE.INIT, this.pushHeroes.map(cur => cur.hid));
}
public async updateRedisRank() {
let role = await this.getRole();
let { serverId, roleId, pushHeroes } = this;
// 更新军团信息
if(this.guild) {
let r = new Rank(REDIS_KEY.GUILD_INFO, { guildCode: this.guild.code });
await r.generParamAndSet(REDIS_KEY.GUILD_INFO, { guildCode: this.guild.code }, { guild: this.guild });
}
// 武将数量
if(this.incHeroNum > 0) {
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
}
// 最强阵容
let r = new Rank(REDIS_KEY.TOP_LINEUP_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, reduceCe(role.topLineupCe), 0, role);
// 最强武将
for(let { hid, ce, hero } of pushHeroes) {
let r2 = new Rank(REDIS_KEY.TOP_HERO_RANK, { serverId });
await r2.setRankWithHeroInfo(roleId, hid, reduceCe(ce), 0, hero);
let r4 = new Rank(REDIS_KEY.HERO_RANK, { serverId, hid });
await r4.setRankWithHeroInfo(roleId, hid, reduceCe(ce), 0, hero);
}
// 总战力
let r3 = new Rank(REDIS_KEY.SUM_CE_RANK, { serverId });
await r3.setRankWithRoleInfo(roleId, reduceCe(role.ce), 0, role);
// 更新最强五人阵容信息
let r5 = new Rank(REDIS_KEY.TOP_LINEUP_INFO, { serverId });
await r5.generParamAndSet(REDIS_KEY.TOP_LINEUP_INFO, { roleId }, { role });
}
public async pushMessage(pinus: any, sid: string) {
let role = await this.getRole();
let uids = [{ uid: this.roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: this.pushHeroes.map(cur => { return {...cur, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }}), topLineupCe: reduceCe(role.topLineupCe) }), uids);
}
}
export class CreateHeroes extends UpdateHeroes {
private resultHeroes: HeroType[] = [];
private heroNum = 0;
// 推送信息
private figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[] = [];
private skinPushMessages: { heros: {skins: HeroSkin[], hid: number}[], skins: {id: number, hid: number, inc: number, reason: number }[]} = { heros: [], skins: [] };
private async getSkinsOfThisHero(hid: number, initSkinInfo: SkinUpdate, isInit: boolean) {
let allSkins = isInit? []: await SkinModel.findbyRoleAndHid(this.roleId, hid);
let skin = await SkinModel.insertSkins(this.roleId, this.roleName, [initSkinInfo]);
let skinInfos = skin.map(cur => ({ id: cur.id, hid, inc: 1, reason: ITEM_CHANGE_REASON.GET_HERO_UNLOCK_SKIN}))
this.skinPushMessages.skins.push(...skinInfos);
if(skin) allSkins.push(...skin);
let skins: HeroSkin[] = [];
for(let skin of allSkins) {
skins.push(new HeroSkin(skin.id, skin.skinId, skin._id, skin.id == initSkinInfo.id));
}
return skins
}
// game-server里面创建武将
public async createWithHeroInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>) {
let role = await this.getRole();
// 数据处理
let conditions = new Array<{ type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>(); // 解锁头像条件
let initHeroInfos: HeroUpdate[] = [];
for (let [ hid, { heroInfo, skinInfo }] of infos) {
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid });
this.updateDbCe(true, heroInfo);
// 皮肤使用初始加载进内存的数据
let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: new SkinModel()._id }, false);
let newAttr = new AttributeCal();
newAttr.setLv(heroInfo.lv);
newAttr.setByDbData(role.attr, heroInfo.attr);
let heroCe = newAttr.calCe(); // 计算最终战力
initHeroInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id, ce: heroCe });
this.heroNum ++;
}
// 武将使用初始加载数据插入
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, initHeroInfos);
let heroSkins = this.resultHeroes.map(cur => { return pick(cur, ['hid', 'skins']) });
this.skinPushMessages.heros.push(...heroSkins);
// 头像解锁
let { figureInfo, frames, heads, spines } = unlockFigureWithoutSave(conditions, role);
this.figureInfos.push(figureInfo);
this.addRoleUpdateParam({ frames, heads, spines });
// 更新战力
await this.saveCeToDb();
}
// 创建初始账号时候的初始
public async createWithInitInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>, figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) {
this.figureInfos.push(figureInfo);
let heroeInfos: HeroUpdate[] = [];
for (let [ hid, { heroInfo, skinInfo }] of infos) {
this.updateDbCe(true, heroInfo);
let model = new SkinModel();
let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: model._id }, true);
heroeInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id});
this.heroNum ++;
}
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, heroeInfos);
}
public async pushMessage(sid: string) {
let role = await this.getRole();
let uids = [{ uid: this.roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: this.pushHeroes.map(cur => { return {...cur, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }}), topLineupCe: reduceCe(role.topLineupCe) }), uids);
let figureInfo = combineFigureInfo(this.figureInfos);
if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) {
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
}
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, this.skinPushMessages), uids);
pinus.app.get('channelService').pushMessageByUids('onHeroUpdate', resResult(STATUS.SUCCESS, { heroes: this.getResultHeroes() }), uids);
checkTaskInCreateHero(this.serverId, this.roleId, sid, this.heroNum, this.resultHeroes)
}
public getResultHeroes() {
return this.resultHeroes;
}
public getShowHeroes() {
return this.resultHeroes.map(cur => {
let hero = new HeroShowParam(cur);
return { ...hero, ce: reduceCe(cur.ce)}
});
}
}
import { addItems, unlockFigure, } from "./rewardService";
import { CounterModel } from "../../db/Counter";
import { calculateCes } from "../playerCeService";
import { RoleUpdate } from "../../db/Role";
/**
* 创建多个武将
@@ -221,29 +20,18 @@ export class CreateHeroes extends UpdateHeroes {
* @param serverId
* @param heroInfo
*/
export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam[]) {
export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam[], initRoleInfos?: RoleUpdate) {
let hids = heroInfo.map(cur => cur.hid);
let userHeroesMap = await HeroModel.findMapByHidRange(hids, roleId);
let infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }> = new Map(), pieces: ItemInter[] = [];
let createHids: number[] = [], pieces: ItemInter[] = [];
for (let h of heroInfo) {
let heroCount = h.count || 1;
if (userHeroesMap.has(h.hid)) {
let { pieceId, count } = transPiece(h.hid);
pieces.push({ id: pieceId, count: count * heroCount });
} else {
let initInfo: { heroInfo: HeroUpdate, skinInfo: SkinUpdate };
if(pinus.app.getServerType() == 'role') {
initInfo = getInitHeroById(h.hid);
} else {
let roleServers = pinus.app.getServersByType('role');
let server = getRandSingleEelm(roleServers);
initInfo = await pinus.app.rpc.role.roleRemote.getInitHeroById.toServer(server.id, h.hid);
}
initInfo.heroInfo = { ...initInfo.heroInfo, ...h };
infos.set(h.hid, initInfo);
createHids.push(h.hid);
userHeroesMap.set(h.hid, null);
if (heroCount > 1) {
let { pieceId, count } = transPiece(h.hid);
@@ -252,24 +40,60 @@ export class CreateHeroes extends UpdateHeroes {
}
}
let resultHeroes: HeroType[] = [], resultItems: RewardInter[] = [], heroes: HeroShowParam[] = [];
if (infos.size > 0) {
let createHero = new CreateHeroes(roleId, roleName, serverId);
await createHero.createWithHeroInfo(infos);
await createHero.pushMessage(sid);
await createHero.updateRedisRank();
heroes = createHero.getShowHeroes();
resultHeroes = createHero.getResultHeroes();
let resultHeroes: HeroType[] = [], resultItems: RewardInter[] = [], showHeroes: HeroShowParam[] = [];
let figureConditions: { type: FIGURE_UNLOCK_CONDITION, paramHid: number }[] = [];
let incHeroNum = 0;
let skins: SkinUpdate[] = [];
if (createHids.length > 0) {
let heroInfos = new Map<number, HeroUpdate>();
for(let hid of createHids) {
let initSkin = SkinModel.getInitInfo(hid);
skins.push(initSkin); // 初始皮肤
let seqId = await CounterModel.getNewCounter(COUNTER.HID) || -1;
let initHero = HeroModel.getInitInfo(hid, { seqId, roleId, roleName, skins: [new HeroSkin(initSkin)] });
heroInfos.set(hid, initHero);
figureConditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: hid });
incHeroNum ++;
}
await unlockFigure(sid, roleId, figureConditions);
let roleUpdata: RoleUpdate = { heroNumUpdatedAt: nowSeconds() };
if(initRoleInfos) {
roleUpdata = { ...initRoleInfos, ...roleUpdata }
}
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);
}
let uids = [{ uid: roleId, sid }];
await SkinModel.insertSkins(roleId, roleName, skins);
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, getSkinPushMsg(resultHeroes, skins)), uids);
pinus.app.get('channelService').pushMessageByUids('onHeroUpdate', resResult(STATUS.SUCCESS, { heroes }), uids);
}
if (pieces.length > 0) {
let goods = await addItems(roleId, roleName, sid, pieces, ITEM_CHANGE_REASON.HERO_TRANSFER_PIECE);
resultItems = goods;
}
return { heroes, resultHeroes, goods: resultItems }
return { heroes: showHeroes, resultHeroes, goods: resultItems }
}
export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam) {
let result = await createHeroes(roleId, roleName, sid, serverId, [heroInfo]);
return result;
}
function getSkinPushMsg(resultHeroes: HeroType[], skins: SkinUpdate[]) {
let skinPushMessages: {heros: {skins: HeroSkin[], hid: number}[], skins: {id: number, hid: number, inc: number, reason: number }[]} = { heros: [], skins:[] }; // 皮肤推送信息
for(let { hid, skins } of resultHeroes) {
skinPushMessages.heros.push({ hid, skins });
}
for(let { id, hid } of skins) {
skinPushMessages.skins.push({ id, hid, inc: 1, reason: ITEM_CHANGE_REASON.GET_HERO_UNLOCK_SKIN })
}
return skinPushMessages;
}

View File

@@ -1,61 +0,0 @@
import { DEFAULT_HEROES, DEFAULT_HERO_LV, FIGURE_UNLOCK_CONDITION, HERO_SYSTEM_TYPE, LINEUP_NUM } from "../../consts";
import { HeroModel, HeroSkin, HeroUpdate } from "../../db/Hero";
import { RoleModel, RoleUpdate } from "../../db/Role";
import { SkinModel, SkinUpdate } from "../../db/Skin";
import { TopHero } from "../../domain/dbGeneral";
import { CalHeroCe, CalRoleCe } from "../../domain/roleField/calCe";
import { gameData, getHeroExpByLv } from "../../pubUtils/data";
import { unlockFigureWithoutSave } from "./rewardService";
// 储存在内存中的初始数据
export function getInitRoleInfo() {
let topLineup: TopHero[] = [], topLineupCe = 0, allCe = 0,
heroes: HeroUpdate[] = [], initHeroes: HeroUpdate[] = [], initSkins: SkinUpdate[] = [], heroNum = 0,
conditions: {type: FIGURE_UNLOCK_CONDITION, paramHid: number }[] = [];
let role = new RoleModel();
let calRoleCe = new CalRoleCe(role);
let roleAttr = calRoleCe.cal(HERO_SYSTEM_TYPE.INIT);
for(let { actorId: hid } of gameData.recruit) {
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = gameData.hero.get(hid);
// 皮肤
let skin = new SkinModel();
let dicFashion = gameData.fashion.get(initialSkin);
if(!dicFashion) {
console.log(`not found skin: ${initialSkin} of ${hid}`);
continue;
}
let skinInfo = { ...skin.toJSON(), id: initialSkin, hid, skinName: dicFashion.name, skinId: dicFashion.heroId };
initSkins.push(skinInfo);
// 武将
let hero = new HeroModel();
let heroInfo = {...hero.toJSON(), hid, star, quality, hName, job, skins: [new HeroSkin(initialSkin, skinInfo.skinId, skinInfo._id, true)], skinId: skinInfo.skinId, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0 };
let calHeroCe = new CalHeroCe(hid, heroInfo);
let heroAttr = calHeroCe.cal(HERO_SYSTEM_TYPE.INIT);
let ce = calHeroCe.getCalculatedCe(roleAttr);
heroes.push({ ...heroInfo, attr: heroAttr, ce, historyCe: ce });
// 更新role表
if(DEFAULT_HEROES.includes(hid)) {
// 头像
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: hid });
allCe += ce;
heroNum++;
initHeroes.push({ ...heroInfo, attr: heroAttr, ce, historyCe: ce });
}
}
let { figureInfo, heads, frames, spines } = unlockFigureWithoutSave(conditions, role);
// 最强阵容
initHeroes.sort((a, b) => { return b.ce - a.ce });
for(let i = 0; i < LINEUP_NUM; i++) {
if(initHeroes[i]) {
let { hid, ce, _id } = initHeroes[i];
topLineup.push({ hid, ce, hero: _id });
topLineupCe += ce;
}
}
let initRole: RoleUpdate = { topLineupCe, topLineup, attr: roleAttr, ce: allCe, heroNum, heroNumUpdatedAt: Date.now(), heads, frames, spines };
return {
role: initRole, heroes, skins: initSkins, figureInfo
}
}

View File

@@ -2,7 +2,6 @@ import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HAN
import { getDecimalCnt, getRandEelm, getRandEelmWithWeight, getRandSingleEelm, getRandValueByMinMax, resResult } from '../../pubUtils/util';
import { RoleModel, RoleType } from '../../db/Role';
import { setAp } from '../actionPointService';
import { pushCalAllHeroCe, calPlayerCeAndSave, calAllHeroCe } from '../playerCeService';
import { ItemModel, ItemType } from '../../db/Item';
import { STATUS } from '../../consts/statusCode';
import { pinus } from 'pinus';
@@ -23,10 +22,9 @@ import { reportTAEvent, reportTAUserSet } from '../sdkService';
import { saveCoinChangeLog, saveFigureInfoLog, saveGoldChangeLog, saveItemChangeLog } from '../../pubUtils/logUtil';
import { JewelModel, JewelType, jewelUpdate, RandSe } from '../../db/Jewel';
import { updateEplaces } from '../equipService';
import { checkPopUpConditionInCreateHero } from '../activity/popUpShopService';
import { CreateHeroes } from './createHero';
import { combineItems, getCoinEventProperties, getGoldEventProperties, sortItems } from './util';
import { nowSeconds } from '../../pubUtils/timeUtil';
import { calculateCeWithHero, calculateCeWithRole } from '../playerCeService';
@@ -71,7 +69,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
heroMap.get(jewel.hid).jewels.push(jewel);
}
}
for(let [_hid, {hero, jewels} ] of heroMap) {
for(let [hid, {hero, jewels} ] of heroMap) {
// 脱下天晶石
let update = new Map<number, Partial<EPlace>>();
for(let jewel of jewels) {
@@ -82,7 +80,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
}
}
let { newEplace } = updateEplaces(hero.ePlace, update);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, { ePlace: newEplace }, [...update.keys()]);
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, roleId, role.serverId, sid, hid, { ePlace: newEplace }, { ePlaceIds: [...update.keys()] });
}
@@ -216,8 +214,6 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
pushHeroSkinMsg(heroskins, skinInfos, uids); // 推送onHeroSkinChange
saveItemChangeLog(roleId, skinInfos, reason);
}
// 推送全局加成信息
if(calAllHeroResult) await pushCalAllHeroCe(roleId, sid, calAllHeroResult);
}
// 5. 获得头像和相框等
@@ -362,12 +358,12 @@ 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 calAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, sid, roleId, {}, [skinId]); // 全局加成
await calculateCeWithRole(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, hero.serverId, sid, {}, { skinId }); // 全局加成
if (hero) { // 有武将的,将皮肤链接到武将上
let curSkin = hero.skins.find(cur => cur.id == skinId);
if (!curSkin) {
hero.skins.push(new HeroSkin(skin.id, skin.skinId, skin._id, enable ));
hero.skins.push(new HeroSkin(skin, enable));
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
}
return hero;

View File

@@ -1,14 +1,14 @@
import { ChannelUser } from './../domain/ChannelUser';
import { Channel, pinus } from 'pinus';
import { getRandValueByMinMax, getRandEelm, decodeIdCntArrayStr } from '../pubUtils/util';
import { DEFAULT_HEROES, ROLE_SELECT, TALENT_RELATION_TYPE, TERAPH_RANDOM } from "../consts";
import { DEFAULT_HEROES, LINEUP_NUM, ROLE_SELECT, TALENT_RELATION_TYPE, TERAPH_RANDOM } from "../consts";
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
import { Teraph, RoleModel, RoleType, RoleUpdate } from '../db/Role';
import { SCHOOL } from '../pubUtils/dicParam';
import { gameData, getHeroInitTalent } from '../pubUtils/data';
import { SchoolModel } from '../db/School';
import { SclResultInter, SclPosInter, RewardInter, ItemInter } from '../pubUtils/interface';
import { HeroSkin, HeroUpdate, Talent } from '../db/Hero';
import { HeroModel, HeroSkin, HeroUpdate, Talent } from '../db/Hero';
import { SkinUpdate } from '../db/Skin';
import { Figure } from '../domain/dbGeneral';
import { pick } from 'underscore';
@@ -251,4 +251,4 @@ export function initSkinTalent(skins: HeroSkin[], isAll = false) {
}
}
return newSkins
}
}

View File

@@ -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

View File

@@ -64,21 +64,21 @@ module.exports = {
'required uInt32 code': 2,
'required Data data': 3
},
'onPlayerCeUpdate': {
'message Data': {
"message Hero": {
'required uInt32 hid': 1,
'required uInt32 ce': 2,
'required sInt32 incHeroCe': 3,
},
'required sInt32 ce': 1,
'repeated Hero heros': 2,
'required uInt32 topLineupCe': 3
},
'required string msg': 1,
'required uInt32 code': 2,
'required Data data': 3
},
// 'onPlayerCeUpdate': {
// 'message Data': {
// "message Hero": {
// 'required uInt32 hid': 1,
// 'required uInt32 ce': 2,
// 'required sInt32 incHeroCe': 3,
// },
// 'required sInt32 ce': 1,
// 'repeated Hero heros': 2,
// 'required uInt32 topLineupCe': 3
// },
// 'required string msg': 1,
// 'required uInt32 code': 2,
// 'required Data data': 3
// },
'onPlayerDataChange': {
'message Data': {
'optional uInt32 coin': 1,

View File

@@ -177,7 +177,6 @@ function checkRoleHero(heros) {
expect(hero.exp).to.be.a('number');
expect(hero.lv).to.be.a('number');
expect(hero.ce).to.be.a('number');
expect(hero.historyCe).to.be.a('number');
expect(hero.star).to.be.a('number');
expect(hero.starStage).to.be.a('number');
expect(hero.colorStar).to.be.a('number');

View File

@@ -58,7 +58,7 @@ export default class Activity extends Service {
if(activity.type == ACTIVITY_TYPE.SIGN_IN || activity.type == ACTIVITY_TYPE.SIGN_IN_VIP) {
// 签到活动的不显示期内也可以编辑
let signInObj = new SignInData(activity, 0);
let signInObj = new SignInData(activity, 0, 0);
if(signInObj.beginTime < now.getTime() && signInObj.endTime > now.getTime() ) {
return this.ctx.service.utils.resResult(STATUS.GM_CAN_NOT_EDIT_ACT);
}

View File

@@ -1,12 +1,11 @@
import { UserModel } from '@db/User';
import { CeAttrDataRole, RoleModel } from '@db/Role';
import { RoleModel } from '@db/Role';
import { HeroModel } from '@db/Hero';
import { Service } from 'egg';
import { STATUS, REDIS_KEY, WAR_TYPE } from '@consts';
import { ItemModel } from '@db/Item';
import { gameData } from '@pubUtils/data';
import { AttributeCal } from '@domain/roleField/attribute';
import { smsModel } from '@db/Sms';
import { isString } from 'underscore';
import { GiftCodeModel } from '@db/GiftCode';
@@ -22,6 +21,7 @@ import { RedisClient } from 'redis';
import { UserGuildModel } from '@db/UserGuild';
import { TowerRecordModel } from '@db/TowerRecord';
import { nowSeconds } from '@pubUtils/timeUtil';
import { RoleCeModel, RoleCeType } from '@db/RoleCe';
// import { resResult } from '@pubUtils/util';
@@ -295,18 +295,18 @@ export default class GMUsers extends Service {
const heroes = await HeroModel.findByCondition(page, pageSize, sortField, sortOrder, form);
const total = await HeroModel.countByCondition( form )
let roleMap = new Map<string, CeAttrDataRole[]>();
let roleMap = new Map<string, RoleCeType>();
for(let { roleId } of heroes) {
if(!roleMap.has(roleId)) {
let role = await RoleModel.findByRoleId(roleId, 'attr');
roleMap.set(roleId, role.attr);
let roleCe = await RoleCeModel.findByRoleId(roleId);
roleMap.set(roleId, roleCe);
}
}
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}
let roleCe = roleMap.get(cur.roleId);
let obj = roleCe.attributes.find(ccur => ccur.hid == cur.hid);
return {...cur, calculatedAttr: obj.attrs, env: ctx.app.config.realEnv}
})
return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total })

View File

@@ -99,13 +99,17 @@ export const ABI_TYPE_SUB = [
export enum SEID_TYPE {
/**属性固定值加成(数值) */
TYPE101 = 1,
/**基础属性加百分比除以1000以后加到ratioUp */
TYPE103 = 2,
/**次级属性的百分比加成乘以100后加到fixUp */
TYPE104 = 3,
FIX = 1,
/**基础属性加百分比除以1000 */
MAIN_RATIO = 2,
/**次级属性的百分比加成 */
SUB_RATIO = 3,
/**基础属性加百分比除以1000 */
MAIN_RATIO_2 = 4,
/**次级属性的百分比加成 */
SUB_RATIO_2 = 5,
/**复合属性 */
TYPE999 = 999,
MIX = 999,
}
export enum ABI_STAGE {

View File

@@ -1,8 +1,8 @@
//武将养成系统分类
export enum HERO_SYSTEM_TYPE {
INIT = 0, // 初始武将
STAR = 1, // 升
LVUP = 2, // 升
LVUP = 1, // 升
STAR = 2, // 升
COLORSTAR = 3, // 觉醒
QUALITY = 4, // 升品
TRAIN = 5, // (职业)训练
@@ -10,11 +10,11 @@ export enum HERO_SYSTEM_TYPE {
SKIN =7, // 皮肤
FAVOUR =8, // 好感
CONNECT =9, // 羁绊
EQUIP = 10, // 装备穿脱
EQUIP_BASE = 11, // 装备栏升级,装备精炼等
RESTRENGTHEN = 12, // 洗练
JEWEL_ON = 13, // 穿宝石
JEWEL_OFF = 14, // 脱宝石
// EQUIP = 10, // 装备穿脱
// EQUIP_BASE = 11, // 装备栏升级,装备精炼等
// RESTRENGTHEN = 12, // 洗练
// JEWEL_ON = 13, // 穿宝石
// JEWEL_OFF = 14, // 脱宝石
ADD_SKIN = 15, // 第一次获取皮肤(全局)
SCHOOL = 16, // 百家学宫
SCROLL = 17, // 名将谱
@@ -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,

View File

@@ -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 {

View File

@@ -540,6 +540,7 @@ export const FILENAME = {
DIC_STONE: 'dic_zyz_stone',
DIC_JEWEL_CONDITION: 'dic_zyz_jewel_condition',
DIC_MAIN_STAR_BOX: 'dic_zyz_main_star_reward',
DIC_EQUIP_STRENGTH_ATTR: 'dic_zyz_equipStrengthAttr',
}
export const WAR_RELATE_TABLES = [

View File

@@ -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用于增加战力的时候加入总战力

View File

@@ -1,55 +1,11 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, Ref, mongoose, DocumentType } from '@typegoose/typegoose';
// import Equip, { } from './Equip';
import { CounterModel } from './Counter';
import { COUNTER, HERO_CE_RATIO } from '../consts';
import { reduceCe } from '../pubUtils/util';
import Skin from './Skin';
import { DEFAULT_HERO_LV } from '../consts';
import Skin, { SkinUpdate } from './Skin';
import { SearchHeroParam } from '../domain/backEndField/search';
import { Reward } from '../domain/battleField/pvp';
import { 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;
}
}
}
import { gameData, getHeroExpByLv, getHeroInitTalent } from '../pubUtils/data';
/**
* 英雄表
@@ -88,12 +44,12 @@ export class HeroSkin {
@prop({ required: true })
usedTalentPoint: number; // 已使用的天赋点数
constructor(id: number, skinId: number, skin: string, enable: boolean) {
this.id = id;
this.skinId = skinId;
this.skin = skin;
constructor(skin: SkinUpdate, enable = true) {
this.id = skin.id;
this.skinId = skin.skinId;
this.skin = skin._id;
this.enable = enable;
this.talent = getHeroInitTalent(skinId);
this.talent = getHeroInitTalent(skin.skinId);
this.usedTalentPoint = 0;
}
}
@@ -111,7 +67,7 @@ export class EPlace {
@prop({ required: true })
equipId: number;
@prop({ required: true })
lv: number = 1;
lv: number = 0;
@prop({ required: true })
quality: number = 1;
@prop({ required: true })
@@ -162,14 +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) })
ce: number; // 武将战力
@prop({ required: false, set: (val: boolean) => val, get: () => true })
isReducedCe: boolean; // 如果战力没有缩过就会返回false缩过了就会返回true
@prop({ required: true, default: 0 })
historyCe: number; // 武将历史最高战力
@prop({ required: true, type: CeAttrData, default: [], _id: false })
attr: CeAttrData[]; // 影响战力的属性
ce: number; // 武将战力
@prop({ required: true, default: 1 })
star: number; // 星级
@@ -274,39 +224,31 @@ export default class Hero extends BaseModel {
return hero;
}
public static getInitInfo(heroInfo: HeroUpdate = {}): HeroUpdate {
public static getInitInfo(hid: number, heroInfo: HeroUpdate = {}): HeroUpdate {
let dicHero = gameData.hero.get(hid)
let { quality, initialStars: star, jobid: job, name: hName } = dicHero;
const doc = new HeroModel();
const update = { ...doc.toJSON(), ...heroInfo};
const update = { ...doc.toJSON(), hid, skinId: hid, hName, star, quality, job, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0, ...heroInfo};
delete update._id;
return update
}
public static async createHero(heroInfo: HeroUpdate, lean = true) {
const seqId = await CounterModel.getNewCounter(COUNTER.HID) || -1;
const update = this.getInitInfo({ ...heroInfo, seqId });
const hero: HeroType = await HeroModel.findOneAndUpdate({ roleId: heroInfo.roleId, hid: heroInfo.hid }, update, { upsert: true, new: true }).lean(lean);
return hero;
}
// public static async createHero(heroInfo: HeroUpdate, lean = true) {
// const seqId = await CounterModel.getNewCounter(COUNTER.HID) || -1;
// const update = this.getInitInfo(heroInfo.hid, { ...heroInfo, seqId });
// const hero: HeroType = await HeroModel.findOneAndUpdate({ roleId: heroInfo.roleId, hid: heroInfo.hid }, update, { upsert: true, new: true }).lean(lean);
// return hero;
// }
public static async insertHeroes(roleId: string, roleName: string, serverId: number, heroInfos: HeroUpdate[]) {
let insertInfos: HeroUpdate[] = [];
for(let hero of heroInfos) {
const seqId = await CounterModel.getNewCounter(COUNTER.HID) || -1;
insertInfos.push({ ...hero, seqId, roleId, roleName, serverId })
}
await HeroModel.insertMany(insertInfos);
return <HeroType[]>insertInfos;
}
public static async sumTopHeroCe(roleId: string, num: number) {
let ce: Array<{ historyCe: number }> = await HeroModel.aggregate([
{ $match: { roleId } },
{ $sort: { historyCe: -1 } },
{ $limit: num },
{ $group: { _id: null, historyCe: { $sum: '$historyCe' } } }
]);
return ce.length > 0 ? ce[0].historyCe : 0;
}
// public static async insertHeroes(roleId: string, roleName: string, serverId: number, heroInfos: HeroUpdate[]) {
// let insertInfos: HeroUpdate[] = [];
// for(let hero of heroInfos) {
// const seqId = await CounterModel.getNewCounter(COUNTER.HID) || -1;
// insertInfos.push({ ...hero, seqId, roleId, roleName, serverId })
// }
// await HeroModel.insertMany(insertInfos);
// return <HeroType[]>insertInfos;
// }
public static async sumHeroCe(roleId: string) {
let ce: Array<{ ce: number }> = await HeroModel.aggregate([
@@ -321,13 +263,6 @@ export default class Hero extends BaseModel {
return heroes;
}
public static async updateCe(roleId: string, hid: number, ce: number, oldCe: number, historyCe: number, lean = true) {
let distance = ce - oldCe;
let historyDistance = ce > historyCe ? ce - historyCe : 0;
let result: HeroType = await HeroModel.findOneAndUpdate({ roleId, hid }, { $inc: { ce: distance, historyCe: historyDistance } }).lean(lean);
return result;
}
public static async deleteAccount(roleId: string) {
let result = await HeroModel.deleteMany({ roleId });
return result;
@@ -340,7 +275,7 @@ export default class Hero extends BaseModel {
public static async updateHeroInfo(roleId: string, hid: number, heroUpdate: HeroUpdate, select?: string, getters = false) {
delete heroUpdate._id;
let result: HeroType = await HeroModel.findOneAndUpdate({ roleId, hid }, { $set: heroUpdate }, { new: true }).select(select).lean({ getters });
let result: HeroType = await HeroModel.findOneAndUpdate({ roleId, hid }, { $set: heroUpdate }, { new: true, upsert: true }).select(select).lean({ getters });
return result;
}

View File

@@ -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; // 总金币

122
shared/db/RoleCe.ts Normal file
View File

@@ -0,0 +1,122 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
// 全局加成
export class AttrCell {
@prop({ required: true })
attrId: number; // 属性id
@prop({ required: true, type: Number })
values: number[]; // 战力公式中的全局加成的数据,查表后的结果
}
// 单武将加成
export class HeroAttr {
@prop({ required: true })
hid: number; // 武将id
@prop({ required: true })
lv: number;
@prop({ required: true, type: () => AttrCell, _id: false })
attrs: AttrCell[];
@prop({ required: true })
historyCe: number;
@prop({ required: true })
objectId: string;
}
export class EquipAttr {
@prop({ required: true })
hid: number; // 武将id
@prop({ required: true })
eplaceId: number; // 装备位置
@prop({ required: true })
lv: number;
@prop({ required: true, type: () => AttrCell, _id: false })
attrs: AttrCell[];
}
// 百家学宫加成
export class SchoolAttr {
@prop({ required: true })
hid: number; // 武将id
@prop({ required: true })
attrId: number; // 属性id
@prop({ required: true })
value: number; // 百家学宫有多个武将单独拎出来方便计算计算之后结果存到globaAttrs的global1
}
// 名将谱加成
export class ScrollAttr {
@prop({ required: true })
hid: number; // 武将id
@prop({ required: true })
attrId: number; // 属性id
@prop({ required: true })
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
}
/**
* 属性表
*/
@index({ roleId: 1 })
@index({ roleId: 1 })
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[]
@prop({ required: true, type: HeroAttr, _id: false })
heroAttrs: HeroAttr[]
@prop({ required: true, type: EquipAttr, _id: false })
equipAttrs: EquipAttr[]
@prop({ required: true, type: SchoolAttr, _id: false })
schoolAttrs: SchoolAttr[];
@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;
}
public static async updateRoleCe(roleId: string, update: RoleCeUpdate) {
let result: RoleCeType = await RoleCeModel.findOneAndUpdate({ roleId }, { $set: update }, { new: true, upsert: true }).lean();
return result;
}
}
export const RoleCeModel = getModelForClass(RoleCe);
export interface RoleCeType extends Pick<DocumentType<RoleCe>, keyof RoleCe> { };
export type RoleCeUpdate = Partial<RoleCeType>;

View File

@@ -1,5 +1,6 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
import { gameData } from '../pubUtils/data';
@index({ roleId: 1, id: 1 })
@index({ seqId: 1 })
@modelOptions({ schemaOptions: { id: false } })
@@ -28,6 +29,15 @@ export default class Skin extends BaseModel {
return rec;
}
public static getInitInfo(hid: number): SkinUpdate {
let dicHero = gameData.hero.get(hid);
let dicFashion = gameData.fashion.get(dicHero.initialSkin)
const doc = new SkinModel();
const update = { ...doc.toJSON(), id: dicFashion.id, skinId: dicFashion.heroId, skinName: dicFashion.name, hid};
delete update._id;
return update
}
public static async insertSkins(roleId: string, roleName: string, skinInfos: SkinUpdate[]) {
let insertInfos: SkinUpdate[] = [];
for(let skinInfo of skinInfos) {

View File

@@ -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 })

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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));
}
}

View File

@@ -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 "./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);
}

View File

@@ -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;
@@ -41,7 +40,6 @@ export class HeroParam {
exp: number; // 经验值
lv: number; // 武将等级
ce: number; // 武将战力
historyCe: number; // 武将历史最高战力
star: number; // 星级
starStage: number; // 星级六维阶段
colorStar: number; // 觉醒, 彩星
@@ -74,13 +72,7 @@ export class HeroParam {
this.hName = hero.hName;
this.exp = hero.exp;
this.lv = hero.lv;
if(hero.isReducedCe) {
this.ce = hero.ce;
this.historyCe = hero.historyCe;
} else {
this.ce = reduceCe(hero.ce);
this.historyCe = reduceCe(hero.historyCe);
}
this.ce = hero.ce;
this.star = hero.star;
this.starStage = hero.starStage;
this.colorStar = hero.colorStar;

View File

@@ -103,6 +103,7 @@ import { dicJewelCondition, loadJewelCondition } from './dictionary/DicJewelCond
import { dicMainStarBox, dicMainStarBoxByChapter, loadMainStarBox } from './dictionary/DicMainStarBox';
import { dicHeroTalent, initTalents, loadHeroTalent } from './dictionary/DicHeroTalent';
import { Talent } from "../db/Hero";
import { dicEquipStrengthAttr, loadEquipStrengthAttr } from './dictionary/DicEquipStrengthAttr';
export const gameData = {
daily: dicDaily,
@@ -257,6 +258,7 @@ export const gameData = {
heroTalent: dicHeroTalent,
initTalents: initTalents,
talentPointOfJob: talentPointOfJob,
equipStrengthAttr: dicEquipStrengthAttr
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据
@@ -333,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) {
@@ -882,6 +884,11 @@ export function getHeroInitTalent(skinId: number) {
return ids.map(id => (new Talent(id)));
}
export function getEquipStrenthenAttr(equipId: number, lv: number) {
let result = gameData.equipStrengthAttr.get(`${equipId}_${lv}`);
return result
}
// 初始加载
function initDatas() {
parseDicParam();
@@ -1049,6 +1056,7 @@ function loadDatas() {
loadJewelCondition();
loadMainStarBox();
loadHeroTalent();
loadEquipStrengthAttr();
}
// 重载dicParam

View File

@@ -0,0 +1,39 @@
// 装备强化表
import { readFileAndParse, decodeArrayListStr } from '../util'
import { FILENAME } from '../../consts'
export interface DicEquipStrengthAttr {
// id
readonly id: number;
// 装备id
readonly equipId: number;
// 等级
readonly lv: number;
// 属性
readonly attr: {id: number, num: number}[];
}
export const dicEquipStrengthAttr = new Map<string, DicEquipStrengthAttr>();
export function loadEquipStrengthAttr() {
dicEquipStrengthAttr.clear();
let arr = readFileAndParse(FILENAME.DIC_EQUIP_STRENGTH_ATTR);
arr.forEach(o => {
o.attr = parseAttr(o.attr);
dicEquipStrengthAttr.set(`${o.equipId}_${o.lv}`, o);
});
arr = undefined;
}
function parseAttr(str: string) {
let result = new Array<{id: number, num: number}>();
if(!str) return result;
let decodeArr = decodeArrayListStr(str);
for(let [id, num] of decodeArr) {
if(isNaN(parseInt(id)) || isNaN(parseInt(num))) {
throw new Error('data table format wrong');
}
result.push({id: parseInt(id), num: parseInt(num)});
}
return result
}

View File

@@ -10,7 +10,7 @@ export interface DicEquipSuit {
// 套装内含的装备编号
readonly equips: number[];
// 按星级可解锁的属性
readonly effect: { star: number, seid: number }[];
readonly effect: { star: number, id: number, val: number }[];
}
export const dicEquipSuit = new Map<number, DicEquipSuit>();
@@ -30,14 +30,14 @@ export function loadEquipSuit() {
}
function parseEffect(str: string) {
let result = new Array<{star: number, seid: number}>();
let result = new Array<{star: number, id: number, val: number}>();
if(!str) return result;
let decodeArr = decodeArrayListStr(str);
for(let [star, seid] of decodeArr) {
if(isNaN(parseInt(star)) || isNaN(parseInt(seid))) {
for(let [star, id, val] of decodeArr) {
if(isNaN(parseInt(star)) || isNaN(parseInt(id)) || isNaN(parseInt(val))) {
throw new Error('data table format wrong');
}
result.push({star: parseInt(star), seid: parseInt(seid)});
result.push({star: parseInt(star), id: parseInt(id), val: parseInt(val)});
}
return result
}

View File

@@ -23,8 +23,10 @@ export interface DicJob {
readonly trainingConsume: Array<RewardInter>;
// 升阶消耗
readonly upGradeConsume: Array<RewardInter>;
// 每阶升级属性
// 每阶升级属性 stage => {}
readonly ceAttr: Map<number, {id: number, attr: number}>;
// 次级属性基础 attr => value attr1
readonly baseSubAttr: {id: number, val: number}[];
// 一共有多少阶升级
readonly maxStage: number;
// 到这一阶能获得多少天赋点
@@ -32,7 +34,7 @@ export interface DicJob {
}
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicJobKeys: KeysEnum<DicJob> = {jobid: true, name: true, grade: true, unlockLevel: true, job_class: true, type: true, trainingConsume: true, upGradeConsume: true, ceAttr: true, maxStage: true, talentPoint: true};
const DicJobKeys: KeysEnum<DicJob> = {jobid: true, name: true, grade: true, unlockLevel: true, job_class: true, type: true, trainingConsume: true, upGradeConsume: true, ceAttr: true, maxStage: true, talentPoint: true, baseSubAttr: true};
export const dicJob = new Map<number, DicJob>();
export const jobClassMaxGrades = new Map<number, {grade:number, jobid:number}>();
@@ -54,6 +56,7 @@ export function loadJob() {
o.maxStage = o.trainingConsume.length;
o.upGradeConsume = parseGoodStr(o.upGradeConsume);
o.ceAttr = parseCeAttr(o.maxStage, o.attr);
o.baseSubAttr = parseAttribute(o.baseSecondAttr||'');
dicJob.set(o.jobid, _.pick(o, Object.keys(DicJobKeys)));
let jobClass = jobClassMaxGrades.get(o.job_class);
if (!jobClass || jobClass.grade < o.grade) {
@@ -93,4 +96,17 @@ function parseCeAttr(maxStage: number, str: string) {
result.set(i, { id: parseInt(id), attr: parseFloat(attr) });
}
return result
}
}
function parseAttribute(str: string) {
let result = new Array<{ id: number, val: number }>();
if (!str) return result;
let decodeArr = decodeArrayListStr(str);
for (let [id, val] of decodeArr) {
if (isNaN(parseInt(id)) || isNaN(parseInt(val))) {
throw new Error('data table format wrong');
}
result.push({ id: parseInt(id), val: parseInt(val) });
}
return result
}

View File

@@ -36,7 +36,7 @@ export function loadRandomEffectPool() {
arr.forEach(o => {
o.rate = parseRate(o.count);
o.gainValueArr = parseNumberList(o.gainvalue);
o.gainValueArr = parseNumberList(o.gainValue);
dicRandomEffectPool.set(o.id, o);
dicRandomEffectPoolByGroupAndLv.set(`${o.group}_${o.level}`, o.id);
});

View File

@@ -23,6 +23,7 @@ export interface DicTeraph {
readonly upMaterial:Array<RewardInter>;
readonly assiAttrValue:Map<number, number>; // 次级属性
readonly basicAttrValue:Map<number, number>; // 主属性
readonly upGradeMaterial:Array<RewardInter>;
}
export const dicTeraph = new Map<string, DicTeraph>();
@@ -42,6 +43,7 @@ export function loadTeraph() {
criEffect: true,
upMaterial: true,
assiAttrValue: true,
basicAttrValue: true,
upGradeMaterial: true,
}
@@ -51,6 +53,7 @@ export function loadTeraph() {
o.upMaterial = parseGoodStr(o.upMaterial);
o.mainAttrMax = parseMainAttrMax(o);
o.mainAttrUp = parseMainAttrUp(o);
o.basicAttrValue = parseBasicAttr(o);
dicTeraph.set(o.index + '_' + o.grade, _.pick(o, Object.keys(DicTeraphKeys)));
});
@@ -72,10 +75,10 @@ function parseAttr(str: string) {
function parseMainAttrMax(elem) {
let result = new Map<number, number>();
result.set(ABI_TYPE.ABI_HP, elem.hpMax);
result.set(ABI_TYPE.ABI_ATK, elem.atkMax);
result.set(ABI_TYPE.ABI_DEF, elem.defMax);
result.set(ABI_TYPE.ABI_MDEF, elem.mdefMax);
result.set(ABI_TYPE.ABI_HP, elem.hpMax - elem.hpBasis);
result.set(ABI_TYPE.ABI_ATK, elem.atkMax - elem.atkBasis);
result.set(ABI_TYPE.ABI_DEF, elem.defMax - elem.defBasis);
result.set(ABI_TYPE.ABI_MDEF, elem.mdefMax - elem.mdefBasis);
return result
}
@@ -86,4 +89,13 @@ function parseMainAttrUp(elem) {
result.set(ABI_TYPE.ABI_DEF, elem.defUp);
result.set(ABI_TYPE.ABI_MDEF, elem.mdefUp);
return result
}
function parseBasicAttr(elem) {
let result = new Map<number, number>();
result.set(ABI_TYPE.ABI_HP, elem.hpBasis);
result.set(ABI_TYPE.ABI_ATK, elem.atkBasis);
result.set(ABI_TYPE.ABI_DEF, elem.defBasis);
result.set(ABI_TYPE.ABI_MDEF, elem.mdefBasis);
return result
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,11 @@
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 } 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';
@@ -114,18 +113,6 @@ export function decodeIdCntArrayStr(str: string, multi: number) {
return strMap;
}
// 计算当前武将战力
export async function calculateSumCE(roleId: string, type: number, param: { num?: number, heroes?: Array<number> }) {
let sum: number;
if (type == 1) { // 最高num人历史最高战力和
sum = await HeroModel.sumTopHeroCe(roleId, param.num || 0);
} else if (type == 2) { // 所有人战力和
sum = await HeroModel.sumHeroCe(roleId);
}
sum = reduceCe(sum);
return sum;
}
/**
* 传入两个时间,返回按照时间差计算,第二个时间比第一个晚几天
* @param preTime 之前的时间
@@ -573,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
@@ -788,3 +764,59 @@ export function stringToRewardInter(rewardStr: string): Array<RewardInter> {
}
return result
}
export function addToMap<T>(map: Map<T, number>, id: T, value: number) {
if(!map.has(id)) {
map.set(id, value);
} else {
map.set(id, map.get(id) + value);
}
}
// /**
// * 计算最强阵容战力
// * @param role
// * @param hid
// * @param ce
// * @param heroId
// */
// export async function calculatetopLineup(role: RoleType, hid?: number, ce?: number, heroId?: string) {
// let topLineup = role?.topLineup || new Array();
// if(!hid) { // 直接重新排
// let heroes = await HeroModel.getTopHero(role.roleId, LINEUP_NUM);
// topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
// } else {
// topLineup.sort((a, b) => { return b.ce - a.ce }); // 0-6最大-最小
// let index = topLineup.findIndex(cur => cur.hid == hid);
// if(index != -1 && !heroId) {
// let heroes = await HeroModel.getTopHero(role.roleId, LINEUP_NUM);
// topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
// } else {
// if (index == -1) { // 不在最强列表
// if (topLineup.length < LINEUP_NUM) { // 不满6人
// topLineup.push({ hid, ce, hero: heroId });
// } else if (topLineup.length == LINEUP_NUM) {
// if (ce > topLineup[topLineup.length - 1].ce) { // 跻身最强6人
// topLineup.pop();
// topLineup.push({ hid, ce, hero: heroId });
// }
// } else {
// topLineup.splice(LINEUP_NUM, topLineup.length - LINEUP_NUM);
// }
// } else { // 原来就是最强6人
// if (ce < topLineup[topLineup.length - 1].ce) { // 滑出最强
// let heroes = await HeroModel.getTopHero(role.roleId, LINEUP_NUM);
// topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
// } else {
// topLineup[index].ce = ce;
// }
// }
// }
// }
// let topLineupCe = topLineup.reduce((pre, cur) => {
// return pre + cur.ce
// }, 0);
// return { topLineup, topLineupCe };
// }

View File

@@ -5,8 +5,6 @@
"jobClass": 1,
"eplaceId": 1,
"suitId": 1,
"attribute": "2&10",
"attributeUp": "2&10",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -16,8 +14,6 @@
"jobClass": 1,
"eplaceId": 2,
"suitId": 1,
"attribute": "4&20",
"attributeUp": "4&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -27,8 +23,6 @@
"jobClass": 1,
"eplaceId": 3,
"suitId": 1,
"attribute": "5&20",
"attributeUp": "5&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -38,8 +32,6 @@
"jobClass": 1,
"eplaceId": 4,
"suitId": 1,
"attribute": "1&50",
"attributeUp": "1&50",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -49,8 +41,6 @@
"jobClass": 2,
"eplaceId": 1,
"suitId": 2,
"attribute": "2&10",
"attributeUp": "2&10",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -60,8 +50,6 @@
"jobClass": 2,
"eplaceId": 2,
"suitId": 2,
"attribute": "4&20",
"attributeUp": "4&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -71,8 +59,6 @@
"jobClass": 2,
"eplaceId": 3,
"suitId": 2,
"attribute": "5&20",
"attributeUp": "5&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -82,8 +68,6 @@
"jobClass": 2,
"eplaceId": 4,
"suitId": 2,
"attribute": "1&50",
"attributeUp": "1&50",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -93,8 +77,6 @@
"jobClass": 3,
"eplaceId": 1,
"suitId": 3,
"attribute": "2&10",
"attributeUp": "2&10",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -104,8 +86,6 @@
"jobClass": 3,
"eplaceId": 2,
"suitId": 3,
"attribute": "4&20",
"attributeUp": "4&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -115,8 +95,6 @@
"jobClass": 3,
"eplaceId": 3,
"suitId": 3,
"attribute": "5&20",
"attributeUp": "5&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -126,8 +104,6 @@
"jobClass": 3,
"eplaceId": 4,
"suitId": 3,
"attribute": "1&50",
"attributeUp": "1&50",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -137,8 +113,6 @@
"jobClass": 4,
"eplaceId": 1,
"suitId": 4,
"attribute": "2&10",
"attributeUp": "2&10",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -148,8 +122,6 @@
"jobClass": 4,
"eplaceId": 2,
"suitId": 4,
"attribute": "4&20",
"attributeUp": "4&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -159,8 +131,6 @@
"jobClass": 4,
"eplaceId": 3,
"suitId": 4,
"attribute": "5&20",
"attributeUp": "5&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -170,8 +140,6 @@
"jobClass": 4,
"eplaceId": 4,
"suitId": 4,
"attribute": "1&50",
"attributeUp": "1&50",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -181,8 +149,6 @@
"jobClass": 5,
"eplaceId": 1,
"suitId": 5,
"attribute": "2&10",
"attributeUp": "2&10",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -192,8 +158,6 @@
"jobClass": 5,
"eplaceId": 2,
"suitId": 5,
"attribute": "4&20",
"attributeUp": "4&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -203,8 +167,6 @@
"jobClass": 5,
"eplaceId": 3,
"suitId": 5,
"attribute": "5&20",
"attributeUp": "5&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -214,8 +176,6 @@
"jobClass": 5,
"eplaceId": 4,
"suitId": 5,
"attribute": "1&50",
"attributeUp": "1&50",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -225,8 +185,6 @@
"jobClass": 6,
"eplaceId": 1,
"suitId": 6,
"attribute": "2&10",
"attributeUp": "2&10",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -236,8 +194,6 @@
"jobClass": 6,
"eplaceId": 2,
"suitId": 6,
"attribute": "4&20",
"attributeUp": "4&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -247,8 +203,6 @@
"jobClass": 6,
"eplaceId": 3,
"suitId": 6,
"attribute": "5&20",
"attributeUp": "5&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -258,8 +212,6 @@
"jobClass": 6,
"eplaceId": 4,
"suitId": 6,
"attribute": "1&50",
"attributeUp": "1&50",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -269,8 +221,6 @@
"jobClass": 7,
"eplaceId": 1,
"suitId": 7,
"attribute": "2&10",
"attributeUp": "2&10",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -280,8 +230,6 @@
"jobClass": 7,
"eplaceId": 2,
"suitId": 7,
"attribute": "4&20",
"attributeUp": "4&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -291,8 +239,6 @@
"jobClass": 7,
"eplaceId": 3,
"suitId": 7,
"attribute": "5&20",
"attributeUp": "5&20",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
},
@@ -302,8 +248,6 @@
"jobClass": 7,
"eplaceId": 4,
"suitId": 7,
"attribute": "1&50",
"attributeUp": "1&50",
"composeMaterial": "50001&2",
"imageId": "qingtongjian&bintiejian&wenshijian&jinggangjian&songwenjian"
}

File diff suppressed because it is too large Load Diff

View File

@@ -15,8 +15,8 @@
"turnLimted": 20,
"forcedCharactor": "&",
"fobiddenCharactor": "&",
"victoryInfoInUI": "1.消灭所有敌军\r\n2.死亡的村民数量≤2\r\n3.剩下的村民都到达洞口",
"loseInfoInUI": "1.我方全部阵亡\r\n2.死亡的村民数量≥3\r\n3.20回合内未能胜利",
"victoryInfoInUI": "1.消灭所有敌军\n2.死亡的村民数量≤2\n3.剩下的村民都到达洞口",
"loseInfoInUI": "1.我方全部阵亡\n2.死亡的村民数量≥3\n3.20回合内未能胜利",
"starInfoInUI": "1.在20回合内获得胜利",
"cost": 10,
"iconInMap": "spine&qingnian",
@@ -30,7 +30,7 @@
"needPrepare": 1,
"spineInBigMap": "&",
"HeroNum": "6&6",
"gkInfo": " 循着不详的气息,赵云一行人来到了一座神秘的小村庄。老人们说,他们是为了躲避连年战乱才来此地。\r\n 想不到即使是在这里,也藏着不为人知的阴谋……\r\n 这些阴兵,究竟由谁招来?山林里还有恶兽蠢蠢欲动……\r\n",
"gkInfo": " 循着不详的气息,赵云一行人来到了一座神秘的小村庄。老人们说,他们是为了躲避连年战乱才来此地。\n 想不到即使是在这里,也藏着不为人知的阴谋……\n 这些阴兵,究竟由谁招来?山林里还有恶兽蠢蠢欲动……\n",
"HeroNum_1": "1&6",
"progress": "1&0|2&0",
"progressDesc": "已逃走的百姓数量&被击杀的百姓数量",
@@ -52,8 +52,8 @@
"turnLimted": 20,
"forcedCharactor": "&",
"fobiddenCharactor": "&",
"victoryInfoInUI": "1.消灭所有敌军\r\n2.解救所有被绑架的村民\r\n",
"loseInfoInUI": "1.我方全部阵亡\r\n2.20回合内未能胜利",
"victoryInfoInUI": "1.消灭所有敌军\n2.解救所有被绑架的村民\n",
"loseInfoInUI": "1.我方全部阵亡\n2.20回合内未能胜利",
"starInfoInUI": "1.在20回合内获得胜利",
"cost": 10,
"iconInMap": "spine&yinbingdao&1",
@@ -67,7 +67,7 @@
"needPrepare": 1,
"spineInBigMap": "&",
"HeroNum": "6&6",
"gkInfo": " 赵云一行人刚将村中的百姓带入山洞避难,一位急急忙忙寻找妻子的青年便找上门来。\r\n 洞内仍有不少以往百姓为了躲避战乱设下的陷阱,可务必要当心!\r\n 也许在这昏暗的洞穴里,点燃火炬一路小心前行,才是上策。",
"gkInfo": " 赵云一行人刚将村中的百姓带入山洞避难,一位急急忙忙寻找妻子的青年便找上门来。\n 洞内仍有不少以往百姓为了躲避战乱设下的陷阱,可务必要当心!\n 也许在这昏暗的洞穴里,点燃火炬一路小心前行,才是上策。",
"HeroNum_1": "1&6",
"progress": "1&0|6&0",
"progressDesc": "已解救的百姓数量&待解救的百姓数量",
@@ -104,7 +104,7 @@
"needPrepare": 1,
"spineInBigMap": "&",
"HeroNum": "6&6",
"gkInfo": " 诡异的阴兵,神秘的阴珠,残忍的血法……从巨鹿废墟到山林小村,一个巨大的阴谋似乎一直笼罩在冀州的上空。\r\n 现在赵云一行人终于来到了最后的祭坛,即将揭开这一切的始作俑者……",
"gkInfo": " 诡异的阴兵,神秘的阴珠,残忍的血法……从巨鹿废墟到山林小村,一个巨大的阴谋似乎一直笼罩在冀州的上空。\n 现在赵云一行人终于来到了最后的祭坛,即将揭开这一切的始作俑者……",
"HeroNum_1": "1&6",
"progress": "&",
"progressDesc": "&",
@@ -128,7 +128,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "\r\n1.在20回合内获得胜利",
"starInfoInUI": "\n1.在20回合内获得胜利",
"cost": 10,
"iconInMap": "spine&qingnian",
"iconName": "井底世界",
@@ -141,7 +141,7 @@
"needPrepare": 1,
"spineInBigMap": "&",
"HeroNum": "6&6",
"gkInfo": " 在枯井的周围,一群宫女装扮的幽鬼盘亘。\r\n 原来,这些是洛阳被焚毁时,惨死于皇宫中的宫女,因为长久以来的怨气而化为幽鬼,她们憎恨一切活着的人类。\r\n 小心!她们来了!",
"gkInfo": " 在枯井的周围,一群宫女装扮的幽鬼盘亘。\n 原来,这些是洛阳被焚毁时,惨死于皇宫中的宫女,因为长久以来的怨气而化为幽鬼,她们憎恨一切活着的人类。\n 小心!她们来了!",
"HeroNum_1": "1&6",
"progress": "&",
"progressDesc": "&",
@@ -178,7 +178,7 @@
"needPrepare": 1,
"spineInBigMap": "&",
"HeroNum": "6&6",
"gkInfo": " 枯井的尽头是一条大门,出于好奇,赵云一行人穿越幽暗的隧道,来到大门前。\r\n 吱呀——推开大门,原来这里是一片墓室。\r\n 在昏黄的烛火中,他们看到了一群没有意识的侍卫,还有一个没有头颅的巨大身影……",
"gkInfo": " 枯井的尽头是一条大门,出于好奇,赵云一行人穿越幽暗的隧道,来到大门前。\n 吱呀——推开大门,原来这里是一片墓室。\n 在昏黄的烛火中,他们看到了一群没有意识的侍卫,还有一个没有头颅的巨大身影……",
"HeroNum_1": "1&6",
"progress": "&",
"progressDesc": "&",
@@ -202,7 +202,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在30回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在30回合内获得胜利",
"cost": 30,
"iconInMap": "spine&zhangjiao",
"iconName": "何后废陵",
@@ -215,7 +215,7 @@
"needPrepare": 1,
"spineInBigMap": "&",
"HeroNum": "6&6",
"gkInfo": " 何太后身材窈窕,风流妩媚,进宫之后更是凭借自身的心计一步步征服了汉灵帝的心。然其天性善妒,刘协出生后,感到自身地位动摇的何太后用鸩酒毒杀了王美人。\r\n 天道有轮回,外戚与宦官相争,何进身死,董卓进京,何太后也被逼饮下毒酒。\r\n 陵墓尽头,彼岸花开,何太后已超脱生死,可千万别停留在这里!",
"gkInfo": " 何太后身材窈窕,风流妩媚,进宫之后更是凭借自身的心计一步步征服了汉灵帝的心。然其天性善妒,刘协出生后,感到自身地位动摇的何太后用鸩酒毒杀了王美人。\n 天道有轮回,外戚与宦官相争,何进身死,董卓进京,何太后也被逼饮下毒酒。\n 陵墓尽头,彼岸花开,何太后已超脱生死,可千万别停留在这里!",
"HeroNum_1": "1&6",
"progress": "&",
"progressDesc": "&",
@@ -239,7 +239,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&guanhai",
"iconName": 0,
@@ -276,7 +276,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&caosong",
"iconName": 0,
@@ -313,7 +313,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 30,
"iconInMap": "spine&zhangrang",
"iconName": 0,
@@ -350,7 +350,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&qingnian",
"iconName": 0,
@@ -387,7 +387,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&yinbingdao",
"iconName": 0,
@@ -424,7 +424,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 30,
"iconInMap": "spine&zhangjiao",
"iconName": 0,
@@ -461,7 +461,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&qingnian",
"iconName": 0,
@@ -498,7 +498,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&yinbingdao",
"iconName": 0,
@@ -535,7 +535,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 30,
"iconInMap": "spine&zhangjiao",
"iconName": 0,
@@ -572,7 +572,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&wangcan",
"iconName": 0,
@@ -609,7 +609,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&yanshi",
"iconName": 0,
@@ -646,7 +646,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 30,
"iconInMap": "spine&sengren",
"iconName": 0,
@@ -683,7 +683,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&qingnian",
"iconName": "武陵顽猴",
@@ -720,7 +720,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 10,
"iconInMap": "spine&yinbingdao",
"iconName": "桃源疫民",
@@ -757,7 +757,7 @@
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"starInfoInUI": "1.我方无人阵亡;\n2.在5回合内获得胜利",
"cost": 30,
"iconInMap": "spine&zhangjiao",
"iconName": "西夷疫魔",