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