抽卡:求贤若渴pick武将按品质算数量

This commit is contained in:
luying
2022-06-27 17:36:11 +08:00
parent ed1586fefe
commit b5c2005192
5 changed files with 51 additions and 14 deletions

View File

@@ -194,12 +194,12 @@ export class GachaHandler {
let resultList: GachaResult[] = [];
for (let h of resultHeroes) {
let result = new GachaResult(contentId);
result.setHero(h.hid);
result.setHero(h.hid, 1);
resultList.push(result);
}
for (let g of goods) {
let result = new GachaResult(contentId);
result.setHero(hero);
result.setHero(hero, 1);
result.transferToPiece(g.id, g.count);
resultList.push(result);
}

View File

@@ -328,7 +328,7 @@ export class GachaPull {
let { dic: { id: randHopePosition } } = getRandEelmWithWeight(gameData.gachaHope);
if(randHopePosition > 0) { // 按玩家设置的心愿单塞
let hopeHero = this.player.getHopeHero(randHopePosition)
if(hopeHero > 0) gachaResult.setHidOrGid(hopeHero);
if(hopeHero > 0) gachaResult.setHidOrGid(hopeHero, 1);
}
this.player.setUserHope(gachaResult.hid); // 设置心愿单中了没有
}
@@ -342,7 +342,7 @@ export class GachaPull {
public pullBySimpleResult(simpleResult: {contentId: number, hid: number }[], userHeroes: HeroType[]) {
let results = simpleResult.map(obj => {
let gachaResult = new GachaResult(obj.contentId);
gachaResult.setHidOrGid(obj.hid);
gachaResult.setHidOrGid(obj.hid, 1);
return gachaResult;
});
@@ -352,8 +352,12 @@ export class GachaPull {
private transferToFinalResult(results: GachaResult[], userHeroes: HeroType[]) {
let hids = userHeroes.map(cur => cur.hid);
let items: RewardInter[] = [], heroInfo: CreateHeroParam[] = [];
for (let result of results) {
let newResult: GachaResult[] = [];
for(let result of results) {
let cnt = result.hid > 0? result.count: 1;
newResult.push(...new Array(cnt).fill(result.copy()));
}
for (let result of newResult) {
if (result.hid > 0) {
let hasHero = hids.indexOf(result.hid) != -1;
if (hasHero) { // 已有转换为碎片
@@ -368,7 +372,7 @@ export class GachaPull {
items.push({ id: result.id, count: result.count });
}
}
return { items, heroInfo, resultList: results }
return { items, heroInfo, resultList: newResult }
}
// 获得需要储存的数据
@@ -416,13 +420,22 @@ class ContentDetail {
}
private randomHeroByQuality(quality: number) {
if(quality == 0) return this.pickHero;
if(quality == 0) {
this.setPickHeroCnt();
return this.pickHero;
}
let heroes = getAllHeroByQuality(quality);
return getRandSingleEelm(heroes);
}
private setPickHeroCnt() {
if(this.pickHero && gameData.hero.has(this.pickHero)) {
let dicHero = gameData.hero.get(this.pickHero);
this.count = gameData.gachaPickHeroCnt.get(dicHero.quality)??1;
}
}
private randomHeroPieceByQuality(quality: number) {
let pieces = getAllItemByQuality(IT_TYPE.HERO_PIECE, quality);
return getRandSingleEelm(pieces);

View File

@@ -140,20 +140,20 @@ export class GachaResult {
if(id) this.pickHero = id;
}
setHidOrGid(id: number, count?: number) {
setHidOrGid(id: number, count: number) {
let dicGachaContent = gameData.gachaContent.get(this.contentId);
if(!dicGachaContent) return;
if(dicGachaContent.type == GACHA_CONTENT_TYPE.HERO) {
this.setHero(id);
this.setHero(id, count);
} else {
this.setItem(id, count||dicGachaContent.count);
}
}
setHero(hid: number) {
setHero(hid: number, count: number) {
this.hid = hid;
this.count = 1;
this.count = count;
}
setItem(id: number, count: number) {
@@ -166,4 +166,14 @@ export class GachaResult {
this.id = id;
this.count = count;
}
copy() {
let result = new GachaResult(this.contentId);
result.hid = this.hid;
result.isTransfer = this.isTransfer;
result.id = this.id;
result.count = this.count;
result.pickHero = this.pickHero;
return result
}
}

View File

@@ -214,6 +214,7 @@ export const gameData = {
gachaContentHero: dicGachaContentHero,
gachaHope: new Array<{id: number, weight: number}>(),
gachaTurntable: new Array<{quality: number, count: number}>(),
gachaPickHeroCnt: new Map<number, number>(),
heroTransPiece: new Map<number, number>(),
giftPackage: dicGiftPackage,
comBtlLvRange: new Map<number, {min: number, max: number}>(),
@@ -745,6 +746,13 @@ function getGachaTurntablePercent() {
});
}
function getGachaPickHeroCnt() {
let arr = decodeArrayListStr(RECRUIT.RECRUIT_GET_HERO_HIGH_RECRUIT);
arr.forEach(cur => {
gameData.gachaPickHeroCnt.set(parseInt(cur[0]), parseInt(cur[1]));
});
}
function getHeroTransPiece() {
let map = decodeIdCntArrayStr(RECRUIT.RECRUIT_CHANGE_SHARD, 1);
let newMap = new Map<number, number>();
@@ -955,6 +963,7 @@ function parseDicParam() {
decodeRaceEventItems();
getGachaHopePercent();
getGachaTurntablePercent();
getGachaPickHeroCnt();
getHeroTransPiece();
parseComBtlLvRange();
getCeRatio();

View File

@@ -151,6 +151,7 @@ export const RECRUIT = {
RECRUIT_LEVEL_HIGH_RECRUIT: 30, // 求贤若渴多少级开启
RECRUIT_DAILY_RECRUIT_SHARD: 3, // 每日武将拜访数量
RECRUIT_SHARD_LIMIT: 5, // 每日武将拜访碎片数量
RECRUIT_GET_HERO_HIGH_RECRUIT: '1&6|2&3|3&1', // 求贤若渴指定武将为名将/国士/传奇时,抽中后分别获得多少个同武将
RECRUIT_FIRST_RECRUIT: 50, // 首次招募预招募50次10连
RECRUIT_FIRST_RECRUIT_SAVE: 2, // 最多保存2个预招募结果
};
@@ -245,7 +246,6 @@ export const SERVER_DEBUG_MODE = {
export const IS_SQ = {
IS_OPEN: 1, // 0关1开37SDK
};
/*音效开关*/
export const OPEN_EFFECT = {
GUIDE_EFFECT: 0, // 0关1开 (引导音效)
TALK_EFFECT: 0, // 0关1开 (剧情对话音效)
@@ -300,3 +300,8 @@ export const TABEL = {
JOB_MIN_GRADE: 0, // 职业表-职业最小阶数
JOB_MAX_GRADE: 16, // 职业表-职业最大阶数
};
export const INFO_WINDOW = {
TEAM_VIEW: 10, // 组队列表显示队伍最大数量
REFRESH_TIME: 10, // 刷新冷却时间s
TEAM_INFORMATION_TIME: 60, // 显示的组队信息时间s
};