抽卡:逻辑修复
This commit is contained in:
@@ -333,8 +333,12 @@ export class GachaHandler {
|
|||||||
async getGuideGachaData(msg: {}, session: BackendSession) {
|
async getGuideGachaData(msg: {}, session: BackendSession) {
|
||||||
const { } = msg;
|
const { } = msg;
|
||||||
const roleId: string = session.get('roleId');
|
const roleId: string = session.get('roleId');
|
||||||
const userGacha = await UserGachaModel.findByRole(roleId, GACHA_ID.NORMAL);
|
let { gachaHasGuide } = await RoleModel.findByRoleId(roleId, 'gachaHasGuide');
|
||||||
let { guideCount = 0, guideResultList = [], candidates = [] } = userGacha;
|
let guideCount = 0, guideResultList = [], candidates = [];
|
||||||
|
if(!gachaHasGuide) {
|
||||||
|
const userGacha = await UserGachaModel.findByRole(roleId, GACHA_ID.NORMAL);
|
||||||
|
({ guideCount = 0, guideResultList = [], candidates = [] } = userGacha);
|
||||||
|
}
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
guideCount,
|
guideCount,
|
||||||
@@ -370,7 +374,7 @@ export class GachaHandler {
|
|||||||
|
|
||||||
let userHeroes = await HeroModel.findByRole(roleId);
|
let userHeroes = await HeroModel.findByRole(roleId);
|
||||||
let gachaPull = new GachaPull(gachaId);
|
let gachaPull = new GachaPull(gachaId);
|
||||||
gachaPull.setByUserGacha({...dicGacha, floorReward: 0}, userGacha, true);
|
gachaPull.setByUserGacha(dicGacha, userGacha, true);
|
||||||
let { resultList } = gachaPull.pull(count, userHeroes);
|
let { resultList } = gachaPull.pull(count, userHeroes);
|
||||||
|
|
||||||
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { guideResultList: resultList, guideCount: guideCount + 1 })
|
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { guideResultList: resultList, guideCount: guideCount + 1 })
|
||||||
|
|||||||
@@ -190,8 +190,8 @@ class GachaResults {
|
|||||||
export class GachaPull {
|
export class GachaPull {
|
||||||
private gachaType: GACHA_ID; // 抽卡类型
|
private gachaType: GACHA_ID; // 抽卡类型
|
||||||
// 字典
|
// 字典
|
||||||
private dicFloor: Map<GACHA_FLOOR_TYPE, number>; // 保底次数
|
private dicFloor: Map<GACHA_FLOOR_TYPE, number> = new Map(); // 保底次数
|
||||||
private percent: { id: number, weight: number, goodId?: number }[];
|
private percent: { id: number, weight: number, goodId?: number }[] = [];
|
||||||
private bigReward: { id: number, weight: number, goodId?: number }; // 保底的一项,percent中的一项
|
private bigReward: { id: number, weight: number, goodId?: number }; // 保底的一项,percent中的一项
|
||||||
// 玩家数据
|
// 玩家数据
|
||||||
private player: PlayerGachaRecord;
|
private player: PlayerGachaRecord;
|
||||||
@@ -262,6 +262,7 @@ export class GachaPull {
|
|||||||
break;
|
break;
|
||||||
case GACHA_FLOOR_TYPE.ASSIGN:
|
case GACHA_FLOOR_TYPE.ASSIGN:
|
||||||
this.setAssignFloor(floorCount);
|
this.setAssignFloor(floorCount);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,18 +293,20 @@ export class GachaPull {
|
|||||||
public setAssignFloor(dicFloorCount: number) {
|
public setAssignFloor(dicFloorCount: number) {
|
||||||
let floorType = GACHA_FLOOR_TYPE.ASSIGN;
|
let floorType = GACHA_FLOOR_TYPE.ASSIGN;
|
||||||
let { floorCount: historyCount, hasGetFloor } = this.player.getFloorCountByFloorType(floorType);
|
let { floorCount: historyCount, hasGetFloor } = this.player.getFloorCountByFloorType(floorType);
|
||||||
|
console.log('#### gachaResult', this.result.list)
|
||||||
for(let gachaResult of this.result.list) {
|
for(let gachaResult of this.result.list) {
|
||||||
let isTarget = this.bigReward.id == gachaResult.contentId;
|
let isTarget = this.bigReward.id == gachaResult.contentId;
|
||||||
|
console.log('#### setAssignFloor', historyCount, dicFloorCount, isTarget)
|
||||||
if(++historyCount >= dicFloorCount || isTarget) {
|
if(++historyCount >= dicFloorCount || isTarget) {
|
||||||
|
console.log('#### setAssignFloor', isTarget, hasGetFloor)
|
||||||
if(hasGetFloor) { // 已经获得过一次保底了, 不给,换个给
|
if(hasGetFloor) { // 已经获得过一次保底了, 不给,换个给
|
||||||
gachaResult.setContentId(getGachaContentOfHeroQuality(HERO_QUALITY_TYPE.PURPLE));
|
gachaResult.setContentId(getGachaContentOfHeroQuality(HERO_QUALITY_TYPE.PURPLE));
|
||||||
} else {
|
} else {
|
||||||
gachaResult.setContentId(this.bigReward.id, this.bigReward.goodId);
|
gachaResult.setContentId(this.bigReward.id, this.bigReward.goodId);
|
||||||
hasGetFloor = false;
|
hasGetFloor = true;
|
||||||
}
|
}
|
||||||
gachaResult.setContentId(this.bigReward.id, this.bigReward.goodId);
|
|
||||||
historyCount = 0;
|
|
||||||
}
|
}
|
||||||
|
console.log('#### setAssignFloor after', historyCount, dicFloorCount)
|
||||||
if(historyCount >= dicFloorCount) {
|
if(historyCount >= dicFloorCount) {
|
||||||
hasGetFloor = false;
|
hasGetFloor = false;
|
||||||
historyCount = 0;
|
historyCount = 0;
|
||||||
@@ -342,8 +345,11 @@ export class GachaPull {
|
|||||||
|
|
||||||
public pullBySimpleResult(simpleResult: {contentId: number, hid: number }[], userHeroes: HeroType[]) {
|
public pullBySimpleResult(simpleResult: {contentId: number, hid: number }[], userHeroes: HeroType[]) {
|
||||||
let results = simpleResult.map(obj => {
|
let results = simpleResult.map(obj => {
|
||||||
return new GachaResult(obj.contentId, obj.hid);
|
let gachaResult = new GachaResult(obj.contentId);
|
||||||
|
gachaResult.setHidOrGid(obj.hid);
|
||||||
|
return gachaResult;
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.transferToFinalResult(results, userHeroes);
|
return this.transferToFinalResult(results, userHeroes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +404,8 @@ class ContentDetail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getResult() {
|
public getResult() {
|
||||||
switch(this.contentId) {
|
let { type } = gameData.gachaContent.get(this.contentId);
|
||||||
|
switch(type) {
|
||||||
case GACHA_CONTENT_TYPE.HERO:
|
case GACHA_CONTENT_TYPE.HERO:
|
||||||
return this.randomHeroByQuality(this.param[0]);
|
return this.randomHeroByQuality(this.param[0]);
|
||||||
case GACHA_CONTENT_TYPE.HERO_PIECE:
|
case GACHA_CONTENT_TYPE.HERO_PIECE:
|
||||||
@@ -407,6 +414,8 @@ class ContentDetail {
|
|||||||
return this.randomStoneByLv(this.param[0]);
|
return this.randomStoneByLv(this.param[0]);
|
||||||
case GACHA_CONTENT_TYPE.ITEMS:
|
case GACHA_CONTENT_TYPE.ITEMS:
|
||||||
return getRandSingleEelm(this.param);
|
return getRandSingleEelm(this.param);
|
||||||
|
default:
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,13 +141,13 @@ export class GachaResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setHidOrGid(id: number, count?: number) {
|
setHidOrGid(id: number, count?: number) {
|
||||||
let dicGachaContent = gameData.gachaContent.get(id);
|
let dicGachaContent = gameData.gachaContent.get(this.contentId);
|
||||||
if(!dicGachaContent) return;
|
if(!dicGachaContent) return;
|
||||||
|
|
||||||
if(dicGachaContent.type == GACHA_CONTENT_TYPE.HERO) {
|
if(dicGachaContent.type == GACHA_CONTENT_TYPE.HERO) {
|
||||||
this.setHero(id);
|
this.setHero(id);
|
||||||
} else {
|
} else {
|
||||||
this.setItem(id, count);
|
this.setItem(id, count||dicGachaContent.count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user