✨ feat(百家争鸣): 添加将灵合成
This commit is contained in:
@@ -2,7 +2,7 @@ import { Application, BackendSession, HandlerService, } from "pinus";
|
|||||||
import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD, GIFT_GENERATE_TYPE, ITEM_CHANGE_REASON, GIFT_TYPE } from "../../../consts";
|
import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD, GIFT_GENERATE_TYPE, ITEM_CHANGE_REASON, GIFT_TYPE } from "../../../consts";
|
||||||
import { RewardInter } from "../../../pubUtils/interface";
|
import { RewardInter } from "../../../pubUtils/interface";
|
||||||
|
|
||||||
import { resResult } from "../../../pubUtils/util";
|
import { getRandSingleEelm, resResult } from "../../../pubUtils/util";
|
||||||
import { addItems, handleCost } from "../../../services/role/rewardService";
|
import { addItems, handleCost } from "../../../services/role/rewardService";
|
||||||
import { RoleModel } from "../../../db/Role";
|
import { RoleModel } from "../../../db/Role";
|
||||||
import { gameData } from "../../../pubUtils/data";
|
import { gameData } from "../../../pubUtils/data";
|
||||||
@@ -16,6 +16,7 @@ import { nowSeconds } from "../../../pubUtils/timeUtil";
|
|||||||
import { AP } from "../../../pubUtils/dicParam";
|
import { AP } from "../../../pubUtils/dicParam";
|
||||||
import { GiftPackageFloorModel } from "../../../db/GiftPackageFloor";
|
import { GiftPackageFloorModel } from "../../../db/GiftPackageFloor";
|
||||||
import { UserGiftCodeDetailModel } from "../../../db/UserGiftCodeDetail";
|
import { UserGiftCodeDetailModel } from "../../../db/UserGiftCodeDetail";
|
||||||
|
import { combineItems } from "../../../services/role/util";
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -234,6 +235,46 @@ export class ItemHandler {
|
|||||||
return resResult(STATUS.SUCCESS, { ap, apBefore });
|
return resResult(STATUS.SUCCESS, { ap, apBefore });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async exchangeSpirit(msg: { origin: { id: number, count: number }[] }, session: BackendSession) {
|
||||||
|
const roleId: string = session.get('roleId');
|
||||||
|
const roleName: string = session.get('roleName');
|
||||||
|
const sid: string = session.get('sid');
|
||||||
|
const { origin = [] } = msg;
|
||||||
|
|
||||||
|
let originQuality = 0, allCount = 0;
|
||||||
|
for (let { id, count } of origin) {
|
||||||
|
let dicGoods = gameData.goods.get(id);
|
||||||
|
let dicItid = ITID.get(dicGoods?.itid);
|
||||||
|
if (!dicItid || dicItid.type != CONSUME_TYPE.SPIRIT_STONE)
|
||||||
|
return resResult(STATUS.ACCESS_BUSY);
|
||||||
|
if (originQuality == 0) originQuality = dicGoods.quality;
|
||||||
|
if (dicGoods.quality != originQuality) return resResult(STATUS.SPIRIT_QUALITY_NOT_SAME);
|
||||||
|
allCount += count;
|
||||||
|
}
|
||||||
|
let dicSpiritCompose = gameData.spiritCompose.get(originQuality);
|
||||||
|
if (!dicSpiritCompose) return resResult(STATUS.SPIRIT_QUALITY_NOT_FOUND);
|
||||||
|
|
||||||
|
let { goalQuality, materialNum } = dicSpiritCompose;
|
||||||
|
let num = Math.floor(allCount/materialNum);
|
||||||
|
if (allCount > num * materialNum) return resResult(STATUS.SPIRIT_QUALITY_NOT_INTERGER);
|
||||||
|
|
||||||
|
let pool = gameData.spiritByQuality.get(goalQuality);
|
||||||
|
if (!pool || pool.length <= 0) return resResult(STATUS.TARGET_SPIRIT_QUALITY_NOT_FOUND);
|
||||||
|
|
||||||
|
let costResult = await handleCost(roleId, sid, origin, ITEM_CHANGE_REASON.EXCHANGE_SPIRIT);
|
||||||
|
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
|
|
||||||
|
let rewards: RewardInter[] = [];
|
||||||
|
for (let i = 0; i < num; i++) {
|
||||||
|
let gid = getRandSingleEelm(pool);
|
||||||
|
rewards.push({ id: gid, count: 1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
let goods = await addItems(roleId, roleName, sid, combineItems(rewards), ITEM_CHANGE_REASON.EXCHANGE_SPIRIT);
|
||||||
|
|
||||||
|
return resResult(STATUS.SUCCESS, { goods });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async debugIncAp(msg: { magicWord: string, ap: number }, session: BackendSession) {
|
public async debugIncAp(msg: { magicWord: string, ap: number }, session: BackendSession) {
|
||||||
const { magicWord } = msg;
|
const { magicWord } = msg;
|
||||||
|
|||||||
@@ -2069,6 +2069,14 @@ export function checkRouteParam(route: string, msg: any) {
|
|||||||
if (!checkNaturalNumbers(msg.lv)) return false;
|
if (!checkNaturalNumbers(msg.lv)) return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "role.itemHandler.exchangeSpirit":
|
||||||
|
{
|
||||||
|
if (!checkNaturalArray(msg.origin)) return false;
|
||||||
|
for (let { id, count } of msg.origin) {
|
||||||
|
if (!checkNaturalNumbers(id, count)) return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "role.mailHandler.readMail":
|
case "role.mailHandler.readMail":
|
||||||
{
|
{
|
||||||
if (!checkNaturalStrings(msg.id)) return false;
|
if (!checkNaturalStrings(msg.id)) return false;
|
||||||
|
|||||||
@@ -694,6 +694,7 @@ export const FILENAME = {
|
|||||||
DIC_ROUGE_TECH_CIRCLE: "dic_rougeTechCircle",
|
DIC_ROUGE_TECH_CIRCLE: "dic_rougeTechCircle",
|
||||||
DIC_ROUGE_TECH_LEVEL: "dic_rougeTechLevel",
|
DIC_ROUGE_TECH_LEVEL: "dic_rougeTechLevel",
|
||||||
DIC_GUILD_HP_RATIO: "dic_army_hpRatio",
|
DIC_GUILD_HP_RATIO: "dic_army_hpRatio",
|
||||||
|
DIC_SPIRIT_COMPOSE: "dic_zyz_spiritCompose",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WAR_RELATE_TABLES = [
|
export const WAR_RELATE_TABLES = [
|
||||||
@@ -1284,6 +1285,7 @@ export enum ITEM_CHANGE_REASON {
|
|||||||
CHONGYANG_COST = 206, // 重阳集会购买消耗
|
CHONGYANG_COST = 206, // 重阳集会购买消耗
|
||||||
NOVEMBER_REWARD = 207, // 辜月集会奖励
|
NOVEMBER_REWARD = 207, // 辜月集会奖励
|
||||||
NOVEMBER_COST = 208, // 辜月集会购买消耗
|
NOVEMBER_COST = 208, // 辜月集会购买消耗
|
||||||
|
EXCHANGE_SPIRIT = 209, // 将灵合成
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TA_EVENT {
|
export enum TA_EVENT {
|
||||||
|
|||||||
@@ -614,6 +614,11 @@ export const STATUS = {
|
|||||||
EQUIP_IS_OVER: { code: 31302, simStr: '装备已超过上限,无法领取' },
|
EQUIP_IS_OVER: { code: 31302, simStr: '装备已超过上限,无法领取' },
|
||||||
// 道具相关
|
// 道具相关
|
||||||
ITEM_CANNOT_RECEIVE_NO_GUILD: { code: 31401, simStr: '您没有加入军团,不可使用该道具' },
|
ITEM_CANNOT_RECEIVE_NO_GUILD: { code: 31401, simStr: '您没有加入军团,不可使用该道具' },
|
||||||
|
ITEM_NOT_SPIRIT: { code: 31402, simStr: '道具类型错误,不是将灵' },
|
||||||
|
SPIRIT_QUALITY_NOT_SAME: { code: 31403, simStr: '选择的将灵需要都是相同品质的' },
|
||||||
|
SPIRIT_QUALITY_NOT_FOUND: { code: 31404, simStr: '该品质将灵不可合成' },
|
||||||
|
SPIRIT_QUALITY_NOT_INTERGER: { code: 31405, simStr: '将灵材料不是整数倍' },
|
||||||
|
TARGET_SPIRIT_QUALITY_NOT_FOUND: { code: 31406, simStr: '目标品质将灵不存在' },
|
||||||
|
|
||||||
// 社交相关状态 40000 - 49999
|
// 社交相关状态 40000 - 49999
|
||||||
SYS_CHANNEL_AUTH_NOT_ENOUGH: { code: 40000, simStr: '无法在系统频道发送消息' },
|
SYS_CHANNEL_AUTH_NOT_ENOUGH: { code: 40000, simStr: '无法在系统频道发送消息' },
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { dicHero, loadHero } from "./dictionary/DicHero";
|
import { dicHero, loadHero } from "./dictionary/DicHero";
|
||||||
import { dicGoods, figureCondition, loadGoods } from "./dictionary/DicGoods";
|
import { dicGoods, dicSpiritByQuality, figureCondition, loadGoods } from "./dictionary/DicGoods";
|
||||||
import { dicDaily, loadDaily } from "./dictionary/DicDaily";
|
import { dicDaily, loadDaily } from "./dictionary/DicDaily";
|
||||||
import { dicEvent, dicEventList, loadEvent } from "./dictionary/DicEvent";
|
import { dicEvent, dicEventList, loadEvent } from "./dictionary/DicEvent";
|
||||||
import { dicExpedition, DicExpedition, loadExpedition } from "./dictionary/DicExpedition";
|
import { dicExpedition, DicExpedition, loadExpedition } from "./dictionary/DicExpedition";
|
||||||
@@ -173,6 +173,7 @@ import { dicRougePassiveWeight, loadRougePassiveWeight } from "./dictionary/DicR
|
|||||||
import { dicRougeCharaCardPlan, loadRougeCharaCardPlan } from "./dictionary/DicRougeCharaCardPlan";
|
import { dicRougeCharaCardPlan, loadRougeCharaCardPlan } from "./dictionary/DicRougeCharaCardPlan";
|
||||||
import { dicRougeHolyCardPlan, loadRougeHolyCardPlan } from "./dictionary/DicRougeHolyCardPlan";
|
import { dicRougeHolyCardPlan, loadRougeHolyCardPlan } from "./dictionary/DicRougeHolyCardPlan";
|
||||||
import { dicBossHpRatio, loadBossHpRatio } from "./dictionary/DicBossHpRatio";
|
import { dicBossHpRatio, loadBossHpRatio } from "./dictionary/DicBossHpRatio";
|
||||||
|
import { dicSpiritCompose, loadSpiritCompose } from "./dictionary/DicSpiritCompose";
|
||||||
|
|
||||||
export const gameData = {
|
export const gameData = {
|
||||||
daily: dicDaily,
|
daily: dicDaily,
|
||||||
@@ -433,6 +434,8 @@ export const gameData = {
|
|||||||
rougeTechByRow: dicRougeTechIdByRow,
|
rougeTechByRow: dicRougeTechIdByRow,
|
||||||
rougeTechLevel: dicRougeTechLevel,
|
rougeTechLevel: dicRougeTechLevel,
|
||||||
bossHpRatio: dicBossHpRatio,
|
bossHpRatio: dicBossHpRatio,
|
||||||
|
spiritCompose: dicSpiritCompose,
|
||||||
|
spiritByQuality: dicSpiritByQuality,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||||
@@ -1803,6 +1806,7 @@ function loadDatas(type?: string) {
|
|||||||
if (type == undefined || type == 'loadRougeTechCircle') loadRougeTechCircle();
|
if (type == undefined || type == 'loadRougeTechCircle') loadRougeTechCircle();
|
||||||
if (type == undefined || type == 'loadRougeTechLevel') loadRougeTechLevel();
|
if (type == undefined || type == 'loadRougeTechLevel') loadRougeTechLevel();
|
||||||
if (type == undefined || type == 'loadBossHpRatio') loadBossHpRatio();
|
if (type == undefined || type == 'loadBossHpRatio') loadBossHpRatio();
|
||||||
|
if (type == undefined || type == 'loadSpiritCompose') loadSpiritCompose();
|
||||||
|
|
||||||
console.log('loadDatas type: ', type || 'all');
|
console.log('loadDatas type: ', type || 'all');
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// 物品表
|
// 物品表
|
||||||
import { decodeArrayListStr, readFileAndParse, parseGoodStr, } from '../util'
|
import { decodeArrayListStr, readFileAndParse, parseGoodStr, } from '../util'
|
||||||
import { FILENAME, } from '../../consts'
|
import { FILENAME, ITID, } from '../../consts'
|
||||||
import { RewardInter } from '../interface';
|
import { RewardInter } from '../interface';
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
@@ -60,10 +60,12 @@ const DicGoodsKeys: KeysEnum<DicGoods> = {
|
|||||||
}
|
}
|
||||||
export const dicGoods = new Map<number, DicGoods>();
|
export const dicGoods = new Map<number, DicGoods>();
|
||||||
export const figureCondition = new Map<number, { params: number[], id: number, gid: number }[]>(); // type => {params, id, gid}
|
export const figureCondition = new Map<number, { params: number[], id: number, gid: number }[]>(); // type => {params, id, gid}
|
||||||
|
export const dicSpiritByQuality = new Map<number, number[]>();
|
||||||
|
|
||||||
export function loadGoods() {
|
export function loadGoods() {
|
||||||
dicGoods.clear();
|
dicGoods.clear();
|
||||||
figureCondition.clear();
|
figureCondition.clear();
|
||||||
|
dicSpiritByQuality.clear();
|
||||||
|
|
||||||
let arr = readFileAndParse(FILENAME.DIC_GOODS);
|
let arr = readFileAndParse(FILENAME.DIC_GOODS);
|
||||||
|
|
||||||
@@ -78,6 +80,10 @@ export function loadGoods() {
|
|||||||
}
|
}
|
||||||
o.condition = condition;
|
o.condition = condition;
|
||||||
dicGoods.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
|
dicGoods.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
|
||||||
|
if (o.itid == 67) {
|
||||||
|
if (!dicSpiritByQuality.has(o.quality)) dicSpiritByQuality.set(o.quality, []);
|
||||||
|
dicSpiritByQuality.get(o.quality)?.push(o.good_id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
arr = undefined;
|
arr = undefined;
|
||||||
|
|||||||
25
shared/pubUtils/dictionary/DicSpiritCompose.ts
Normal file
25
shared/pubUtils/dictionary/DicSpiritCompose.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 将灵合成
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { readFileAndParse } from '../util'
|
||||||
|
import { FILENAME } from '../../consts'
|
||||||
|
|
||||||
|
export interface DicSpiritCompose {
|
||||||
|
readonly goalQuality: number;
|
||||||
|
readonly materialQuality: number;
|
||||||
|
readonly materialNum: number;
|
||||||
|
}
|
||||||
|
export const dicSpiritCompose = new Map<number, DicSpiritCompose>();
|
||||||
|
|
||||||
|
export function loadSpiritCompose() {
|
||||||
|
dicSpiritCompose.clear();
|
||||||
|
|
||||||
|
let arr = readFileAndParse(FILENAME.DIC_SPIRIT_COMPOSE);
|
||||||
|
|
||||||
|
arr.forEach(o => {
|
||||||
|
dicSpiritCompose.set(o.materialQuality, o);
|
||||||
|
|
||||||
|
});
|
||||||
|
arr = undefined;
|
||||||
|
}
|
||||||
14
shared/resource/jsons/dic_zyz_spiritCompose.json
Normal file
14
shared/resource/jsons/dic_zyz_spiritCompose.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"goalQuality": 2,
|
||||||
|
"materialQuality": 1,
|
||||||
|
"materialNum": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"goalQuality": 3,
|
||||||
|
"materialQuality": 2,
|
||||||
|
"materialNum": 10
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user