From e1e9da4a80480f9e45d321bd6ce7eade75a3ecc3 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 3 Aug 2022 11:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=EF=BC=9A=E5=85=8D=E8=B4=B9?= =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../servers/activity/handler/gachaHandler.ts | 4 +++- .../battle/handler/normalBattleHandler.ts | 2 +- .../app/services/activity/gachaService.ts | 2 ++ .../app/services/activity/newHeroService.ts | 15 +++++++-------- shared/domain/activityField/gachaField.ts | 12 +++++------- .../domain/activityField/newHeroGachaField.ts | 17 +++++++++++------ shared/pubUtils/util.ts | 2 -- 7 files changed, 29 insertions(+), 25 deletions(-) diff --git a/game-server/app/servers/activity/handler/gachaHandler.ts b/game-server/app/servers/activity/handler/gachaHandler.ts index 7df4f6270..f373ef03e 100644 --- a/game-server/app/servers/activity/handler/gachaHandler.ts +++ b/game-server/app/servers/activity/handler/gachaHandler.ts @@ -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, diff --git a/game-server/app/servers/battle/handler/normalBattleHandler.ts b/game-server/app/servers/battle/handler/normalBattleHandler.ts index 8258eaee5..6d67afcae 100644 --- a/game-server/app/servers/battle/handler/normalBattleHandler.ts +++ b/game-server/app/servers/battle/handler/normalBattleHandler.ts @@ -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); } diff --git a/game-server/app/services/activity/gachaService.ts b/game-server/app/services/activity/gachaService.ts index 2be0a7708..7d128e6ee 100644 --- a/game-server/app/services/activity/gachaService.ts +++ b/game-server/app/services/activity/gachaService.ts @@ -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); } diff --git a/game-server/app/services/activity/newHeroService.ts b/game-server/app/services/activity/newHeroService.ts index ff5c3edbc..cee7d7f8d 100644 --- a/game-server/app/services/activity/newHeroService.ts +++ b/game-server/app/services/activity/newHeroService.ts @@ -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; } diff --git a/shared/domain/activityField/gachaField.ts b/shared/domain/activityField/gachaField.ts index 1cb1903cc..e5a44043f 100644 --- a/shared/domain/activityField/gachaField.ts +++ b/shared/domain/activityField/gachaField.ts @@ -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 = f.getAfterDayWithHour(dicGacha.free.day); - } + this.isFree = userGacha.freeCount < dicGacha.free.count; this.count = userGacha.count; this.hope = userGacha.hope; this.point = userGacha.point; diff --git a/shared/domain/activityField/newHeroGachaField.ts b/shared/domain/activityField/newHeroGachaField.ts index 829e85f7c..b82441559 100644 --- a/shared/domain/activityField/newHeroGachaField.ts +++ b/shared/domain/activityField/newHeroGachaField.ts @@ -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) { diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index b3a4abc1c..fb20c1b54 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -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); }