抽卡:修复新人卡池特殊处理问题
This commit is contained in:
@@ -56,15 +56,14 @@ export class GachaHandler {
|
||||
|
||||
let dicGacha = gameData.gacha.get(gachaId);
|
||||
if (!dicGacha) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicGacha.count.includes(count)) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, activityId);
|
||||
userGacha = await refreshGacha(dicGacha, userGacha);
|
||||
let { freeCount, point, pickHero, refFreeTime, count: historyCount } = userGacha;
|
||||
if ((gachaId == GACHA_TYPE.ASSIGN || gachaId == GACHA_TYPE.ACTIVITY) && !pickHero) return resResult(STATUS.GACHA_NOT_ASSIGN);
|
||||
if ((dicGacha.gachaType == GACHA_TYPE.ASSIGN || dicGacha.gachaType == GACHA_TYPE.ACTIVITY) && !pickHero) return resResult(STATUS.GACHA_NOT_ASSIGN);
|
||||
|
||||
dicGacha = getDicGachaByGachaCnt(dicGacha, historyCount);
|
||||
if (!dicGacha) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicGacha.count.includes(count)) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let gachaPull = new GachaPull(dicGacha, userGacha);
|
||||
let userHeroes = await HeroModel.findByRole(roleId);
|
||||
@@ -469,4 +468,60 @@ export class GachaHandler {
|
||||
result: resultList
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async test(msg: { gachaId: number, count: number, isGuide: boolean }, session: BackendSession) {
|
||||
const { gachaId, count, isGuide } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const sid: string = session.get('sid');
|
||||
const dicGacha = gameData.gacha.get(gachaId);
|
||||
console.log(`====== map of content ${gachaId} ====== start`)
|
||||
|
||||
let mapOfContent = new Map<number, number>();
|
||||
|
||||
let hope = [];
|
||||
let floor = [];
|
||||
|
||||
let n = Math.ceil(count/10/200);
|
||||
let sum = 0;
|
||||
|
||||
function cal(num: number) {
|
||||
for(let i = 0; i < 200; i++) {
|
||||
console.log(num, i)
|
||||
let gachaPull = new GachaPull(dicGacha, { ...new UserGachaModel().toJSON(), floor, hope, pickHero: 1 });
|
||||
let { resultList } = gachaPull.pull(10, []);
|
||||
let { hope: _hope, floor: _floor } = gachaPull.getUserGachaParam();
|
||||
floor = _floor;
|
||||
hope = _hope;
|
||||
|
||||
gachaPull = undefined;
|
||||
|
||||
for(let { planId } of resultList ) {
|
||||
if(!mapOfContent.has(planId)) {
|
||||
mapOfContent.set(planId, 1);
|
||||
} else {
|
||||
mapOfContent.set(planId, mapOfContent.get(planId) + 1);
|
||||
}
|
||||
sum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let num = 0;
|
||||
cal(num);
|
||||
let interval = setInterval(() => {
|
||||
if (++num < n) {
|
||||
cal(num);
|
||||
} else {
|
||||
console.log(`====== map of content ${gachaId} sum: ${sum} ======`)
|
||||
console.log('planId \t count')
|
||||
for(let [ planId, count ] of mapOfContent) {
|
||||
console.log(`${planId} \t ${count}`);
|
||||
}
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 50)
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ export function getGuideGachaId() {
|
||||
|
||||
export function getNormalGachaId() {
|
||||
let ids = gameData.gachaByType.get(GACHA_TYPE.NORMAL);
|
||||
return ids[0];
|
||||
return ids.find(gachaId => gameData.gacha.get(gachaId)?.showInMainPage == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,8 +88,8 @@ export async function refreshGacha(dicGacha: DicGacha, userGacha: UserGachaType)
|
||||
|
||||
|
||||
export async function getVisitedHeroList(roleId: string) {
|
||||
|
||||
let { visitedHero, refVisitedTime } = await UserGachaModel.findByRole(roleId, GACHA_TYPE.NORMAL, 0);
|
||||
let gachaId = getNormalGachaId();
|
||||
let { visitedHero, refVisitedTime } = await UserGachaModel.findByRole(roleId, gachaId, 0);
|
||||
if (shouldRefresh(refVisitedTime, new Date())) {
|
||||
visitedHero = [];
|
||||
}
|
||||
@@ -537,9 +537,9 @@ export function getDicGachaByGachaCnt(dicGacha: DicGacha, historyCount: number)
|
||||
}
|
||||
let gachaIds = gameData.gachaByType.get(dicGacha.gachaType);
|
||||
for(let gachaId of gachaIds) {
|
||||
let dicGacha = gameData.gacha.get(gachaId);
|
||||
if(isGachaCntIn(historyCount, dicGacha.gachaCnt.min, dicGacha.gachaCnt.max)) {
|
||||
return dicGacha;
|
||||
let newDicGacha = gameData.gacha.get(gachaId);
|
||||
if(isGachaCntIn(historyCount, newDicGacha.gachaCnt.min, newDicGacha.gachaCnt.max)) {
|
||||
return {...newDicGacha, id: dicGacha.id};
|
||||
}
|
||||
}
|
||||
return null
|
||||
|
||||
@@ -111,8 +111,8 @@ export class GachaListReturn {
|
||||
this.turntable = userGacha.turntable;
|
||||
this.pickHero = userGacha.pickHero;
|
||||
this.guideResultCount = userGacha.guideResultCount||0;
|
||||
this.remainFloor = getGachaRemainFloor(this.gachaId, userGacha.floor);
|
||||
}
|
||||
this.remainFloor = getGachaRemainFloor(this.gachaId, userGacha?.floor||[]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -807,8 +807,11 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"gachaType": 1,
|
||||
"floor": "&",
|
||||
"name": "新手招募1",
|
||||
"count": "1&10",
|
||||
"count": "1&",
|
||||
"free": "&",
|
||||
"cost": "22001&1",
|
||||
"percent": "16&100",
|
||||
@@ -19,7 +19,7 @@
|
||||
"gachaType": 1,
|
||||
"floor": "&",
|
||||
"name": "新手招募2",
|
||||
"count": "1&10",
|
||||
"count": "1&",
|
||||
"free": "&",
|
||||
"cost": "22001&1",
|
||||
"percent": "17&100",
|
||||
|
||||
Reference in New Issue
Block a user