500抽:活动格式

This commit is contained in:
luying
2022-07-28 20:27:08 +08:00
parent dbcbabfda6
commit 2806fdd9b1
10 changed files with 205 additions and 200 deletions
@@ -2,8 +2,7 @@ import { Application, BackendSession, HandlerService, } from "pinus";
import { resResult, shouldRefresh, getRandSingleEelm, getGachaRemainFloor } from "../../../pubUtils/util"; import { resResult, shouldRefresh, getRandSingleEelm, getGachaRemainFloor } from "../../../pubUtils/util";
import { STATUS, GACHA_TYPE, HERO_QUALITY_TYPE, TASK_TYPE, ITEM_CHANGE_REASON, } from "../../../consts"; import { STATUS, GACHA_TYPE, HERO_QUALITY_TYPE, TASK_TYPE, ITEM_CHANGE_REASON, } from "../../../consts";
import { gameData } from "../../../pubUtils/data"; import { gameData } from "../../../pubUtils/data";
import { GachaData, GachaResultIndb } from "../../../domain/activityField/gachaField"; import { UserGachaModel } from "../../../db/UserGacha";
import { SimpleResult, UserGachaModel } from "../../../db/UserGacha";
import { refreshGacha, getGachaList, getVisitedHeroList, GachaPull, getGuideGachaId, GachaResults, getDicGachaByGachaCnt, getNormalGachaId } from "../../../services/activity/gachaService"; import { refreshGacha, getGachaList, getVisitedHeroList, GachaPull, getGuideGachaId, GachaResults, getDicGachaByGachaCnt, getNormalGachaId } from "../../../services/activity/gachaService";
import { RoleModel } from "../../../db/Role"; import { RoleModel } from "../../../db/Role";
import { HeroModel } from "../../../db/Hero"; import { HeroModel } from "../../../db/Hero";
@@ -15,6 +14,7 @@ import { getActivityById } from "../../../services/activity/activityService";
import { checkTaskInGacha } from "../../../services/task/taskService"; import { checkTaskInGacha } from "../../../services/task/taskService";
import { createHeroes } from "../../../services/role/createHero"; import { createHeroes } from "../../../services/role/createHero";
import { getRoleCreateTime, getServerCreateTime } from "../../../services/redisService"; import { getRoleCreateTime, getServerCreateTime } from "../../../services/redisService";
import { getGuideGachaData } from "../../../services/activity/guideGachaService";
export default function (app: Application) { export default function (app: Application) {
new HandlerService(app, {}); new HandlerService(app, {});
@@ -99,7 +99,6 @@ export class GachaHandler {
return resResult(STATUS.SUCCESS, { return resResult(STATUS.SUCCESS, {
gachaId, activityId, gachaId, activityId,
freeCount, refFreeTime: userGacha.refFreeTime, count: userGacha.count, point: userGacha.point, floor, hope, freeCount, refFreeTime: userGacha.refFreeTime, count: userGacha.count, point: userGacha.point, floor, hope,
guideResultCount: userGacha.guideResultCount,
// heroes: resultHeroes, // heroes: resultHeroes,
addHeros: heroes, addHeros: heroes,
result: resultList, result: resultList,
@@ -301,22 +300,14 @@ export class GachaHandler {
* @param {BackendSession} session * @param {BackendSession} session
* @memberof GachaHandler * @memberof GachaHandler
*/ */
async getGuideGachaData(msg: {}, session: BackendSession) { async getGuideGachaData(msg: { activityId: number }, session: BackendSession) {
const { } = msg;
const roleId: string = session.get('roleId'); const roleId: string = session.get('roleId');
let { gachaHasGuide } = await RoleModel.findByRoleId(roleId, 'gachaHasGuide'); const serverId: number = session.get('serverId');
let guideCount = 0, guideResultList = [], candidates = [];
if(!gachaHasGuide) {
let gachaId = getGuideGachaId();
const userGacha = await UserGachaModel.findByRole(roleId, gachaId);
({ guideCount = 0, guideResultList = [], candidates = [] } = userGacha);
}
return resResult(STATUS.SUCCESS, { const { activityId } = msg;
guideCount, let playerData = await getGuideGachaData(serverId, activityId, roleId);
latest: guideResultList,
candidates return resResult(STATUS.SUCCESS, { playerData });
});
} }
/** /**
@@ -325,35 +316,35 @@ export class GachaHandler {
* @param {BackendSession} session * @param {BackendSession} session
* @memberof GachaHandler * @memberof GachaHandler
*/ */
async guidePull(msg: {}, session: BackendSession) { async guidePull(msg: { activityId: number; }, session: BackendSession) {
const { } = msg; // const { } = msg;
const roleId: string = session.get('roleId'); // const roleId: string = session.get('roleId');
const sid: string = session.get('sid'); // const sid: string = session.get('sid');
const count = 10; // const count = 10;
const gachaId = getGuideGachaId(); // const gachaId = getGuideGachaId();
const dicGacha = gameData.gacha.get(gachaId); // const dicGacha = gameData.gacha.get(gachaId);
let userGacha = await UserGachaModel.findByRole(roleId, gachaId); // let userGacha = await UserGachaModel.findByRole(roleId, gachaId);
let { guideCount = 0 } = userGacha; // let { guideCount = 0 } = userGacha;
if(guideCount >= RECRUIT.RECRUIT_FIRST_RECRUIT) return resResult(STATUS.GACHA_GUIDE_PULL_CNT_LACK); // if(guideCount >= RECRUIT.RECRUIT_FIRST_RECRUIT) return resResult(STATUS.GACHA_GUIDE_PULL_CNT_LACK);
if(guideCount == 0) { // if(guideCount == 0) {
// 消耗东西 // // 消耗东西
let cost = dicGacha.cost.map(cur => { return { id: cur.id, count: cur.count * count } }); // let cost = dicGacha.cost.map(cur => { return { id: cur.id, count: cur.count * count } });
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.GACHA_PULL); // let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.GACHA_PULL);
if (!costResult) return resResult(STATUS.GACHA_COST_NOT_ENOUGH); // if (!costResult) return resResult(STATUS.GACHA_COST_NOT_ENOUGH);
} // }
let userHeroes = await HeroModel.findByRole(roleId); // let userHeroes = await HeroModel.findByRole(roleId);
let gachaPull = new GachaPull(dicGacha, userGacha); // let gachaPull = new GachaPull(dicGacha, userGacha);
let { resultList } = gachaPull.pull(count, userHeroes); // let { resultList } = gachaPull.pull(count, userHeroes);
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { guideResultList: resultList, guideCount: guideCount + 1 }) // userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { guideResultList: resultList, guideCount: guideCount + 1 })
return resResult(STATUS.SUCCESS, { // return resResult(STATUS.SUCCESS, {
guideCount: userGacha.guideCount, // guideCount: userGacha.guideCount,
latest: userGacha.guideResultList // latest: userGacha.guideResultList
}); // });
} }
/** /**
@@ -363,28 +354,28 @@ export class GachaHandler {
* @memberof GachaHandler * @memberof GachaHandler
*/ */
async saveToCandidates(msg: { id: number }, session: BackendSession) { async saveToCandidates(msg: { id: number }, session: BackendSession) {
const { id } = msg; // const { id } = msg;
const roleId: string = session.get('roleId'); // const roleId: string = session.get('roleId');
const gachaId = getGuideGachaId(); // const gachaId = getGuideGachaId();
let userGacha = await UserGachaModel.findByRole(roleId, gachaId); // let userGacha = await UserGachaModel.findByRole(roleId, gachaId);
let { guideResultList, candidates = [], guideCount } = userGacha; // let { guideResultList, candidates = [], guideCount } = userGacha;
let index = candidates.findIndex(cur => cur.id == id); // let index = candidates.findIndex(cur => cur.id == id);
if(index == -1) { // if(index == -1) {
candidates.push({ // candidates.push({
id, guideCount, list: guideResultList // id, guideCount, list: guideResultList
}); // });
} else { // } else {
candidates[index].list = guideResultList; // candidates[index].list = guideResultList;
candidates[index].guideCount = guideCount; // candidates[index].guideCount = guideCount;
} // }
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { candidates }) // userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { candidates })
return resResult(STATUS.SUCCESS, { // return resResult(STATUS.SUCCESS, {
candidates: userGacha.candidates // candidates: userGacha.candidates
}); // });
} }
/** /**
@@ -394,61 +385,61 @@ export class GachaHandler {
* @memberof GachaHandler * @memberof GachaHandler
*/ */
async decide(msg: { id: number }, session: BackendSession) { async decide(msg: { id: number }, session: BackendSession) {
const { id } = msg; // const { id } = msg;
const roleId: string = session.get('roleId'); // const roleId: string = session.get('roleId');
const roleName: string = session.get('roleName'); // const roleName: string = session.get('roleName');
const serverId: number = session.get('serverId'); // const serverId: number = session.get('serverId');
const sid: string = session.get('sid'); // const sid: string = session.get('sid');
const count = 10; // const count = 10;
const gachaId = getGuideGachaId(); // const gachaId = getGuideGachaId();
const dicGacha = gameData.gacha.get(gachaId); // const dicGacha = gameData.gacha.get(gachaId);
let role = await RoleModel.findByRoleId(roleId); // let role = await RoleModel.findByRoleId(roleId);
if(role.gachaHasGuide) { // if(role.gachaHasGuide) {
return resResult(STATUS.GACHA_GUIDE_HAS_DONE); // return resResult(STATUS.GACHA_GUIDE_HAS_DONE);
} // }
let userGacha = await UserGachaModel.findByRole(roleId, gachaId); // let userGacha = await UserGachaModel.findByRole(roleId, gachaId);
let { guideResultList = [], candidates = [], } = userGacha; // let { guideResultList = [], candidates = [], } = userGacha;
let simpleResult: SimpleResult[] = [] // let simpleResult: SimpleResult[] = []
if(id == 0) { // if(id == 0) {
if(guideResultList.length <= 0) { // if(guideResultList.length <= 0) {
return resResult(STATUS.GACHA_GUIDE_NOT_DO); // return resResult(STATUS.GACHA_GUIDE_NOT_DO);
} // }
simpleResult = guideResultList; // simpleResult = guideResultList;
} else { // } else {
let candidate = candidates.find(cur => cur.id == id); // let candidate = candidates.find(cur => cur.id == id);
if(!candidate) return resResult(STATUS.WRONG_PARMS); // if(!candidate) return resResult(STATUS.WRONG_PARMS);
simpleResult = candidate.list; // simpleResult = candidate.list;
} // }
let userHeroes = await HeroModel.findByRole(roleId); // let userHeroes = await HeroModel.findByRole(roleId);
let results = new GachaResults(); // let results = new GachaResults();
results.addBySimpleResult(simpleResult); // results.addBySimpleResult(simpleResult);
let { items, heroInfo, resultList } = results.transferToFinalResult(userHeroes); // let { items, heroInfo, resultList } = results.transferToFinalResult(userHeroes);
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { guideResultCount: count }); // userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { guideResultCount: count });
// 给东西 // // 给东西
// console.log('****', heroInfo) // // console.log('****', heroInfo)
let { heroes, resultHeroes } = await createHeroes(roleId, roleName, sid, serverId, heroInfo); // let { heroes, resultHeroes } = await createHeroes(roleId, roleName, sid, serverId, heroInfo);
await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.GACHA_ITEMS); // await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.GACHA_ITEMS);
// 更新数据 // // 更新数据
role = await RoleModel.updateRoleInfo(roleId, { gachaHasGuide: true }); // role = await RoleModel.updateRoleInfo(roleId, { gachaHasGuide: true });
await UserGachaRecModel.createRec(roleId, gachaId, 0, count, resultList); // await UserGachaRecModel.createRec(roleId, gachaId, 0, count, resultList);
// 任务 // // 任务
if(dicGacha.isTask) await checkTaskInGacha(serverId, roleId, sid, count, resultHeroes, resultList, true); // if(dicGacha.isTask) await checkTaskInGacha(serverId, roleId, sid, count, resultHeroes, resultList, true);
return resResult(STATUS.SUCCESS, { // return resResult(STATUS.SUCCESS, {
hasInit: !!role.gachaHasGuide, // hasInit: !!role.gachaHasGuide,
guideResultCount: userGacha.guideResultCount, // guideResultCount: userGacha.guideResultCount,
count: userGacha.count, // count: userGacha.count,
gachaId, // gachaId,
// heroes: resultHeroes, // // heroes: resultHeroes,
addHeros: heroes, // addHeros: heroes,
result: resultList // result: resultList
}); // });
} }
@@ -43,6 +43,7 @@ import { PopUpShopItemShow } from '../../domain/activityField/popUpShopField';
import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from '../pushService'; import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from '../pushService';
import { UserOrderModelType } from '../../db/UserOrder'; import { UserOrderModelType } from '../../db/UserOrder';
import { isArray } from 'underscore'; import { isArray } from 'underscore';
import { getGuideGachaData } from './guideGachaService';
/** /**
* 获取活动数据 * 获取活动数据
@@ -212,7 +213,15 @@ export async function getActivity(serverId: number, roleId: string, guildCode: s
case ACTIVITY_TYPE.GUILD_PAY: case ACTIVITY_TYPE.GUILD_PAY:
{ {
activityData = await getGuildPayDataShow(serverId, activityId, roleId, guildCode); activityData = await getGuildPayDataShow(serverId, activityId, roleId, guildCode);
break
} }
case ACTIVITY_TYPE.GUIDE_GACHA:
{
activityData = await getGuideGachaData(serverId, activityId, roleId);
break
}
case ACTIVITY_TYPE.SHOP:
break
default: { default: {
console.log('未知活动类型.........', activityType) console.log('未知活动类型.........', activityType)
break; break;
@@ -1,6 +1,6 @@
import { GachaData, Floor as UserFloor, Hope as UserHope, GachaListReturn, GachaResultIndb } from "../../domain/activityField/gachaField";; import { Floor as UserFloor, Hope as UserHope, GachaListReturn, GachaResultIndb } from "../../domain/activityField/gachaField";;
import { DicGacha } from "../../pubUtils/dictionary/DicGacha"; import { DicGacha } from "../../pubUtils/dictionary/DicGacha";
import { UserGachaType, UserGachaModel, SimpleResult } from "../../db/UserGacha"; import { UserGachaType, UserGachaModel } from "../../db/UserGacha";
import { shouldRefresh, getRandEelm, getRandEelmWithWeight, getRandSingleIndex, getRandSingleEelm } from "../../pubUtils/util"; import { shouldRefresh, getRandEelm, getRandEelmWithWeight, getRandSingleIndex, getRandSingleEelm } from "../../pubUtils/util";
import { REFRESH_TIME, GACHA_FLOOR_TYPE, HERO_QUALITY_TYPE, IT_TYPE, ITID, CONSUME_TYPE, SPECIAL_ATTR, TIME_OUTPUT_TYPE, GACHA_TYPE, GACHA_PLAN_TYPE } from "../../consts"; import { REFRESH_TIME, GACHA_FLOOR_TYPE, HERO_QUALITY_TYPE, IT_TYPE, ITID, CONSUME_TYPE, SPECIAL_ATTR, TIME_OUTPUT_TYPE, GACHA_TYPE, GACHA_PLAN_TYPE } from "../../consts";
import { getTimeFunD, getZeroPointD } from "../../pubUtils/timeUtil"; import { getTimeFunD, getZeroPointD } from "../../pubUtils/timeUtil";
@@ -11,6 +11,7 @@ import { HeroType } from "../../db/Hero";
import { getActivityById } from "./activityService"; import { getActivityById } from "./activityService";
import { transPiece } from "../role/util"; import { transPiece } from "../role/util";
import { getRoleCreateTime, getServerCreateTime } from "../redisService"; import { getRoleCreateTime, getServerCreateTime } from "../redisService";
import { SimpleResult } from "../../domain/activityField/guideGachaField";
/** /**
* 获取招募列表 * 获取招募列表
@@ -31,26 +32,6 @@ export async function getGachaList(roleId: string) {
return list; return list;
} }
/**
* 获取活动页签里的限时卡池
*
* @param roleId 玩家id
* @param aid 活动id
*/
export async function getLimitGacha(serverId: number, roleId: string, activityId: number) {
let activityData = await getActivityById(activityId);
if (!activityData) return false;
let createTime = await getRoleCreateTime(roleId);
let serverTime = await getServerCreateTime(serverId);
let gachaData = new GachaData(activityData, createTime, serverTime);
let userGacha = await UserGachaModel.findByRole(roleId, gachaData.gachaId, activityId);
userGacha = await refreshGacha(gameData.gacha.get(gachaData.gachaId), userGacha);
gachaData.setUserGacha(userGacha);
return gachaData
}
export function getGuideGachaId() { export function getGuideGachaId() {
let ids = gameData.gachaByType.get(GACHA_TYPE.GUIDE); let ids = gameData.gachaByType.get(GACHA_TYPE.GUIDE);
return ids[0]; return ids[0];
@@ -0,0 +1,15 @@
import { UserGachaModel } from "../../db/UserGacha";
import { GuideGachaData } from "../../domain/activityField/guideGachaField";
import { getRoleCreateTime, getServerCreateTime } from "../redisService";
import { getActivityById } from "./activityService";
export async function getGuideGachaData(serverId: number, activityId: number, roleId: string) {
let activityData = await getActivityById(activityId);
let createTime = await getRoleCreateTime(roleId);
let serverTime = await getServerCreateTime(serverId);
let playerData = new GuideGachaData(activityData, createTime, serverTime);
let userGacha = await UserGachaModel.findByRole(roleId, playerData.gachaId, activityId);
playerData.setPlayerData(userGacha);
if(playerData.hasChoosen) return null
return playerData;
}
+2 -1
View File
@@ -645,7 +645,8 @@ export function checkRouteParam(route: string, msg: any) {
if(!checkNaturalArray(heroes)) return false; if(!checkNaturalArray(heroes)) return false;
if (heroes.length > LINEUP_NUM) return false; if (heroes.length > LINEUP_NUM) return false;
for(let { actorId, order } of heroes) { for(let { actorId, order } of heroes) {
if(!checkNaturalNumbers(actorId, order)) return false; if(!checkNaturalNumbers(actorId)) return false;
if(!checkNumberIfExist(order)) return false;
} }
break; break;
} }
+1 -2
View File
@@ -156,10 +156,9 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
case 'pvp': // pvp case 'pvp': // pvp
return await getPvpEntryData(roleId); return await getPvpEntryData(roleId);
case 'gacha': case 'gacha':
const { gachaHasGuide } = role;
const gachalist = await getGachaList(roleId); const gachalist = await getGachaList(roleId);
const visitList = await getVisitedHeroList(roleId); const visitList = await getVisitedHeroList(roleId);
return { hasInit: !!gachaHasGuide, gachalist, visitList } return { hasInit: true, gachalist, visitList }
case 'school': case 'school':
return await getSchoolList(roleId); return await getSchoolList(roleId);
case 'guild': case 'guild':
@@ -57,6 +57,7 @@ export enum ACTIVITY_TYPE {
TASK_PASS = 42, // 战令活动 TASK_PASS = 42, // 战令活动
GUILD_PAY = 43, // 军团充值人数 GUILD_PAY = 43, // 军团充值人数
SHOP = 44, // 限时商店 SHOP = 44, // 限时商店
GUIDE_GACHA = 45, // 500抽
} }
/** /**
@@ -218,3 +219,8 @@ export enum DAILY_COIN_BOX_STATUS {
CAN_OPEN = 1, // 可以打开 CAN_OPEN = 1, // 可以打开
RECEIVED = 2, // 已领取 RECEIVED = 2, // 已领取
} }
export enum GUIDE_GACHA_STAGE {
PULL = 1, // 抽卡阶段
DECIDE = 2, // 决定阶段
}
+4 -28
View File
@@ -2,6 +2,7 @@ import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
import { getZeroPointD } from '../pubUtils/timeUtil'; import { getZeroPointD } from '../pubUtils/timeUtil';
import { RECRUIT } from '../pubUtils/dicParam'; import { RECRUIT } from '../pubUtils/dicParam';
import { Candidate, SimpleResult } from '../domain/activityField/guideGachaField';
export class Floor { export class Floor {
@prop({ required: true }) @prop({ required: true })
@@ -36,28 +37,6 @@ class Turntable {
hasGet: boolean; // 是否得到 hasGet: boolean; // 是否得到
} }
export class SimpleResult {
@prop({ required: true })
planId: number;
@prop({ required: true })
hid: number;
@prop({ required: true })
isTransfer: boolean;
}
/**
* @description 特殊引导候选列表
* @memberof UserGacha
*/
class Candidate {
@prop({ required: true })
id: number; // 列表id
@prop({ required: true })
guideCount: number; // 引导次数
@prop({ required: true, type: SimpleResult, _id: false })
list: SimpleResult[]; // 是否得到
}
/** /**
* 玩家抽卡表 * 玩家抽卡表
**/ **/
@@ -115,15 +94,12 @@ export default class UserGacha extends BaseModel {
// 初始特殊引导 // 初始特殊引导
@prop({ required: true, default: 0 }) @prop({ required: true, default: 0 })
guideCount: number; // 预抽卡次数 pullCnt: number; // 预抽卡次数
@prop({ required: true, default: 0 }) @prop({ required: true, type: () => SimpleResult, default: [], _id: false })
guideResultCount: number; // 预抽卡次数
@prop({ required: true, type: SimpleResult, default: [], _id: false })
guideResultList: SimpleResult[]; // 预抽卡结果 guideResultList: SimpleResult[]; // 预抽卡结果
@prop({ required: true, type: Candidate, default: [], _id: false }) @prop({ required: true, type: () => Candidate, default: [], _id: false })
candidates: Candidate[]; // 预抽卡候选 candidates: Candidate[]; // 预抽卡候选
public static async findAllByRole(roleId: string) { public static async findAllByRole(roleId: string) {
-40
View File
@@ -1,47 +1,9 @@
import { ActivityModelType } from '../../db/Activity';
import { ActivityBase } from './activityField';
import { prop } from '@typegoose/typegoose'; import { prop } from '@typegoose/typegoose';
import { UserGachaType } from '../../db/UserGacha'; import { UserGachaType } from '../../db/UserGacha';
import { getTimeFun } from '../../pubUtils/timeUtil'; import { getTimeFun } from '../../pubUtils/timeUtil';
import { DicGacha } from '../../pubUtils/dictionary/DicGacha'; import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
import { gameData } from '../../pubUtils/data';
import { getGachaRemainFloor } from '../../pubUtils/util'; import { getGachaRemainFloor } from '../../pubUtils/util';
// 抽卡数据
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) {
let f = getTimeFun(userGacha.refFreeTime);
this.refFreeTime = <number>f.getAfterDayWithHour(dicGacha.free.day);
}
this.count = userGacha.count;
this.floor = userGacha.floor;
}
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
super(activityData, createTime, serverTime)
}
}
/** /**
* @description 保底记录 * @description 保底记录
* @memberof UserGacha * @memberof UserGacha
@@ -88,7 +50,6 @@ export class GachaListReturn {
freeCount: number = 0; // 免费次数 freeCount: number = 0; // 免费次数
refFreeTime: number = 0; // 免费次数下次刷新时间 refFreeTime: number = 0; // 免费次数下次刷新时间
count: number = 0; // 整体已抽卡次数 count: number = 0; // 整体已抽卡次数
guideResultCount: number = 0; // 引导已抽卡次数
remainFloor: number = 0; // 还剩多少次可以保底 remainFloor: number = 0; // 还剩多少次可以保底
hope: Hope[] = []; // 心愿单 hope: Hope[] = []; // 心愿单
point: number = 0; // 积分 point: number = 0; // 积分
@@ -110,7 +71,6 @@ export class GachaListReturn {
this.point = userGacha.point; this.point = userGacha.point;
this.turntable = userGacha.turntable; this.turntable = userGacha.turntable;
this.pickHero = userGacha.pickHero; this.pickHero = userGacha.pickHero;
this.guideResultCount = userGacha.guideResultCount||0;
} }
this.remainFloor = getGachaRemainFloor(this.gachaId, userGacha?.floor||[]); this.remainFloor = getGachaRemainFloor(this.gachaId, userGacha?.floor||[]);
} }
@@ -0,0 +1,67 @@
import { ActivityModelType } from '../../db/Activity';
import { ActivityBase } from './activityField';
import { prop } from '@typegoose/typegoose';
import { getTimeFunM } from '../../pubUtils/timeUtil';
import { UserGachaType } from '../../db/UserGacha';
import { GUIDE_GACHA_STAGE } from '../../consts';
export class SimpleResult {
@prop({ required: true })
planId: number;
@prop({ required: true })
hid: number;
@prop({ required: true })
isTransfer: boolean;
}
/**
* @description 特殊引导候选列表
* @memberof UserGacha
*/
export class Candidate {
@prop({ required: true })
id: number; // 列表id
@prop({ required: true })
isChosen: boolean; // 是否被选中
@prop({ required: true })
pullCnt: number; // 引导第几次保存的
@prop({ required: true, type: () => SimpleResult, _id: false })
list: SimpleResult[]; // 列表
}
interface GuideGachaDataInDb {
gachaId: number; // 抽卡卡池id
chooseTime: number; // 开始后几天内可以选卡
}
// 抽卡数据
export class GuideGachaData extends ActivityBase {
gachaId: number = 0;
stage: GUIDE_GACHA_STAGE = GUIDE_GACHA_STAGE.PULL;
chooseTime: number = 0;
pullCnt: number = 0;
hasChoosen: boolean = false;
candidates: Candidate[] = [];
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
super(activityData, createTime, serverTime);
this.initData(activityData.data);
}
public initData(data: string) {
let obj: GuideGachaDataInDb = JSON.parse(data);
this.gachaId = obj.gachaId;
this.chooseTime = <number>getTimeFunM(this.beginTime).getAfterDayWithHour(obj.chooseTime);
this.stage = Date.now() < this.chooseTime? GUIDE_GACHA_STAGE.PULL: GUIDE_GACHA_STAGE.DECIDE;
}
public setPlayerData(userGacha: UserGachaType) {
if(userGacha) {
this.pullCnt = userGacha.pullCnt;
this.candidates = userGacha.candidates;
this.hasChoosen = userGacha.candidates.findIndex(cur => cur.isChosen) != -1;
}
}
}