装备:天晶继承
This commit is contained in:
@@ -8,10 +8,10 @@ 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, checkTaskInComposeEquip, checkTaskInEquipLvUp, checkTaskInComposeStone, checkTaskInEquipReset, checkTaskInEquipQuench } from "../../../services/equipService";
|
||||
import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, checkTaskInComposeEquip, checkTaskInEquipLvUp, checkTaskInComposeStone, checkTaskInEquipReset, checkTaskInEquipQuench, isLocked } from "../../../services/equipService";
|
||||
|
||||
import { isNumber, pick } from 'underscore';
|
||||
import { JewelModel } from "../../../db/Jewel";
|
||||
import { JewelModel, RandSe } from "../../../db/Jewel";
|
||||
import { getJewelRandSe } from "../../../pubUtils/itemUtils";
|
||||
import { checkTaskInEquipQualityUp, checkTaskInEquipStarUp, checkTaskInPutJewel, checkTaskInPutStone } from '../../../services/equipService';
|
||||
import { pushEquipQualityMax, pushEquipStarMax } from "../../../services/sysChatService";
|
||||
@@ -723,4 +723,46 @@ export class EquipHandler {
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
|
||||
public async inheritJewel(msg: { originJewel: number, targetJewel: number }, session: BackendSession) {
|
||||
let { originJewel: originJewelId, targetJewel: targetJewelId } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
let originJewel = await JewelModel.findbySeqId(originJewelId);
|
||||
if(!originJewel || originJewel.roleId != roleId) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
if(originJewel.hid > 0) return resResult(STATUS.JEWEL_HAS_EQUPED);
|
||||
|
||||
let targetJewel = await JewelModel.findbySeqId(targetJewelId);
|
||||
if(!targetJewel || targetJewel.roleId != roleId) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
|
||||
if(isLocked(targetJewel.randSe)) return resResult(STATUS.JEWEL_LOCKED_CANNOT_INHERIT);
|
||||
|
||||
let dicOldJewel = gameData.jewel.get(originJewel.id);
|
||||
if(!dicOldJewel) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let dicJewel = gameData.jewel.get(targetJewel.id);
|
||||
if(!dicJewel) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if(dicJewel.eplaceId != dicOldJewel.eplaceId || dicJewel.lv < dicOldJewel.lv) {
|
||||
return resResult(STATUS.JEWEL_CANNOT_INHERIT);
|
||||
}
|
||||
|
||||
// 消耗
|
||||
let consumeResult = await handleCost(roleId, sid, [
|
||||
{ id: originJewel.id, seqId: originJewel.seqId},
|
||||
...dicJewel.inheritConsume
|
||||
], ITEM_CHANGE_REASON.ACT_DAILY_GK_BATTLE_END);
|
||||
if(!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let newRandSe = getRandSeResult(targetJewel.id, targetJewel.randSe, originJewel.randSe, originJewel.id);
|
||||
let newJewel = await JewelModel.updateInfo(targetJewel.seqId, { previewRandSe: [], randSe: newRandSe });
|
||||
// 更新战力
|
||||
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 checkTaskInEquipReset(serverId, roleId, sid);
|
||||
return resResult(STATUS.SUCCESS, { curJewel: pick(newJewel, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,36 @@
|
||||
import { getRandEelm, } from '../pubUtils/util';
|
||||
import { EPlace, Stone } from "../db/Hero";
|
||||
import { gameData } from "../pubUtils/data";
|
||||
import { gameData, getRandEffectByGroupAndLevel } from "../pubUtils/data";
|
||||
import { JewelType, RandSe } from '../db/Jewel';
|
||||
import { getJewelRandSe } from '../pubUtils/itemUtils';
|
||||
import { checkActivityTask, checkTask, checkTaskWithEplaces, checkTaskWithEplace } from './taskService';
|
||||
import { TASK_TYPE } from '../consts';
|
||||
import { DicRandomEffectPool } from '../pubUtils/dictionary/DicRandomEffectPool';
|
||||
|
||||
export function getRandSeResult(id: number, randSe: RandSe[]) {
|
||||
let { randomEffect, effectCount } = gameData.jewel.get(id);
|
||||
export function getRandSeResult(id: number, randSe: RandSe[], originSe: RandSe[] = [], originId?: number) {
|
||||
let { randomEffect, effectCount, lv } = gameData.jewel.get(id);
|
||||
|
||||
let chosen = randSe.filter(cur => cur.locked).map(cur => cur.seid); // 上一轮随机出来的
|
||||
|
||||
let newRandSe: RandSe[] = []; // 随机结果
|
||||
let startId = 0;
|
||||
for(let { id, seid } of originSe) {
|
||||
let { lv: oldLv } = gameData.jewel.get(originId);
|
||||
// 替换成高阶
|
||||
let dicRandomEffect = gameData.randomEffectPool.get(seid);
|
||||
let nextRandEffect: DicRandomEffectPool;
|
||||
let targetRandLv = dicRandomEffect.level + lv - oldLv;
|
||||
while(!nextRandEffect) {
|
||||
nextRandEffect = getRandEffectByGroupAndLevel(dicRandomEffect.group, targetRandLv);
|
||||
targetRandLv--;
|
||||
if(targetRandLv < 0) break;
|
||||
}
|
||||
let newSeid = nextRandEffect? nextRandEffect.id: seid;
|
||||
newRandSe.push(getJewelRandSe(id, newSeid));
|
||||
chosen.push(seid);
|
||||
startId++;
|
||||
}
|
||||
|
||||
let randomResult: number[] = getRandEelm(randomEffect.filter(cur => !chosen.includes(cur)), effectCount); // 随机出的结果
|
||||
if(randomResult.length < effectCount) { // 去上轮之后不够,把上轮加入
|
||||
let chosenRandom = getRandEelm(chosen, effectCount - randomResult.length);
|
||||
@@ -20,8 +41,7 @@ export function getRandSeResult(id: number, randSe: RandSe[]) {
|
||||
randomResult.push(...allRandom);
|
||||
}
|
||||
|
||||
let newRandSe: RandSe[] = [];
|
||||
for (let i = 0; i < effectCount; i++) {
|
||||
for (let i = startId; i < effectCount; i++) {
|
||||
if(randSe[i]) {
|
||||
if(randSe[i] && randSe[i].locked) {
|
||||
newRandSe.push(randSe[i]);
|
||||
@@ -196,3 +216,11 @@ function getEquipById(oldEplace: EPlace[], newEplace: EPlace[], eplaceId: number
|
||||
let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0);
|
||||
return { oldEquip, newEquip }
|
||||
}
|
||||
|
||||
|
||||
export function isLocked(randSe: RandSe[]) {
|
||||
for(let { locked } of randSe) {
|
||||
if(locked) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ export async function checkActivityTask(serverId: number, sid: string, roleId: s
|
||||
|
||||
export async function pushActivityUpdate(roleId: string, sid: string, pushMessage: any[]) {
|
||||
// console.log('pushActivityUpdate', JSON.stringify(pushMessage))
|
||||
if (pushMessage.length > 0) {
|
||||
if (pushMessage?.length > 0) {
|
||||
if (!sid) {
|
||||
let onlineUser = await getRoleOnlineInfo(roleId);
|
||||
sid = onlineUser.sid;
|
||||
|
||||
Reference in New Issue
Block a user