测试:修改测试bug

This commit is contained in:
qiaoxin
2021-07-08 21:20:19 +08:00
parent 9d52053ba0
commit 876b0ee600
8 changed files with 401 additions and 294 deletions
@@ -109,10 +109,12 @@ export class GachaPull {
constructor(gachaType: GACHA_ID, lv: number, userHeroes: HeroType[]) {
this.gachaType = gachaType;
if(gachaType == GACHA_ID.NORMAL) { // 元宝招募,金色武将保底,按次数给保底,抽到就重新计算次数,单抽也算
this.dicFloorType = GACHA_FLOOR_TYPE.GOLD;
if (gachaType == GACHA_ID.NORMAL) { // 元宝招募,金色武将保底,按次数给保底,抽到就重新计算次数,单抽也算
this.dicFloorType = GACHA_FLOOR_TYPE.GOLD;
} else if (gachaType == GACHA_ID.ASSIGN || gachaType == GACHA_ID.TIMELIMIT) { // 求贤若渴,和活动抽卡金色保底,伪随机,n次内给且只给一个,单抽也算
this.dicFloorType = GACHA_FLOOR_TYPE.ASSIGN;
} else {
this.dicFloorType = GACHA_FLOOR_TYPE.GOLD;
}
this.userHeroes = userHeroes;
this.lv = lv;
@@ -124,23 +126,23 @@ export class GachaPull {
let percent = dicGacha.percent;
// 设置pickup的武将
let newPercent = [];
for(let { id, weight } of percent) {
if(id == gameData.gachaContentHero.get(0)) {
for (let { id, weight } of percent) {
if (id == gameData.gachaContentHero.get(0)) {
newPercent.push({ id, weight, goodId: userGacha.pickHero })
} else {
newPercent.push({ id, weight });
}
}
this.percent = newPercent;
if(dicGacha.floorReward > 0) {
if (dicGacha.floorReward > 0) {
this.dicFloor = this.percent[dicGacha.floorReward - 1];
}
this.dicFloorCount = getDicGachaFloor(this.dicFloorType);
// 玩家数据
let userFloor = userGacha.floor.find(cur => cur.id == this.dicFloorType);
if(userFloor) {
if (userFloor) {
this.floorCount = userFloor.count;
this.hasGetFloor = userFloor.hasGetFloor||false;
this.hasGetFloor = userFloor.hasGetFloor || false;
}
this.hope = userGacha.hope;
}
@@ -150,27 +152,27 @@ export class GachaPull {
this.hasGetFloor = item.hasGetFloor;
this.percent = item.percent;
this.dicFloorCount = item.floorCount;
if(item.floorReward >= 0) {
if (item.floorReward >= 0) {
this.dicFloor = item.percent[item.floorReward]
}
}
private getFloorResult(base: { id: number, weight: number, goodId?: number }) {
if(!this.dicFloor) return base;
if (!this.dicFloor) return base;
let isTarget = base.id == this.dicFloor.id; // 是否抽到的就是那个保底
if(this.dicFloorType == GACHA_FLOOR_TYPE.GOLD) { // 元宝招募 橙色 按次数保底,抽到就重计
if(isTarget || this.floorCount + 1 >= this.dicFloorCount) {
if (this.dicFloorType == GACHA_FLOOR_TYPE.GOLD) { // 元宝招募 橙色 按次数保底,抽到就重计
if (isTarget || this.floorCount + 1 >= this.dicFloorCount) {
this.floorCount = 0;
return this.dicFloor;
} else {
this.floorCount ++;
this.floorCount++;
return base;
}
} else if (this.dicFloorType == GACHA_FLOOR_TYPE.ASSIGN) {
let result = base;
if(isTarget || this.floorCount + 1 >= this.dicFloorCount) {
if(this.hasGetFloor) { // 已经获得过一次保底了, 不给,换个给
if (isTarget || this.floorCount + 1 >= this.dicFloorCount) {
if (this.hasGetFloor) { // 已经获得过一次保底了, 不给,换个给
let { dic } = getRandEelmWithWeight(this.percent.filter(cur => cur.id != this.dicFloor.id));
result = dic
} else {
@@ -178,16 +180,16 @@ export class GachaPull {
result = this.dicFloor;
}
}
this.floorCount ++;
if(this.floorCount >= this.dicFloorCount) {
this.floorCount++;
if (this.floorCount >= this.dicFloorCount) {
this.hasGetFloor = false;
this.floorCount = 0;
}
console.log('******', this.floorCount, this.dicFloorCount, this.hasGetFloor )
console.log('******', this.floorCount, this.dicFloorCount, this.hasGetFloor)
return result;
} else {
return base
}
}
}
/**
@@ -201,7 +203,7 @@ export class GachaPull {
let { type, param, count } = dic;
if (type == GACHA_CONTENT_TYPE.HERO) {
let pool: number[] = [];
if(this.hope.length > 0) {
if (this.hope.length > 0) {
pool = this.getPoolByHope(this.hope, param[0]); // 根据心愿单获得卡池
} else {
pool = getAllHeroByQuality(param[0]); // 没有心愿单就根据武将颜色
@@ -251,7 +253,7 @@ export class GachaPull {
if (h.hasGet) hasGetHope.push(h.id);
}
}
let list = gameData.gachaHope.map(cur => {
return { ...cur, hasGet: hopeMap.get(cur.id)?.hasGet || false };
})
@@ -303,17 +305,17 @@ export class GachaPull {
}
private getPurpleFloor(count: number, index: number, contentId: number, resultList: GachaResult[]) {
if(this.gachaType == GACHA_ID.NORMAL && count == 10 && index == count - 1) { // 10连到最后一抽
if (this.gachaType == GACHA_ID.NORMAL && count == 10 && index == count - 1) { // 10连到最后一抽
let { type, param } = gameData.gachaContent.get(contentId);
if(type != GACHA_CONTENT_TYPE.HERO || param[0] < HERO_QUALITY_TYPE.PURPLE) {
if (type != GACHA_CONTENT_TYPE.HERO || param[0] < HERO_QUALITY_TYPE.PURPLE) {
let hasPurple = false;
for(let { contentId } of resultList) {
for (let { contentId } of resultList) {
let { type, param } = gameData.gachaContent.get(contentId);
if(type == GACHA_CONTENT_TYPE.HERO && param[0] >= HERO_QUALITY_TYPE.PURPLE) {
if (type == GACHA_CONTENT_TYPE.HERO && param[0] >= HERO_QUALITY_TYPE.PURPLE) {
hasPurple = true; break;
}
}
if(!hasPurple) {
if (!hasPurple) {
return gameData.gachaContentHero.get(HERO_QUALITY_TYPE.PURPLE);
}
}
@@ -324,9 +326,9 @@ export class GachaPull {
// 获得需要储存的数据
// 一般抽卡getter
public getUserGachaParam(userGacha: UserGachaType) {
let floor = userGacha.floor||[];
let floor = userGacha.floor || [];
let curFloor = floor.find(cur => cur.id == this.dicFloorType);
if(curFloor) {
if (curFloor) {
curFloor.hasGetFloor = this.hasGetFloor;
curFloor.count = this.floorCount;
} else {