道具:添加礼包字段
This commit is contained in:
@@ -3,7 +3,7 @@ import { resResult } from '../../../pubUtils/util';
|
|||||||
import { FIRST_GIFT_STATE, STATUS } from '../../../consts';
|
import { FIRST_GIFT_STATE, STATUS } from '../../../consts';
|
||||||
import { getPlayerFirstGiftData } from '../../../services/firstGiftService';
|
import { getPlayerFirstGiftData } from '../../../services/firstGiftService';
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { addReward, stringToRewardParam, useGiftPackage } from '../../../services/giftPackageService';
|
import { addReward, stringToRewardParam } from '../../../services/giftPackageService';
|
||||||
import { ActivityFirstGiftModel } from '../../../db/ActivityFirstGift';
|
import { ActivityFirstGiftModel } from '../../../db/ActivityFirstGift';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Application, BackendSession } from 'pinus';
|
import { Application, BackendSession } from 'pinus';
|
||||||
import { deltaDays, resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { ACTIVITY_TYPE, FIRST_GIFT_STATE, SERVER_OPEN_TIME, STATUS } from '../../../consts';
|
import { ACTIVITY_TYPE, STATUS } from '../../../consts';
|
||||||
import { newPlayerLimitPackageActivity, getPlayerLimitPackageData, limitPackageActivity } from '../../../services/limitPackageService';
|
import { newPlayerLimitPackageActivity, getPlayerLimitPackageData } from '../../../services/limitPackageService';
|
||||||
import { addReward, stringToConsumeParam, stringToRewardParam, useGiftPackage } from '../../../services/giftPackageService';
|
import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../services/giftPackageService';
|
||||||
import { ActivityShopModel } from '../../../db/ActivityShop';
|
import { ActivityShopModel } from '../../../db/ActivityShop';
|
||||||
import moment = require('moment');
|
import moment = require('moment');
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { Application, BackendSession } from "pinus";
|
||||||
|
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE } from "../../../consts";
|
||||||
|
import { ItemInter } from "../../../pubUtils/interface";
|
||||||
|
|
||||||
|
import { resResult, parseGoodStr, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
||||||
|
import { addItems, handleCost, decreaseItems } from "../../../services/rewardService";
|
||||||
|
import Equip, { EquipModel, EquipType } from "../../../db/Equip";
|
||||||
|
import { HeroModel, EPlace } from "../../../db/Hero";
|
||||||
|
import Role from "../../../db/Role";
|
||||||
|
import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
||||||
|
import { getHeroJob, getGoodById, gameData, getHeroEquipByClassId } from "../../../pubUtils/data";
|
||||||
|
import { EQUIP } from "../../../pubUtils/dicParam";
|
||||||
|
import { ITID, SPEICAL_ITEM, QUALITY_TYPE } from "../../../consts/constModules/itemConst";
|
||||||
|
import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService";
|
||||||
|
|
||||||
|
import { indexOf, findIndex } from 'underscore';
|
||||||
|
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
||||||
|
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, checkTaskConditionEquipSuitJewelStage, checkActivityTask } from "../../../services/taskService";
|
||||||
|
import { useGiftPackage } from "../../../services/giftPackageService";
|
||||||
|
|
||||||
|
export default function (app: Application) {
|
||||||
|
return new ItemHandler(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ItemHandler {
|
||||||
|
|
||||||
|
constructor(private app: Application) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 道具的使用
|
||||||
|
public async useItem(msg: { id: number, selected: Array<number> }, session: BackendSession) {
|
||||||
|
let { id, selected } = msg;
|
||||||
|
const roleId = session.get('roleId');
|
||||||
|
const serverId = session.get('serverId');
|
||||||
|
const sid = session.get('sid');
|
||||||
|
const roleName = session.get('roleName');
|
||||||
|
const funcs = session.get('funcs');
|
||||||
|
|
||||||
|
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: 1 }]);
|
||||||
|
if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
|
||||||
|
|
||||||
|
let dicGoods = gameData.goods.get(id);
|
||||||
|
let giftID = dicGoods.gift;
|
||||||
|
let result = await useGiftPackage(roleId, roleName, sid, serverId, funcs, giftID, selected)
|
||||||
|
|
||||||
|
return resResult(STATUS.SUCCESS, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ import { decodeArrayListStr } from '../pubUtils/util';
|
|||||||
* @param sid
|
* @param sid
|
||||||
*/
|
*/
|
||||||
export async function useGiftPackage(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[], giftID: number, selected: Array<number> = []) {
|
export async function useGiftPackage(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[], giftID: number, selected: Array<number> = []) {
|
||||||
|
console.log("bbbbbbbb", giftID, selected)
|
||||||
let result = { goods: [], addHeros: [] }
|
let result = { goods: [], addHeros: [] }
|
||||||
let giftPackageData = gameData.giftPackage.get(giftID);
|
let giftPackageData = gameData.giftPackage.get(giftID);
|
||||||
if (!giftPackageData) {
|
if (!giftPackageData) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// 物品表
|
// 物品表
|
||||||
import {decodeArrayListStr, readFileAndParse, parseGoodStr, parseNumberList, decodeArrayStr} from '../util'
|
import { decodeArrayListStr, readFileAndParse, parseGoodStr, parseNumberList, decodeArrayStr } from '../util'
|
||||||
import { FILENAME, IT_TYPE, ABI_TYPE , GOOD_TYPE} from '../../consts'
|
import { FILENAME, IT_TYPE, ABI_TYPE, GOOD_TYPE } from '../../consts'
|
||||||
import { RewardInter } from '../interface';
|
import { RewardInter } from '../interface';
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
import { findWhere } from 'underscore';
|
import { findWhere } from 'underscore';
|
||||||
@@ -41,9 +41,9 @@ export interface DicGoods {
|
|||||||
// 将魂对应武将id
|
// 将魂对应武将id
|
||||||
readonly hid: number;
|
readonly hid: number;
|
||||||
// 属性
|
// 属性
|
||||||
readonly goodsAbility:Map<number, number>;
|
readonly goodsAbility: Map<number, number>;
|
||||||
// 强化属性
|
// 强化属性
|
||||||
readonly goodsAbilityUp:Map<number, number>;
|
readonly goodsAbilityUp: Map<number, number>;
|
||||||
// 套装id
|
// 套装id
|
||||||
readonly suitId: number;
|
readonly suitId: number;
|
||||||
// 特殊属性
|
// 特殊属性
|
||||||
@@ -59,11 +59,13 @@ export interface DicGoods {
|
|||||||
// 对应的装备id
|
// 对应的装备id
|
||||||
readonly equipId?: number;
|
readonly equipId?: number;
|
||||||
// 解锁条件
|
// 解锁条件
|
||||||
readonly condition: {id: number, type: number, params: number[]}[];
|
readonly condition: { id: number, type: number, params: number[] }[];
|
||||||
// 时间限制
|
// 时间限制
|
||||||
readonly timeLimit: number;
|
readonly timeLimit: number;
|
||||||
// 图片
|
// 图片
|
||||||
readonly image_id: number;
|
readonly image_id: number;
|
||||||
|
// 礼包id
|
||||||
|
readonly gift: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||||
@@ -94,12 +96,13 @@ const DicGoodsKeys: KeysEnum<DicGoods> = {
|
|||||||
equipId: true,
|
equipId: true,
|
||||||
condition: true,
|
condition: true,
|
||||||
timeLimit: true,
|
timeLimit: true,
|
||||||
image_id: true
|
image_id: true,
|
||||||
|
gift: true
|
||||||
}
|
}
|
||||||
export const dicJewel = new Map<number, DicGoods>();
|
export const dicJewel = new Map<number, DicGoods>();
|
||||||
export const dicGoods = new Map<number, DicGoods>();
|
export const dicGoods = new Map<number, DicGoods>();
|
||||||
export const blueprt = new Map<number, Array<number>>();
|
export const blueprt = new Map<number, Array<number>>();
|
||||||
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 function loadGoods() {
|
export function loadGoods() {
|
||||||
let arr = readFileAndParse(FILENAME.DIC_GOODS);
|
let arr = readFileAndParse(FILENAME.DIC_GOODS);
|
||||||
@@ -119,22 +122,22 @@ export function loadGoods() {
|
|||||||
o.equipId = good.good_id;
|
o.equipId = good.good_id;
|
||||||
}
|
}
|
||||||
let condition = parseConditionStr(o.condition);
|
let condition = parseConditionStr(o.condition);
|
||||||
for(let {id, type, params} of condition) {
|
for (let { id, type, params } of condition) {
|
||||||
let mapArr = figureCondition.get(type)||new Array<{params: number[], id: number, gid: number}>();
|
let mapArr = figureCondition.get(type) || new Array<{ params: number[], id: number, gid: number }>();
|
||||||
mapArr.push({ params, id: id, gid: o.good_id});
|
mapArr.push({ params, id: id, gid: o.good_id });
|
||||||
figureCondition.set(type, mapArr);
|
figureCondition.set(type, mapArr);
|
||||||
}
|
}
|
||||||
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 == IT_TYPE.BLUEPRT) {
|
if (o.itid == IT_TYPE.BLUEPRT) {
|
||||||
let arr = blueprt.get(o.quality)||new Array<number>();
|
let arr = blueprt.get(o.quality) || new Array<number>();
|
||||||
arr.push(o.good_id);
|
arr.push(o.good_id);
|
||||||
blueprt.set(o.quality, arr);
|
blueprt.set(o.quality, arr);
|
||||||
} else if (o.goodType == GOOD_TYPE.JEWEL) {
|
} else if (o.goodType == GOOD_TYPE.JEWEL) {
|
||||||
let material = o.composeMaterial[0];
|
let material = o.composeMaterial[0];
|
||||||
if (!!material && !!material.id) {
|
if (!!material && !!material.id) {
|
||||||
let lastJewel = findWhere(arr,{good_id:material.id});
|
let lastJewel = findWhere(arr, { good_id: material.id });
|
||||||
if (!!lastJewel) {
|
if (!!lastJewel) {
|
||||||
lastJewel.count = material.count;
|
lastJewel.count = material.count;
|
||||||
lastJewel.nextJewelId = o.good_id;
|
lastJewel.nextJewelId = o.good_id;
|
||||||
@@ -155,10 +158,10 @@ export function loadGoods() {
|
|||||||
|
|
||||||
function parseSpecialAttr(str: string) {
|
function parseSpecialAttr(str: string) {
|
||||||
let specialAttr = new Map<number, number>();
|
let specialAttr = new Map<number, number>();
|
||||||
if(str) {
|
if (str) {
|
||||||
let decodeArr = decodeArrayListStr(str);
|
let decodeArr = decodeArrayListStr(str);
|
||||||
for(let [type, count] of decodeArr) {
|
for (let [type, count] of decodeArr) {
|
||||||
if(isNaN(parseInt(type)) || isNaN(parseInt(count))) {
|
if (isNaN(parseInt(type)) || isNaN(parseInt(count))) {
|
||||||
throw new Error('data table format wrong');
|
throw new Error('data table format wrong');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,35 +173,35 @@ function parseSpecialAttr(str: string) {
|
|||||||
|
|
||||||
function parseAbility(json) {
|
function parseAbility(json) {
|
||||||
let map = new Map<number, number>();
|
let map = new Map<number, number>();
|
||||||
map.set(ABI_TYPE.ABI_HP, json.hp||0);
|
map.set(ABI_TYPE.ABI_HP, json.hp || 0);
|
||||||
map.set(ABI_TYPE.ABI_ATK, json.atk||0);
|
map.set(ABI_TYPE.ABI_ATK, json.atk || 0);
|
||||||
map.set(ABI_TYPE.ABI_DEF, json.def||0);
|
map.set(ABI_TYPE.ABI_DEF, json.def || 0);
|
||||||
map.set(ABI_TYPE.ABI_MDEF, json.mdef||0);
|
map.set(ABI_TYPE.ABI_MDEF, json.mdef || 0);
|
||||||
map.set(ABI_TYPE.ABI_DAMAGE_INCREASE, json.damageIncrease||0);
|
map.set(ABI_TYPE.ABI_DAMAGE_INCREASE, json.damageIncrease || 0);
|
||||||
map.set(ABI_TYPE.ABI_DAMAGE_DECREASE, json.damageDecrease||0);
|
map.set(ABI_TYPE.ABI_DAMAGE_DECREASE, json.damageDecrease || 0);
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseAbilityUp(json) {
|
function parseAbilityUp(json) {
|
||||||
let map = new Map<number, number>();
|
let map = new Map<number, number>();
|
||||||
map.set(ABI_TYPE.ABI_HP, json.hp_up||0);
|
map.set(ABI_TYPE.ABI_HP, json.hp_up || 0);
|
||||||
map.set(ABI_TYPE.ABI_ATK, json.atk_up||0);
|
map.set(ABI_TYPE.ABI_ATK, json.atk_up || 0);
|
||||||
map.set(ABI_TYPE.ABI_DEF, json.def_up||0);
|
map.set(ABI_TYPE.ABI_DEF, json.def_up || 0);
|
||||||
map.set(ABI_TYPE.ABI_MDEF, json.mdef_up||0);
|
map.set(ABI_TYPE.ABI_MDEF, json.mdef_up || 0);
|
||||||
map.set(ABI_TYPE.ABI_DAMAGE_INCREASE, json.damageIncrease_up||0);
|
map.set(ABI_TYPE.ABI_DAMAGE_INCREASE, json.damageIncrease_up || 0);
|
||||||
map.set(ABI_TYPE.ABI_DAMAGE_DECREASE, json.damageDecrease_up||0);
|
map.set(ABI_TYPE.ABI_DAMAGE_DECREASE, json.damageDecrease_up || 0);
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSpecialMaterial(str: string) {
|
function parseSpecialMaterial(str: string) {
|
||||||
let specialAttr = {ids: new Array<number>(), count: 0}
|
let specialAttr = { ids: new Array<number>(), count: 0 }
|
||||||
if(!str) return specialAttr;
|
if (!str) return specialAttr;
|
||||||
|
|
||||||
let decodeArr = decodeArrayStr(str);
|
let decodeArr = decodeArrayStr(str);
|
||||||
if(decodeArr.length >= 2) {
|
if (decodeArr.length >= 2) {
|
||||||
let ids = parseNumberList(decodeArr[0]);
|
let ids = parseNumberList(decodeArr[0]);
|
||||||
let count = parseInt(decodeArr[1]);
|
let count = parseInt(decodeArr[1]);
|
||||||
if(isNaN(count)) return specialAttr;
|
if (isNaN(count)) return specialAttr;
|
||||||
specialAttr.ids = ids;
|
specialAttr.ids = ids;
|
||||||
specialAttr.count = count;
|
specialAttr.count = count;
|
||||||
}
|
}
|
||||||
@@ -217,7 +220,7 @@ export function parseConditionStr(str: string) {
|
|||||||
throw new Error('data table format wrong');
|
throw new Error('data table format wrong');
|
||||||
}
|
}
|
||||||
let parsedParam = new Array<number>();
|
let parsedParam = new Array<number>();
|
||||||
for(let param of params) {
|
for (let param of params) {
|
||||||
if (isNaN(parseInt(param))) {
|
if (isNaN(parseInt(param))) {
|
||||||
throw new Error('data table format wrong');
|
throw new Error('data table format wrong');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user