抽卡:提供内部接口
This commit is contained in:
@@ -131,9 +131,14 @@ export class GachaHandler {
|
||||
|
||||
// 任务
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GASHA, count, true, {});
|
||||
|
||||
let resultRefFreeTime = 0;
|
||||
if(dicGacha.free.count > 0) {
|
||||
resultRefFreeTime = getAfterDateByDay(refFreeTime, dicGacha.free.day);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
gachaId, activityId,
|
||||
freeCount, refFreeTime: getAfterDateByDay(refFreeTime, dicGacha.free.day), count, point, floor,
|
||||
freeCount, refFreeTime: resultRefFreeTime, count, point, floor,
|
||||
heroes, result: resultList
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,39 +1,28 @@
|
||||
import { GachaData, Floor, GachaResult, Hope } from "../domain/activityField/gachaField";;
|
||||
import { ActivityModelType, ActivityModel } from "../db/Activity";
|
||||
import { ActivityModel } from "../db/Activity";
|
||||
import { DicGacha } from "../pubUtils/dictionary/DicGacha";
|
||||
import { UserGachaType, UserGachaModel } from "../db/UserGacha";
|
||||
import { shouldRefresh, getRandEelm, decodeArrayListStr, getRandomWithWeight, decodeIdCntArrayStr } from "../pubUtils/util";
|
||||
import { REFRESH_HOUR, GACHA_ID, GACHA_TO_FLOOR, GACHA_FLOOR_TYPE, GACHA_CONTENT_TYPE, HERO_QUALITY_TYPE, GACHA_OCCUPY_HID, IT_TYPE, ITID, CONSUME_TYPE, SPECIAL_ATTR } from "../consts";
|
||||
import { shouldRefresh, getRandEelm, getRandomWithWeight } from "../pubUtils/util";
|
||||
import { REFRESH_HOUR, GACHA_TO_FLOOR, GACHA_FLOOR_TYPE, GACHA_CONTENT_TYPE, HERO_QUALITY_TYPE, GACHA_OCCUPY_HID, IT_TYPE, ITID, CONSUME_TYPE, SPECIAL_ATTR } from "../consts";
|
||||
import { getNextDayByGap, getTodayZeroDate } from "../pubUtils/timeUtil";
|
||||
import { gameData, getDicGachaFloor } from "../pubUtils/data";
|
||||
import { RECRUIT } from "../pubUtils/dicParam";
|
||||
|
||||
/**
|
||||
* 获取活动页签里的限时卡池
|
||||
*
|
||||
* @param roleId 玩家id
|
||||
* @param aid 活动id
|
||||
*/
|
||||
export async function getLimitGacha(activityId: number) {
|
||||
export async function getLimitGacha(roleId: string, activityId: number) {
|
||||
|
||||
let activityData = await ActivityModel.findActivity(activityId, true);
|
||||
if(!activityData) return false;
|
||||
|
||||
let gachaData = new GachaData(activityData);
|
||||
|
||||
let { heroes, gachaId } = gachaData;
|
||||
|
||||
return {
|
||||
gachaId,
|
||||
heroes,
|
||||
pickHero: 0,
|
||||
freeCount: 0,
|
||||
refFreeTime: 0,
|
||||
count: 0,
|
||||
floor: [{
|
||||
id: 3,
|
||||
count: 0
|
||||
}]
|
||||
}
|
||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaData.gachaId, activityId);
|
||||
userGacha = await refreshGacha(gameData.gacha.get(gachaData.gachaId), userGacha);
|
||||
gachaData.setUserGacha(userGacha);
|
||||
return gachaData
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -320,7 +320,6 @@ export async function createHeroes(roleId: string, roleName: string, sid: string
|
||||
|
||||
let newHeroInfo: CreateHeroParam[] = [], pieces: ItemInter[] = [];
|
||||
for(let h of heroInfo) {
|
||||
console.log('*****', JSON.stringify([...userHeroesMap]), h.hid)
|
||||
if(userHeroesMap.has(h.hid)) {
|
||||
let {pieceId, count} = transPiece(h.hid);
|
||||
pieces.push({ id: pieceId, count });
|
||||
|
||||
@@ -2,10 +2,11 @@ import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityBase } from './activityField';
|
||||
import { prop } from '@typegoose/typegoose';
|
||||
import { UserGachaType } from '../../db/UserGacha';
|
||||
import { getSeconds, getAfterDateByDay } from '../../pubUtils/timeUtil';
|
||||
import { getAfterDateByDay } from '../../pubUtils/timeUtil';
|
||||
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
|
||||
import { getFloorStatus } from '../../services/gachaService';
|
||||
import { GACHA_OCCUPY_HID } from '../../consts';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
|
||||
|
||||
// 抽卡数据
|
||||
@@ -13,12 +14,29 @@ export class GachaData extends ActivityBase {
|
||||
gachaId: number = 0;
|
||||
heroes: Array<number> = [];
|
||||
|
||||
pickHero: number;
|
||||
freeCount: number;
|
||||
refFreeTime: number = 0;
|
||||
count: number;
|
||||
floor: Floor[];
|
||||
|
||||
public initData(data: string) {
|
||||
let obj = JSON.parse(data);
|
||||
this.gachaId = obj.gachaId;
|
||||
this.heroes = obj.heroes;
|
||||
}
|
||||
|
||||
public setUserGacha(userGacha: UserGachaType) {
|
||||
let dicGacha = gameData.gacha.get(this.gachaId);
|
||||
this.pickHero = userGacha.pickHero;
|
||||
this.freeCount = userGacha.freeCount;
|
||||
if(dicGacha.free.count > 0) {
|
||||
this.refFreeTime = getAfterDateByDay(userGacha.refFreeTime, dicGacha.free.day);
|
||||
}
|
||||
this.count = userGacha.count;
|
||||
this.floor = userGacha.floor;
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
super(activityData)
|
||||
}
|
||||
@@ -78,7 +96,9 @@ export class GachaListReturn {
|
||||
|
||||
if(userGacha) {
|
||||
this.freeCount = userGacha.freeCount;
|
||||
this.refFreeTime = getAfterDateByDay(userGacha.refFreeTime, dicGacha.free.day);
|
||||
if(dicGacha.free.count > 0) {
|
||||
this.refFreeTime = getAfterDateByDay(userGacha.refFreeTime, dicGacha.free.day);
|
||||
}
|
||||
this.count = userGacha.count;
|
||||
this.floor = getFloorStatus(dicGacha.id, userGacha.floor);
|
||||
this.hope = userGacha.hope;
|
||||
|
||||
Reference in New Issue
Block a user