抽卡:500抽逻辑完成

This commit is contained in:
luying
2022-07-29 16:17:41 +08:00
parent 40af0edc28
commit 1ad6163bb5
11 changed files with 196 additions and 126 deletions
@@ -43,7 +43,7 @@ import { PopUpShopItemShow } from '../../domain/activityField/popUpShopField';
import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from '../pushService';
import { UserOrderModelType } from '../../db/UserOrder';
import { isArray } from 'underscore';
import { getGuideGachaData } from './guideGachaService';
import { getGuideGachaData } from './gachaService';
/**
* 获取活动数据
@@ -11,7 +11,7 @@ import { HeroType } from "../../db/Hero";
import { getActivityById } from "./activityService";
import { transPiece } from "../role/util";
import { getRoleCreateTime, getServerCreateTime } from "../redisService";
import { SimpleResult } from "../../domain/activityField/guideGachaField";
import { SimpleResult, GuideGachaData } from "../../domain/activityField/guideGachaField";
/**
* 获取招募列表
@@ -32,11 +32,6 @@ export async function getGachaList(roleId: string) {
return list;
}
export function getGuideGachaId() {
let ids = gameData.gachaByType.get(GACHA_TYPE.GUIDE);
return ids[0];
}
export function getNormalGachaId() {
let ids = gameData.gachaByType.get(GACHA_TYPE.NORMAL);
return ids.find(gachaId => gameData.gacha.get(gachaId)?.showInMainPage == 1);
@@ -351,7 +346,7 @@ export class GachaPull {
// 结果
private result = new GachaResults();
constructor(dicGacha: DicGacha, userGacha: UserGachaType) {
constructor(dicGacha: DicGacha, userGacha?: UserGachaType) {
this.gachaType = dicGacha.gachaType;
this.percent = new GachaPercent(dicGacha.percent);
this.player = new PlayerGachaRecord(userGacha);
@@ -529,4 +524,16 @@ export function getDicGachaByGachaCnt(dicGacha: DicGacha, historyCount: number)
function isGachaCntIn(historyCount: number, min: number, max: number) {
let nowCnt = historyCount + 1;
return min <= nowCnt && (max >= nowCnt || max == -1);
}
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;
}
@@ -1,15 +0,0 @@
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;
}