抽卡:修改抽卡奖池逻辑
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, GACHA_ID, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
import { STATUS, GACHA_TYPE, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
import { getPlayerNewHeroGachaData } from '../../../services/activity/newHeroGachaService';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { HeroModel } from '../../../db/Hero';
|
||||
@@ -62,50 +62,50 @@ export class NewHeroGachaHandler {
|
||||
* @param {BackendSession} session
|
||||
* @memberof NewHeroGachaHandler
|
||||
*/
|
||||
async pull(msg: { activityId: number, hid: number, count: number }, session: BackendSession) {
|
||||
const { activityId, hid, count } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const roleName = session.get('roleName');
|
||||
// async pull(msg: { activityId: number, hid: number, count: number }, session: BackendSession) {
|
||||
// const { activityId, hid, count } = msg;
|
||||
// const roleId = session.get('roleId');
|
||||
// const serverId = session.get('serverId');
|
||||
// const sid = session.get('sid');
|
||||
// const roleName = session.get('roleName');
|
||||
|
||||
if(count < 0) return resResult(STATUS.WRONG_PARMS);
|
||||
// if(count < 0) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let playerData = await getPlayerNewHeroGachaData(activityId, serverId, roleId)
|
||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
// let playerData = await getPlayerNewHeroGachaData(activityId, serverId, roleId)
|
||||
// if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
|
||||
let item = playerData.findItem(hid);
|
||||
if (!item) {
|
||||
return resResult(STATUS.ACTIVITY_DATA_ERROR);
|
||||
}
|
||||
// let item = playerData.findItem(hid);
|
||||
// if (!item) {
|
||||
// return resResult(STATUS.ACTIVITY_DATA_ERROR);
|
||||
// }
|
||||
|
||||
let userHeroes = await HeroModel.findByRole(roleId);
|
||||
// let userHeroes = await HeroModel.findByRole(roleId);
|
||||
|
||||
let gachaPull = new GachaPull(GACHA_ID.TIMELIMIT);
|
||||
gachaPull.setByActivity(item);
|
||||
let { items, heroInfo, resultList } = gachaPull.pull(count, userHeroes);
|
||||
let { hasGetFloor, floorCount } = gachaPull.getActivityParam();
|
||||
// let gachaPull = new GachaPull(GACHA_TYPE.TIMELIMIT);
|
||||
// gachaPull.setByActivity(item);
|
||||
// let { items, heroInfo, resultList } = gachaPull.pull(count, userHeroes);
|
||||
// let { hasGetFloor, floorCount } = gachaPull.getActivityParam();
|
||||
|
||||
// 消耗东西
|
||||
let cost = item.cost.map(cur => { return { id: cur.id, count: cur.count * count } });
|
||||
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.NEW_HERO_GACHA_PULL);
|
||||
if (!costResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
|
||||
// // 消耗东西
|
||||
// let cost = item.cost.map(cur => { return { id: cur.id, count: cur.count * count } });
|
||||
// let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.NEW_HERO_GACHA_PULL);
|
||||
// if (!costResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
|
||||
|
||||
//记录数据
|
||||
await ActivityNewHeroGachaModel.addRecord(serverId, activityId, roleId, hid, floorCount, JSON.stringify(resultList), hasGetFloor);
|
||||
// //记录数据
|
||||
// await ActivityNewHeroGachaModel.addRecord(serverId, activityId, roleId, hid, floorCount, JSON.stringify(resultList), hasGetFloor);
|
||||
|
||||
// 给东西
|
||||
let { heroes, resultHeroes } = await createHeroes(roleId, roleName, sid, serverId, heroInfo);
|
||||
await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.GACHA_ITEMS);
|
||||
//固定奖励
|
||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.commonReward);
|
||||
let newRewardParamArr: Array<RewardParam> = rewardParamArr.map(obj => { return { id: obj.id, type: obj.type, count: obj.count * count } });
|
||||
let commonResult = await addReward(roleId, roleName, sid, serverId, newRewardParamArr, ITEM_CHANGE_REASON.NEW_HERO_GACHA_PULL)
|
||||
// // 给东西
|
||||
// let { heroes, resultHeroes } = await createHeroes(roleId, roleName, sid, serverId, heroInfo);
|
||||
// await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.GACHA_ITEMS);
|
||||
// //固定奖励
|
||||
// let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.commonReward);
|
||||
// let newRewardParamArr: Array<RewardParam> = rewardParamArr.map(obj => { return { id: obj.id, type: obj.type, count: obj.count * count } });
|
||||
// let commonResult = await addReward(roleId, roleName, sid, serverId, newRewardParamArr, ITEM_CHANGE_REASON.NEW_HERO_GACHA_PULL)
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
hid, activityId, count, randomReward: { heroes: resultHeroes.map(cur => ({hid: cur.hid})), result: resultList }, commonReward: commonResult
|
||||
// return resResult(STATUS.SUCCESS, {
|
||||
// hid, activityId, count, randomReward: { heroes: resultHeroes.map(cur => ({hid: cur.hid})), result: resultList }, commonReward: commonResult
|
||||
|
||||
});
|
||||
}
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user