装备:清理旧代码
This commit is contained in:
@@ -5,8 +5,8 @@ import { WishPoolReportModel } from '../../../db/WishPoolReport';
|
||||
import { resResult, genCode } from '../../../pubUtils/util';
|
||||
import { ITEM_CHANGE_REASON, STATUS } from '../../../consts';
|
||||
import { getArmyWishPoolBaseByLv, getGoodById, getWishPoolReward } from '../../../pubUtils/data';
|
||||
import { addItems, checkGoods, checkHeroes } from '../../../services/rewardService';
|
||||
import { IT_TYPE } from '../../../consts/constModules/itemConst';
|
||||
import { addItems, checkGoods, checkHeroEquips, checkHeroes } from '../../../services/rewardService';
|
||||
import { ITID, CONSUME_TYPE } from '../../../consts/constModules/itemConst';
|
||||
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
|
||||
import { refreshUserGuild, getWishPool, getUserGuildWithRefActive } from '../../../services/guildService';
|
||||
import { findIndex, findWhere } from 'underscore';
|
||||
@@ -40,23 +40,23 @@ export class WishPoolHandler {
|
||||
const { goodId, type, myUserGuild } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let count;
|
||||
let goodInfo = getGoodById(goodId)
|
||||
if (!goodInfo)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!(goodInfo.itid == IT_TYPE.HERO_PIECE && type == 2 ) && !(goodInfo.itid == IT_TYPE.EQUIP_PIECE && type == 1 ))
|
||||
let dicGoods = getGoodById(goodId)
|
||||
if (!dicGoods) return resResult(STATUS.WRONG_PARMS);
|
||||
let dicItid = ITID.get(dicGoods.itid);
|
||||
if (!(dicItid.type == CONSUME_TYPE.SOUL && type == 2 ) && !(dicItid.type == CONSUME_TYPE.DRAWING && type == 1 ))
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let userGuild = await refreshUserGuild(myUserGuild, roleId);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let result = await checkGoods(roleId, [goodId]);
|
||||
if (!result) {
|
||||
if (goodInfo.itid == IT_TYPE.HERO_PIECE ) {
|
||||
result = await checkHeroes(roleId, [goodInfo.hid]);
|
||||
if (dicItid.type == CONSUME_TYPE.SOUL ) {
|
||||
result = await checkHeroes(roleId, [dicGoods.hid]);
|
||||
if (!result)
|
||||
return resResult(STATUS.GUILD_WISH_POOL_NOT_OWN_HERO);
|
||||
} else if (goodInfo.itid == IT_TYPE.EQUIP_PIECE ) {
|
||||
result = await checkGoods(roleId, [goodInfo.equipId]);
|
||||
} else if (dicItid.type == CONSUME_TYPE.DRAWING ) {
|
||||
result = await checkHeroEquips(roleId, dicGoods.quality);
|
||||
if (!result)
|
||||
return resResult(STATUS.GUILD_WISH_POOL_NOT_OWN_EQUIP);
|
||||
}
|
||||
@@ -65,27 +65,23 @@ export class WishPoolHandler {
|
||||
|
||||
let { structure } = await GuildModel.findGuild(code, serverId, 'structure');
|
||||
let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.WISH_POOL});
|
||||
let { wishgoodsDrawings, wishGoodsHeros } = getArmyWishPoolBaseByLv(lv);
|
||||
let len = 0;
|
||||
wishGoods.map(({type: resType})=>{
|
||||
if (resType == type)
|
||||
len++;
|
||||
});
|
||||
let len = wishGoods.filter(cur => cur.type == type).length;
|
||||
|
||||
if(receivedWishPool.indexOf(type) != -1 && getSeconds(createdAt) > getZeroPoint()) {
|
||||
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
|
||||
}
|
||||
if (len >= ARMY.ARMY_WISH_TIMES) //今日已经许愿过
|
||||
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
|
||||
|
||||
let dicWishPool = getArmyWishPoolBaseByLv(lv);
|
||||
let count = 0;
|
||||
if (type == 1) {
|
||||
let wishGoodsDrawing = findWhere(wishgoodsDrawings, { quality: goodInfo.quality});
|
||||
if (!wishGoodsDrawing)
|
||||
return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
|
||||
let wishGoodsDrawing = dicWishPool.wishgoodsDrawings.find(cur => cur.quality == dicGoods.quality);
|
||||
if (!wishGoodsDrawing) return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
|
||||
count = wishGoodsDrawing.count;
|
||||
} else {
|
||||
let wishGoodsHero = findWhere(wishGoodsHeros, { quality: goodInfo.quality});
|
||||
if (!wishGoodsHero)
|
||||
return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
|
||||
let wishGoodsHero = dicWishPool.wishGoodsHeros.find(cur => cur.quality == dicGoods.quality);
|
||||
if (!wishGoodsHero) return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
|
||||
count = wishGoodsHero.count;
|
||||
}
|
||||
const id = genCode(6);
|
||||
|
||||
Reference in New Issue
Block a user