武将:抽象武将创建接口
This commit is contained in:
@@ -187,7 +187,10 @@ export const gameData = {
|
||||
taskBox: dicTaskBox,
|
||||
gacha: dicGacha,
|
||||
gachaContent: dicGachaContent,
|
||||
gachaContentHero: dicGachaContentHero
|
||||
gachaContentHero: dicGachaContentHero,
|
||||
gachaHope: getGachaHopePercent(),
|
||||
gachaTurntable: getGachaTurntablePercent(),
|
||||
heroTransPiece: getHeroTransPiece()
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
@@ -582,4 +585,29 @@ export function getRandExpedition(cnt = 1) {
|
||||
arr.push(dicExpedition);
|
||||
}
|
||||
return getRandEelm(arr, cnt);
|
||||
}
|
||||
|
||||
// 抽卡心愿单概率
|
||||
function getGachaHopePercent() {
|
||||
let arr = decodeArrayListStr(RECRUIT.RECRUIT_WISH_LIST);
|
||||
return arr.map(cur => {
|
||||
return { id: parseInt(cur[0]), weight: parseInt(cur[1]) }
|
||||
});
|
||||
}
|
||||
|
||||
// 抽卡转盘概率
|
||||
function getGachaTurntablePercent() {
|
||||
let arr = decodeArrayListStr(RECRUIT.RECRUIT_BONUS_HERO_QUANTITY);
|
||||
return arr.map(cur => {
|
||||
return { quality: parseInt(cur[0]), weight: parseInt(cur[1]) }
|
||||
});
|
||||
}
|
||||
|
||||
function getHeroTransPiece() {
|
||||
let map = decodeIdCntArrayStr(RECRUIT.RECRUIT_CHANGE_SHARD, 1);
|
||||
let newMap = new Map<number, number>();
|
||||
for(let [id, count] of map) {
|
||||
newMap.set(parseInt(id), count);
|
||||
}
|
||||
return newMap
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import { Figure } from '../domain/dbGeneral';
|
||||
import { getBeforeDaySeconds, nowSeconds } from './timeUtil';
|
||||
import { calPlayerCeAndSave, reCalAllHeroCe } from './playerCe';
|
||||
import { checkTask, checkTaskWithHeroes, checkTaskWithEquip, accomplishTask } from './taskUtil';
|
||||
import { CreateHeroParam } from '../domain/roleField/hero';
|
||||
|
||||
export async function addSkins(roleId: string, id: number) {
|
||||
let skinInfo = gameData.fashion.get(id);
|
||||
@@ -221,12 +222,12 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = fals
|
||||
return figure
|
||||
}
|
||||
|
||||
export async function createHero(roleId: string, heroInfo: HeroUpdate) {
|
||||
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage } = await createHeroes(roleId, [heroInfo])
|
||||
export async function createHero(roleId: string, roleName: string, serverId: number, heroInfo: CreateHeroParam) {
|
||||
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage } = await createHeroes(roleId, roleName, serverId, [heroInfo])
|
||||
return { hero: heroes[0], role, figureInfo, calHeroResult: calHeroResults[0], calAllHeroResult: calAllHeroResults[0], taskPushMessage }
|
||||
}
|
||||
|
||||
export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
|
||||
export async function createHeroes(roleId: string, roleName: string, serverId: number, heroInfos: CreateHeroParam[]) {
|
||||
|
||||
let heroNum = 0;
|
||||
let skinIds = new Array<number>();
|
||||
@@ -234,12 +235,16 @@ export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
|
||||
let heroes: HeroType[] = [], calHeroResults = [], calAllHeroResults = [];
|
||||
|
||||
for (let heroInfo of heroInfos) {
|
||||
let curHero = await HeroModel.createHero(heroInfo); heroes.push(curHero);
|
||||
let dicHero = gameData.hero.get(heroInfo.hid);
|
||||
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = dicHero;
|
||||
|
||||
let info = { roleId, roleName, serverId, quality, star, job, hName, skins: [{id: initialSkin, enable: true}] };
|
||||
let curHero = await HeroModel.createHero(Object.assign(info, heroInfo));
|
||||
let calHeroResult = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, roleId, curHero, {}); calHeroResults.push(calHeroResult);
|
||||
let calAllHeroResult = await reCalAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, {}, skinIds); calAllHeroResults.push(calAllHeroResult);
|
||||
|
||||
heroes.push(calHeroResult.hero);
|
||||
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid });
|
||||
heroInfo.skins.forEach(cur => {
|
||||
info.skins.forEach(cur => {
|
||||
skinIds.push(cur.id);
|
||||
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: cur.id });
|
||||
});
|
||||
@@ -257,4 +262,10 @@ export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
|
||||
//成长任务
|
||||
await accomplishTask(roleId, TASK_TYPE.HERO_NUM, heroNum)
|
||||
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage }
|
||||
}
|
||||
|
||||
export function transPiece(hid: number) {
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
let count = gameData.heroTransPiece.get(dicHero.quality);
|
||||
return { pieceId: dicHero.pieceId, count }
|
||||
}
|
||||
@@ -37,7 +37,7 @@ export async function calPlayerCeAndSave(type: number, roleId: string, originHer
|
||||
update.attr = heroAttrs;
|
||||
update.ce = heroCe;
|
||||
if (originHero.historyCe < heroCe) update.historyCe = heroCe;
|
||||
let hero = await HeroModel.updateHeroInfo(roleId, originHero.hid, update); // 更新武将
|
||||
let hero = await HeroModel.updateHeroInfo(roleId, originHero.hid, update, null, true); // 更新武将 返回是战力缩过的
|
||||
|
||||
// 更新到角色
|
||||
let { topLineup, topLineupCe } = await calculatetopLineup(role, originHero.hid, heroCe, originHero._id); // 计算更新最强五人战力
|
||||
|
||||
Reference in New Issue
Block a user