🐞 fix(优化): 羁绊溢出替换道具
This commit is contained in:
@@ -8,7 +8,7 @@ import { RoleModel } from '../../../db/Role';
|
|||||||
import { ItemModel } from '../../../db/Item';
|
import { ItemModel } from '../../../db/Item';
|
||||||
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getConnectLvByExp, getEquipByJobClassAndEPlace, getScollByStar, getExpByLv, getConnectMaxLv, getFriendShipByIdAndLv } from '../../../pubUtils/data';
|
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getConnectLvByExp, getEquipByJobClassAndEPlace, getScollByStar, getExpByLv, getConnectMaxLv, getFriendShipByIdAndLv } from '../../../pubUtils/data';
|
||||||
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
|
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
|
||||||
import { getDropItems, FIGURE_UNLOCK_CONDITION, ITID } from '../../../consts/constModules/itemConst'
|
import { getDropItems, FIGURE_UNLOCK_CONDITION, ITID, DELICACY_GID } from '../../../consts/constModules/itemConst'
|
||||||
import { pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
|
import { pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
|
||||||
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
||||||
import { checkTask, checkTaskInHeroGiveFavor, checkTaskInHeroQUalityUp, checkTaskInHeroStarUp, checkTaskInHeroTrain, checkTaskInHeroWakeUp } from '../../../services/task/taskService';
|
import { checkTask, checkTaskInHeroGiveFavor, checkTaskInHeroQUalityUp, checkTaskInHeroStarUp, checkTaskInHeroTrain, checkTaskInHeroWakeUp } from '../../../services/task/taskService';
|
||||||
@@ -433,6 +433,7 @@ export class HeroHandler {
|
|||||||
//赠送(包括一键赠送)
|
//赠送(包括一键赠送)
|
||||||
async heroGiveFavor(msg: { hid: number, shipId: number, type: number }, session: BackendSession) {
|
async heroGiveFavor(msg: { hid: number, shipId: number, type: number }, session: BackendSession) {
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
|
let roleName: string = session.get('roleName');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
let serverId: number = session.get('serverId');
|
let serverId: number = session.get('serverId');
|
||||||
|
|
||||||
@@ -490,19 +491,34 @@ export class HeroHandler {
|
|||||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
let newLevel = getConnectLvByExp(hid, shipId, newExp);
|
let addItem: RewardInter[] = [];
|
||||||
|
let { newLv: newLevel, overExp } = getConnectLvByExp(hid, shipId, newExp);
|
||||||
|
let saveMaterial: RewardInter[] = [];
|
||||||
|
for(let { id, count } of material) {
|
||||||
|
if(count > 0) saveMaterial.push({ id, count});
|
||||||
|
}
|
||||||
|
if(newLevel == maxLv && overExp > 0 && material.length > 0) {
|
||||||
|
let dicGoods = gameData.goods.get(saveMaterial[0].id);
|
||||||
|
if(!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
|
|
||||||
|
addItem.push({ id: DELICACY_GID, count: Math.floor(overExp/10) });
|
||||||
|
saveMaterial.push({ id: DELICACY_GID, count: Math.floor((dicGoods.value - overExp)/10) });
|
||||||
|
saveMaterial[0].count--;
|
||||||
|
saveMaterial = saveMaterial.filter(cur => cur.count > 0);
|
||||||
|
}
|
||||||
|
|
||||||
let result = await handleCost(roleId, sid, material, ITEM_CHANGE_REASON.HERO_GIVE_FAVOR);
|
let result = await handleCost(roleId, sid, material, ITEM_CHANGE_REASON.HERO_GIVE_FAVOR);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
let updateConsume = addConsumeToHero(hero.consumes, material);
|
let updateConsume = addConsumeToHero(hero.consumes, saveMaterial);
|
||||||
let newConnections = addConnect(connections, { shipId, level: newLevel, exp: newExp });
|
let newConnections = addConnect(connections, { shipId, level: newLevel, exp: newExp });
|
||||||
let update = {
|
let update = {
|
||||||
connections: newConnections,
|
connections: newConnections,
|
||||||
consumes: updateConsume
|
consumes: updateConsume
|
||||||
}
|
}
|
||||||
|
let goods = await addItems(roleId, roleName, sid, addItem, ITEM_CHANGE_REASON.HERO_GIVE_FAVOR);
|
||||||
|
|
||||||
let isLv = oldLv != newLevel;
|
let isLv = oldLv != newLevel;
|
||||||
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.CONNECT, roleId, serverId, sid, hero.hid, update, { shipId });
|
let { curHero } = await calculateCeWithHero(HERO_SYSTEM_TYPE.CONNECT, roleId, serverId, sid, hero.hid, update, { shipId });
|
||||||
@@ -510,7 +526,7 @@ export class HeroHandler {
|
|||||||
// await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.HERO_FAVOR, paramHid: curHero.hid, paramFavourLv: curHero.favourLv }]);
|
// await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.HERO_FAVOR, paramHid: curHero.hid, paramFavourLv: curHero.favourLv }]);
|
||||||
await checkTaskInHeroGiveFavor(serverId, roleId, sid, shipId, newConnections, connections);
|
await checkTaskInHeroGiveFavor(serverId, roleId, sid, shipId, newConnections, connections);
|
||||||
}
|
}
|
||||||
return resResult(STATUS.SUCCESS, { curHero: { ...pick(curHero, ['hid', 'connections']), shipId } });
|
return resResult(STATUS.SUCCESS, { curHero: { ...pick(curHero, ['hid', 'connections']), shipId }, goods });
|
||||||
}
|
}
|
||||||
|
|
||||||
//穿带时装
|
//穿带时装
|
||||||
|
|||||||
@@ -197,8 +197,9 @@ const currencyArr = [
|
|||||||
{ "gid": 72021, "name": "天机骰子", "type": CURRENCY_TYPE.SPECIAL_DICE },
|
{ "gid": 72021, "name": "天机骰子", "type": CURRENCY_TYPE.SPECIAL_DICE },
|
||||||
{ "gid": 72030, "name": "主公经验", "type": CURRENCY_TYPE.KING_EXP },
|
{ "gid": 72030, "name": "主公经验", "type": CURRENCY_TYPE.KING_EXP },
|
||||||
{ "gid": 81000, "name": "英杰券", "type": CURRENCY_TYPE.VOUCHER},
|
{ "gid": 81000, "name": "英杰券", "type": CURRENCY_TYPE.VOUCHER},
|
||||||
{ "gid": 81001, "name": "英杰币", "type": CURRENCY_TYPE.VOUCHER_COIN},
|
{ "gid": 81001, "name": "英杰币", "type": CURRENCY_TYPE.VOUCHER_COIN}
|
||||||
];
|
];
|
||||||
|
|
||||||
export const CURRENCY = new Map<number, { gid: number, name: string, type: string }>();
|
export const CURRENCY = new Map<number, { gid: number, name: string, type: string }>();
|
||||||
export const CURRENCY_BY_TYPE = new Map<string, number>();
|
export const CURRENCY_BY_TYPE = new Map<string, number>();
|
||||||
for (let obj of currencyArr) {
|
for (let obj of currencyArr) {
|
||||||
@@ -229,6 +230,7 @@ export function getSpineItid() {
|
|||||||
return dicItid?.id;
|
return dicItid?.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export enum QUALITY_TYPE {
|
export enum QUALITY_TYPE {
|
||||||
BLUE = 1, // 蓝
|
BLUE = 1, // 蓝
|
||||||
PURPLE = 2, // 紫
|
PURPLE = 2, // 紫
|
||||||
@@ -308,4 +310,6 @@ export enum QUENCH_TYPE {
|
|||||||
export enum REFINE_TYPE {
|
export enum REFINE_TYPE {
|
||||||
ONCE = 1, // 精炼一次
|
ONCE = 1, // 精炼一次
|
||||||
ONE_LEVEL = 2, // 精炼一级
|
ONE_LEVEL = 2, // 精炼一级
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const DELICACY_GID = 11011;
|
||||||
@@ -422,12 +422,16 @@ export function getConnectMaxLv(actorId: number, shipId: number) {
|
|||||||
*/
|
*/
|
||||||
export function getConnectLvByExp(actorId: number, shipId: number, newExp: number) {
|
export function getConnectLvByExp(actorId: number, shipId: number, newExp: number) {
|
||||||
let exps = gameData.friendShips.get(`${actorId}_${shipId}`) || [];
|
let exps = gameData.friendShips.get(`${actorId}_${shipId}`) || [];
|
||||||
|
let overExp = 0;
|
||||||
exps.sort((a, b) => a.level - b.level);
|
exps.sort((a, b) => a.level - b.level);
|
||||||
let newLv = 0;
|
let newLv = 0;
|
||||||
for (let { level, shipExp } of exps) {
|
for (let { level, shipExp } of exps) {
|
||||||
if (newExp >= shipExp) newLv = level;
|
if (newExp >= shipExp) {
|
||||||
|
newLv = level;
|
||||||
|
overExp = newExp - shipExp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return newLv
|
return { newLv, overExp }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBossHpByWarId(warId: number) {
|
export function getBossHpByWarId(warId: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user