🐞 fix(抽卡): 首次十连必出ssr
This commit is contained in:
@@ -82,12 +82,10 @@ class PlayerGachaRecord {
|
||||
public floor: UserFloor[] = [];
|
||||
public pickHero: number = 0;
|
||||
|
||||
constructor(userGacha: UserGachaType ) {
|
||||
if(userGacha) {
|
||||
this.floor = userGacha.floor;
|
||||
this.hope = userGacha.hope;
|
||||
this.pickHero = userGacha.pickHero;
|
||||
}
|
||||
public setUserGacha(floor: UserFloor[], hope: UserHope[], pickHero: number ) {
|
||||
this.floor = floor;
|
||||
this.hope = hope;
|
||||
this.pickHero = pickHero;
|
||||
}
|
||||
|
||||
public getFloorCountById(id: number) {
|
||||
@@ -363,14 +361,15 @@ export class GachaPull {
|
||||
private floors: GachaFloor[] = []; // 保底次数
|
||||
private percent: GachaPercent;
|
||||
// 玩家数据
|
||||
private player: PlayerGachaRecord;
|
||||
private player: PlayerGachaRecord = new PlayerGachaRecord();
|
||||
// 结果
|
||||
private result = new GachaResults();
|
||||
|
||||
constructor(dicGacha: DicGacha, userGacha?: UserGachaType) {
|
||||
constructor(dicGacha: DicGacha, userGacha?: { floor: UserFloor[], hope: UserHope[], pickHero: number }) {
|
||||
this.gachaType = dicGacha.gachaType;
|
||||
this.percent = new GachaPercent(dicGacha.percent);
|
||||
this.player = new PlayerGachaRecord(userGacha);
|
||||
if(userGacha)
|
||||
this.player.setUserGacha(userGacha.floor, userGacha.hope, userGacha.pickHero);
|
||||
for(let id of dicGacha.floor) {
|
||||
let floor = new GachaFloor(id);
|
||||
if(floor && floor.id) this.floors.push(floor);
|
||||
@@ -543,6 +542,20 @@ export function getDicGachaByGachaCnt(dicGacha: DicGacha, historyCount: number)
|
||||
return null
|
||||
}
|
||||
|
||||
export function getDicGachas(gachaType: number, historyCount: number, count: number) {
|
||||
let dics: { dic: DicGacha, min: number, max: number }[] = [];
|
||||
let gachaIds = gameData.gachaByType.get(gachaType);
|
||||
for(let gachaId of gachaIds) {
|
||||
let dicGacha = gameData.gacha.get(gachaId);
|
||||
if(!dicGacha || (dicGacha.gachaCnt.min > dicGacha.gachaCnt.max && dicGacha.gachaCnt.max != -1)) continue;
|
||||
if((dicGacha.gachaCnt.max != -1 && dicGacha.gachaCnt.max <= historyCount) || dicGacha.gachaCnt.min > historyCount + count) continue; // dic的范围不包含
|
||||
let min = dicGacha.gachaCnt.min > historyCount + 1? dicGacha.gachaCnt.min: historyCount + 1;
|
||||
let max = (dicGacha.gachaCnt.max == -1 || dicGacha.gachaCnt.max > historyCount + count)? historyCount + count: dicGacha.gachaCnt.max;
|
||||
dics.push({ dic: dicGacha, min, max });
|
||||
}
|
||||
return dics.sort((a, b) => a.min - b.min);
|
||||
}
|
||||
|
||||
function isGachaCntIn(historyCount: number, min: number, max: number) {
|
||||
let nowCnt = historyCount + 1;
|
||||
return min <= nowCnt && (max >= nowCnt || max == -1);
|
||||
|
||||
Reference in New Issue
Block a user