军团优化:拍卖行基础奖励
This commit is contained in:
@@ -4,11 +4,11 @@ import { GuildModel } from '../../../db/Guild';
|
||||
import { WishPoolReportModel } from '../../../db/WishPoolReport';
|
||||
import { resResult, genCode } from '../../../pubUtils/util';
|
||||
import { ITEM_CHANGE_REASON, PUSH_ROUTE, STATUS } from '../../../consts';
|
||||
import { getArmyWishPoolBaseByLv, getGoodById, getWishPoolReward } from '../../../pubUtils/data';
|
||||
import { gameData, getGoodById, getWishPoolReward } from '../../../pubUtils/data';
|
||||
import { addItems, checkGoods, checkHeroEquips, checkHeroes, getHonourObject, handleCost } from '../../../services/role/rewardService';
|
||||
import { ITID, CONSUME_TYPE } from '../../../consts/constModules/itemConst';
|
||||
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
|
||||
import { refreshUserGuild, getWishPool, getUserGuildWithRefActive } from '../../../services/guildService';
|
||||
import { GUILD_POINT_WAYS, GUILD_STRUCTURE, WISH_POOL_TYPE } from '../../../consts/constModules/guildConst';
|
||||
import { refreshUserGuild, getWishPool, getUserGuildWithRefActive, addActive } from '../../../services/guildService';
|
||||
import { findIndex, findWhere } from 'underscore';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
@@ -41,30 +41,17 @@ export class WishPoolHandler {
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let dicGoods = getGoodById(goodId)
|
||||
if (!dicGoods) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
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);
|
||||
if (dicItid.type != CONSUME_TYPE.SOUL && type != WISH_POOL_TYPE.SOUL)
|
||||
return resResult(STATUS.GUILD_WISH_POOL_CAN_NOT_WISH);
|
||||
|
||||
let userGuild = await refreshUserGuild(myUserGuild, roleId);
|
||||
if (!userGuild) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let result = await checkGoods(roleId, [goodId]);
|
||||
if (!result) {
|
||||
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 (dicItid.type == CONSUME_TYPE.DRAWING ) {
|
||||
result = await checkHeroEquips(roleId, dicGoods.quality);
|
||||
if (!result)
|
||||
return resResult(STATUS.GUILD_WISH_POOL_NOT_OWN_EQUIP);
|
||||
}
|
||||
}
|
||||
const { guildCode: code, wishGoods, receivedWishPool, createdAt } = userGuild;
|
||||
|
||||
let { structure } = await GuildModel.findGuild(code, serverId, 'structure');
|
||||
let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.WISH_POOL});
|
||||
let { lv } = await GuildModel.findGuild(code, serverId, 'lv');
|
||||
let len = wishGoods.filter(cur => cur.type == type).length;
|
||||
|
||||
if(receivedWishPool.indexOf(type) != -1 && getSeconds(createdAt) > getZeroPoint()) {
|
||||
@@ -73,17 +60,14 @@ export class WishPoolHandler {
|
||||
if (len >= ARMY.ARMY_WISH_TIMES) //今日已经许愿过
|
||||
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
|
||||
|
||||
let dicWishPool = getArmyWishPoolBaseByLv(lv);
|
||||
let dicStructure = gameData.centerBase.get(lv);
|
||||
let count = 0;
|
||||
if (type == 1) {
|
||||
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 = dicWishPool.wishGoodsHeros.find(cur => cur.quality == dicGoods.quality);
|
||||
if (type == WISH_POOL_TYPE.SOUL) {
|
||||
let wishGoodsHero = dicStructure.wishgoodsHero.find(cur => cur.quality == dicGoods.quality);
|
||||
if (!wishGoodsHero) return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
|
||||
count = wishGoodsHero.count;
|
||||
}
|
||||
|
||||
const id = genCode(6);
|
||||
let { wishGoods: resWishGoods } = await UserGuildModel.pushAndUpdate(roleId, {}, { wishGoods: { type, goodId, count, receiveCnt: 0, drawCnt: 0, id, donateNames:[]} }, 'wishGoods');
|
||||
return resResult(STATUS.SUCCESS, { wishGoods: resWishGoods });
|
||||
@@ -94,6 +78,7 @@ export class WishPoolHandler {
|
||||
let { wishRoleId, id, myUserGuild } = msg;
|
||||
const dntRoleId: string = session.get('roleId');
|
||||
const dntRoleName: string = session.get('roleName');
|
||||
const serverId: number = session.get('serverId');
|
||||
const sid: string = session.get('sid');
|
||||
if (wishRoleId == dntRoleId)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
@@ -132,6 +117,8 @@ export class WishPoolHandler {
|
||||
}
|
||||
await WishPoolReportModel.addReport(code, wishRoleId, role.roleName , dntRoleId, dntRoleName, wishGood.goodId, 1);
|
||||
let goods = await addItems(dntRoleId, dntRoleName, sid, [getHonourObject(dicWishReward.honourReward)], ITEM_CHANGE_REASON.WISH_POOL_DONATE);
|
||||
await addActive(dntRoleId, serverId, GUILD_POINT_WAYS.DONATE);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { wishDntCnt, goods, updateWishGoods: resWishGoods.map(({type, goodId, count, receiveCnt, drawCnt, id})=>{
|
||||
return { type, goodId, count, receiveCnt, drawCnt, id, roleId: wishRoleId };
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user