武将战力计算(进阶,穿戴,羁绊,好感)加道具
This commit is contained in:
@@ -8,6 +8,7 @@ import { setAp } from './actionPointService';
|
||||
import { ItemModel } from '../db/Item';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { pinus } from 'pinus';
|
||||
const _ = require('underscore');
|
||||
|
||||
export async function handleFixedReward(roleId: string, roleName: string, rewardStr: string, multi: number) {
|
||||
let reward = decodeStr('fixReward', rewardStr);
|
||||
@@ -83,7 +84,7 @@ async function rewardItems (roleId: string, roleName: string, dicGood: any, type
|
||||
|
||||
let goods = new Array();
|
||||
let {id, cnt} = data;
|
||||
|
||||
|
||||
let result = await ItemModel.increaseItem(roleId, id, cnt, {roleId, roleName, itemName: dicGood.name, id, type, hid: dicGood.hid||0});
|
||||
|
||||
if(result) {
|
||||
@@ -174,5 +175,34 @@ export async function handleCost(roleId: string, sid: string, goods: Array<{id:
|
||||
let uids = [{uid: roleId, sid}];
|
||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, {goods: resultGoods, gold, coin} ), uids);
|
||||
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function addItems(roleId: string, sid: string, goods: Array<{id: number, count: number}>) {
|
||||
let showItems = [];
|
||||
let equips = [];
|
||||
let currencys = [];
|
||||
for (let good of goods) {
|
||||
let goodInfo = getGoodById(good.id);
|
||||
if (goodInfo.goodType == GOOD_TYPE.EQUIP) { // 装备
|
||||
equips.push({
|
||||
id: good.id,
|
||||
name: goodInfo.name,
|
||||
quality: goodInfo.lv,
|
||||
type: goodInfo.goodType
|
||||
});
|
||||
} else if (goodInfo.goodType == GOOD_TYPE.CONSUMES|| goodInfo.goodType == GOOD_TYPE.SCRIPT) {
|
||||
let {type, isCurrency} = ITID.get(goodInfo.itid);
|
||||
if (!!isCurrency) { // 货币
|
||||
let index = _.indexOf(currencys, {id: good.id});
|
||||
if (index > 0) {
|
||||
currencys[index].count = currencys[index].count + good.count;
|
||||
} else {
|
||||
currencys.push(good);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user