抽卡:免费抽卡次数
This commit is contained in:
@@ -93,12 +93,14 @@ export class GachaHandler {
|
||||
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, activityId, {
|
||||
freeCount, hope, floor, count: historyCount + count
|
||||
});
|
||||
let newDicGacha = getDicGachaByGachaCnt(dicGacha, userGacha.count);
|
||||
|
||||
await UserGachaRecModel.createRec(roleId, gachaId, activityId, count, resultList);
|
||||
if(dicGacha.isTask) await checkTaskInGacha(serverId, roleId, sid, count, resultHeroes, resultList, false);
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
gachaId, activityId,
|
||||
freeCount, refFreeTime: userGacha.refFreeTime, count: userGacha.count, point: userGacha.point, floor, hope,
|
||||
isFree: freeCount < newDicGacha.free.count, cost: newDicGacha.cost,
|
||||
count: userGacha.count, point: userGacha.point, floor, hope,
|
||||
// heroes: resultHeroes,
|
||||
addHeros: heroes,
|
||||
result: resultList,
|
||||
|
||||
@@ -275,7 +275,7 @@ export class NormalBattleHandler {
|
||||
pushVestigeFirstMsg(roleId, roleName, serverId, warInfo.warType, warInfo.war_id);
|
||||
}
|
||||
// 是否首次3星
|
||||
if (newStar == 3 && (!isFirst || curWarStar.star != 3)) {
|
||||
if (newStar == 3 && (isFirst || curWarStar.star != 3)) {
|
||||
warReward.setCondition(1, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ export async function getGachaList(roleId: string) {
|
||||
let userGacha = userGachaList.find(cur => cur.gachaId == id);
|
||||
if (userGacha)
|
||||
userGacha = await refreshGacha(dicGacha, userGacha);
|
||||
dicGacha = getDicGachaByGachaCnt(dicGacha, userGacha?.count||0);
|
||||
|
||||
let param = new GachaListReturn(dicGacha, userGacha);
|
||||
list.push(param);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { ACTIVITY_TYPE } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityNewHeroGiftModel, ActivityNewHeroGiftModelType } from '../../db/ActivityNewHeroGift';
|
||||
import { ActivityNewHeroGKModel, ActivityNewHeroGKModelType } from '../../db/ActivityNewHeroGK';
|
||||
import { RoleModel } from '../../db/Role';
|
||||
import { ServerlistModel } from '../../db/Serverlist';
|
||||
import { UserGachaModel, UserGachaType } from '../../db/UserGacha';
|
||||
import { NewHeroGachaData } from '../../domain/activityField/newHeroGachaField';
|
||||
import { NewHeroGiftData } from '../../domain/activityField/newHeroGiftField';
|
||||
import { NewHeroGKData } from '../../domain/activityField/newHeroGKField';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
import { getRoleCreateTime, getServerCreateTime } from '../redisService';
|
||||
import { getActivitiesByType, getActivityById } from './activityService';
|
||||
import { getActivityById } from './activityService';
|
||||
import { refreshGacha } from './gachaService';
|
||||
|
||||
|
||||
|
||||
@@ -26,9 +24,10 @@ import { getActivitiesByType, getActivityById } from './activityService';
|
||||
let createTime = await getRoleCreateTime(roleId);
|
||||
let serverTime = await getServerCreateTime(serverId);
|
||||
let playerData = new NewHeroGachaData(activityData, createTime, serverTime);
|
||||
let playerRecord: UserGachaType = await UserGachaModel.findByRole(roleId, playerData.gachaId);
|
||||
|
||||
playerData.setPlayerRecords(playerRecord);
|
||||
let userGacha: UserGachaType = await UserGachaModel.findByRole(roleId, playerData.gachaId);
|
||||
let dicGacha = gameData.gacha.get(playerData.gachaId);
|
||||
userGacha = await refreshGacha(dicGacha, userGacha);
|
||||
playerData.setPlayerRecords(userGacha, dicGacha);
|
||||
|
||||
return playerData;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { UserGachaType } from '../../db/UserGacha';
|
||||
import { getTimeFun } from '../../pubUtils/timeUtil';
|
||||
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
|
||||
import { getGachaRemainFloor } from '../../pubUtils/util';
|
||||
import { RewardInter } from '../../pubUtils/interface';
|
||||
|
||||
/**
|
||||
* @description 保底记录
|
||||
@@ -47,8 +48,8 @@ export class Turntable {
|
||||
export class GachaListReturn {
|
||||
gachaId: number; // dicGacha里的id
|
||||
gachaType: number;
|
||||
freeCount: number = 0; // 免费次数
|
||||
refFreeTime: number = 0; // 免费次数下次刷新时间
|
||||
isFree: boolean = false; // 免费次数
|
||||
cost: RewardInter[] = []; // 消耗
|
||||
count: number = 0; // 整体已抽卡次数
|
||||
remainFloor: number = 0; // 还剩多少次可以保底
|
||||
hope: Hope[] = []; // 心愿单
|
||||
@@ -59,13 +60,10 @@ export class GachaListReturn {
|
||||
constructor(dicGacha: DicGacha, userGacha: UserGachaType) {
|
||||
this.gachaId = dicGacha.id;
|
||||
this.gachaType = dicGacha.gachaType;
|
||||
this.cost = dicGacha.cost;
|
||||
|
||||
if (userGacha) {
|
||||
this.freeCount = userGacha.freeCount;
|
||||
if (dicGacha.free.count > 0) {
|
||||
let f = getTimeFun(userGacha.refFreeTime);
|
||||
this.refFreeTime = <number>f.getAfterDayWithHour(dicGacha.free.day);
|
||||
}
|
||||
this.isFree = userGacha.freeCount < dicGacha.free.count;
|
||||
this.count = userGacha.count;
|
||||
this.hope = userGacha.hope;
|
||||
this.point = userGacha.point;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { UserGachaType } from '../../db/UserGacha';
|
||||
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
|
||||
import { RewardInter } from '../../pubUtils/interface';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
interface NewHeroGachaItemInDb {
|
||||
@@ -24,7 +26,8 @@ export class NewHeroGachaData extends ActivityBase {
|
||||
uiType: number;
|
||||
pickHero: number = 0;
|
||||
count: number = 0;
|
||||
freeCount: number = 0;
|
||||
isFree: boolean = false; // 免费次数
|
||||
cost: RewardInter[] = []; // 消耗
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
@@ -45,11 +48,13 @@ export class NewHeroGachaData extends ActivityBase {
|
||||
}
|
||||
|
||||
//解析玩家记录
|
||||
public setPlayerRecords(data: UserGachaType) {
|
||||
if (!data) return;
|
||||
this.pickHero = data.pickHero;
|
||||
this.count = data.count;
|
||||
this.freeCount = data.freeCount;
|
||||
public setPlayerRecords(data: UserGachaType, dic: DicGacha) {
|
||||
if(dic) this.cost = dic.cost;
|
||||
if (data) {
|
||||
this.pickHero = data.pickHero;
|
||||
this.count = data.count;
|
||||
this.isFree = data.freeCount < dic?.free.count;
|
||||
}
|
||||
}
|
||||
|
||||
public isPickHero(hid: number) {
|
||||
|
||||
@@ -798,10 +798,8 @@ export function getGachaRemainFloor(gachaId: number, userFloor: Floor[]) {
|
||||
|
||||
for(let floorId of dicGacha.floor) {
|
||||
let dicGachaFloor = gameData.gachaFloor.get(floorId);
|
||||
console.log('##### floorId', floorId, dicGachaFloor)
|
||||
if(dicGachaFloor && dicGachaFloor.floorType == GACHA_FLOOR_TYPE.MAIN_FLOOR) {
|
||||
let myFloor = userFloor.find(cur => cur.id == floorId);
|
||||
console.log('#### dicGacha#', gachaId, dicGachaFloor.param, (myFloor?.count||0))
|
||||
|
||||
return dicGachaFloor.param - (myFloor?.count||0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user