feat(活动): 新将擢迁保底显示

This commit is contained in:
luying
2023-06-20 19:51:54 +08:00
parent fac1b923a7
commit f3e82af5c9
4 changed files with 38 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts';
import { getPlayerNewHeroGachaData } from '../../../services/activity/newHeroService';
export default function (app: Application) {
new HandlerService(app, {});
return new NewHeroGachaHandler(app);
}
export class NewHeroGachaHandler {
constructor(private app: Application) {
}
/**
* @description 获取关卡活动数据
* @param {{ activityId: number}} msg
* @param {BackendSession} session
* @memberof NewHeroGachaHandler
*/
async getData(msg: { activityId: number }, session: BackendSession) {
const { activityId } = msg;
const roleId = session.get('roleId');
const serverId = session.get('serverId');
let playerData = await getPlayerNewHeroGachaData(activityId, serverId, roleId)
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
return resResult(STATUS.SUCCESS, playerData);
}
}

View File

@@ -105,6 +105,7 @@ export function checkRouteParam(route: string, msg: any) {
case 'activity.newHeroGachaHandler.getNewHeroGachaActivity': case 'activity.newHeroGachaHandler.getNewHeroGachaActivity':
case 'activity.newHeroGiftsHandler.getNewHeroGiftsActivity': case 'activity.newHeroGiftsHandler.getNewHeroGiftsActivity':
case 'activity.newHeroGKHandler.getNewHeroGKActivity': case 'activity.newHeroGKHandler.getNewHeroGKActivity':
case 'activity.newHeroGachaHandler.getData':
case 'activity.popUpShopHandler.getPopUpShopActivity': case 'activity.popUpShopHandler.getPopUpShopActivity':
case 'activity.rechargeMoneyHandler.getRechargeMoneyActivity': case 'activity.rechargeMoneyHandler.getRechargeMoneyActivity':
case 'activity.refreshShopHandler.getRefreshShopActivity': case 'activity.refreshShopHandler.getRefreshShopActivity':

View File

@@ -1,6 +1,7 @@
import { ActivityModelType } from '../../db/Activity'; import { ActivityModelType } from '../../db/Activity';
import { UserGachaType } from '../../db/UserGacha'; import { UserGachaType } from '../../db/UserGacha';
import { DicGacha } from '../../pubUtils/dictionary/DicGacha'; import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
import { getGachaRemainFloor } from '../../pubUtils/util';
import { ActivityBase } from './activityField'; import { ActivityBase } from './activityField';
interface NewHeroGachaItemInDb { interface NewHeroGachaItemInDb {
@@ -29,6 +30,7 @@ export class NewHeroGachaData extends ActivityBase {
pickHero: number = 0; pickHero: number = 0;
count: number = 0; count: number = 0;
isFree: boolean = false; // 免费次数 isFree: boolean = false; // 免费次数
remainFloor: number = 0;
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) { constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
super(activityData, createTime, serverTime) super(activityData, createTime, serverTime)
@@ -59,6 +61,7 @@ export class NewHeroGachaData extends ActivityBase {
this.pickHero = data.pickHero; this.pickHero = data.pickHero;
this.count = data.count; this.count = data.count;
this.isFree = data.freeCount < dic?.free.count; this.isFree = data.freeCount < dic?.free.count;
this.remainFloor = getGachaRemainFloor(data.gachaId, data.floor||[])
} }
} }

View File

@@ -839,7 +839,7 @@ export function arrToMap<T>(arr: T[], getKey: (obj: T) => number|string): Map<nu
export function getGachaRemainFloor(gachaId: number, userFloor: Floor[]) { export function getGachaRemainFloor(gachaId: number, userFloor: Floor[]) {
let dicGacha = gameData.gacha.get(gachaId); let dicGacha = gameData.gacha.get(gachaId);
if(dicGacha.gachaType != GACHA_TYPE.NORMAL) return 0; if(dicGacha.gachaType != GACHA_TYPE.NORMAL && dicGacha.gachaType != GACHA_TYPE.ACTIVITY) return 0;
for(let floorId of dicGacha.floor) { for(let floorId of dicGacha.floor) {
let dicGachaFloor = gameData.gachaFloor.get(floorId); let dicGachaFloor = gameData.gachaFloor.get(floorId);