diff --git a/game-server/app/servers/battle/handler/normalBattleHandler.ts b/game-server/app/servers/battle/handler/normalBattleHandler.ts index 69ea41721..32923830d 100644 --- a/game-server/app/servers/battle/handler/normalBattleHandler.ts +++ b/game-server/app/servers/battle/handler/normalBattleHandler.ts @@ -436,8 +436,8 @@ export class NormalBattleHandler { } // 关卡列表 - async receiveChapterBox(msg: { chapter: number, id: number }, session: BackendSession) { - const { id, chapter } = msg; + async receiveChapterBox(msg: { chapter: number, id: number, warType: number }, session: BackendSession) { + const { id, chapter, warType } = msg; if(!isNumber(id)) return resResult(STATUS.WRONG_PARMS); let roleId = session.get('roleId'); @@ -447,14 +447,13 @@ export class NormalBattleHandler { let role = await RoleModel.findByRoleId(roleId, 'warStar receivedBox'); let ids: number[] = []; let rewards: RewardInter[] = []; - let starOfChapter = getStarOfChapter(role.warStar); + let star = getStarOfChapter(role.warStar, warType, chapter); - let boxIds = id == 0? gameData.mainBoxByChapter.get(chapter): [id]; + let boxIds = id == 0? gameData.mainBoxByChapter.get(`${warType}_${chapter}`): [id]; for(let id of boxIds) { let dicBox = gameData.mainBox.get(id); - if(dicBox && dicBox.chapter == chapter) { - let star = starOfChapter.get(chapter) + if(dicBox && dicBox.chapter == chapter && dicBox.warType == warType) { if(star >= dicBox.star) { rewards.push(...dicBox.reward); ids.push(id); diff --git a/game-server/app/services/normalBattleService.ts b/game-server/app/services/normalBattleService.ts index e603dc818..f075a87d5 100644 --- a/game-server/app/services/normalBattleService.ts +++ b/game-server/app/services/normalBattleService.ts @@ -195,28 +195,31 @@ export async function getBattleList(role: RoleType, type: number) { return result; } -export function getStarOfChapter(warStar: WarStar[]) { - let map = new Map(); +export function getStarOfChapter(warStar: WarStar[], warTye: number, chapter: number) { + let starOfChapter = 0 for(let { id, star } of warStar ) { let dicWar = gameData.war.get(id); - if(dicWar.warType == WAR_TYPE.NORMAL && star > 0) { - if(!map.has(dicWar.chapter)) { - map.set(dicWar.chapter, star); - } else { - map.set(dicWar.chapter, map.get(dicWar.chapter) + star); - } + if(dicWar.warType == warTye && star > 0) { + starOfChapter += star; } } - return map; + return starOfChapter; } export function getMainChapter(role: RoleType) { - let chapterMap = getStarOfChapter(role.warStar); - let chapterArr: { chapter: number, star: number }[] = []; - for(let [ chapter, star ] of chapterMap) { - chapterArr.push({ chapter, star }); + let chapterArr: { chapter: number, star: number, warType: number }[] = []; + for(let { id, star } of role.warStar ) { + let dicWar = gameData.war.get(id); + if((dicWar.warType == WAR_TYPE.NORMAL || dicWar.warType == WAR_TYPE.MAIN_ELITE) && star > 0) { + let curChapter = chapterArr.find(cur => cur.warType == dicWar.warType && cur.chapter == dicWar.chapter); + if(!curChapter) { + chapterArr.push({ chapter: dicWar.chapter, star, warType: dicWar.warType }); + } else { + curChapter.star += star; + } + } } - + return { star: chapterArr, receivedBox: role.receivedBox||[], diff --git a/shared/pubUtils/dictionary/DicMainStarBox.ts b/shared/pubUtils/dictionary/DicMainStarBox.ts index 8cb729f3e..ad41a522d 100644 --- a/shared/pubUtils/dictionary/DicMainStarBox.ts +++ b/shared/pubUtils/dictionary/DicMainStarBox.ts @@ -12,10 +12,12 @@ export interface DicMainStarBox { readonly star: number; // 奖励 readonly reward: RewardInter[]; + // 主线类型 + readonly warType: number; } export const dicMainStarBox = new Map(); -export const dicMainStarBoxByChapter = new Map(); // chapter => ids; +export const dicMainStarBoxByChapter = new Map(); // chapter => ids; export function loadMainStarBox() { dicMainStarBox.clear(); dicMainStarBoxByChapter.clear(); @@ -24,11 +26,12 @@ export function loadMainStarBox() { arr.forEach(o => { o.reward = parseGoodStr(o.reward); + o.warType = o.maintype; dicMainStarBox.set(o.id, o); - if(!dicMainStarBoxByChapter.has(o.chapter)) { - dicMainStarBoxByChapter.set(o.chapter, []); + if(!dicMainStarBoxByChapter.has(`${o.warType}_${o.chapter}`)) { + dicMainStarBoxByChapter.set(`${o.warType}_${o.chapter}`, []); } - dicMainStarBoxByChapter.get(o.chapter).push(o.id); + dicMainStarBoxByChapter.get(`${o.warType}_${o.chapter}`).push(o.id); }); arr = undefined; } \ No newline at end of file diff --git a/shared/resource/jsons/dic_zyz_main_star_reward.json b/shared/resource/jsons/dic_zyz_main_star_reward.json index 34d22dd26..3f712f4e0 100644 --- a/shared/resource/jsons/dic_zyz_main_star_reward.json +++ b/shared/resource/jsons/dic_zyz_main_star_reward.json @@ -172,167 +172,167 @@ "chapter": 1, "star": 6, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 26, "chapter": 1, "star": 12, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 27, "chapter": 1, "star": 18, "reward": "22001&30", - "maintype": 2 + "maintype": 12 }, { "id": 28, "chapter": 2, "star": 6, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 29, "chapter": 2, "star": 12, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 30, "chapter": 2, "star": 18, "reward": "22001&30", - "maintype": 2 + "maintype": 12 }, { "id": 31, "chapter": 3, "star": 6, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 32, "chapter": 3, "star": 12, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 33, "chapter": 3, "star": 18, "reward": "22001&30", - "maintype": 2 + "maintype": 12 }, { "id": 34, "chapter": 4, "star": 6, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 35, "chapter": 4, "star": 12, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 36, "chapter": 4, "star": 18, "reward": "22001&30", - "maintype": 2 + "maintype": 12 }, { "id": 37, "chapter": 5, "star": 7, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 38, "chapter": 5, "star": 14, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 39, "chapter": 5, "star": 21, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 40, "chapter": 5, "star": 28, "reward": "22001&30", - "maintype": 2 + "maintype": 12 }, { "id": 41, "chapter": 6, "star": 7, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 42, "chapter": 6, "star": 14, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 43, "chapter": 6, "star": 21, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 44, "chapter": 6, "star": 28, "reward": "22001&30", - "maintype": 2 + "maintype": 12 }, { "id": 45, "chapter": 7, "star": 7, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 46, "chapter": 7, "star": 14, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 47, "chapter": 7, "star": 21, "reward": "31002&500", - "maintype": 2 + "maintype": 12 }, { "id": 48, "chapter": 7, "star": 28, "reward": "22001&30", - "maintype": 2 + "maintype": 12 } ] \ No newline at end of file