任务:修复任务无法达成bug
This commit is contained in:
@@ -75,7 +75,7 @@ export class GachaHandler {
|
|||||||
|
|
||||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, activityId);
|
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, activityId);
|
||||||
let { floor, freeCount, hope, point, pickHero, refFreeTime } = await refreshGacha(dicGacha, userGacha);
|
let { floor, freeCount, hope, point, pickHero, refFreeTime } = await refreshGacha(dicGacha, userGacha);
|
||||||
if((gachaId == GACHA_ID.ASSIGN|| gachaId == GACHA_ID.TIMELIMIT) && pickHero) return resResult(STATUS.GACHA_NOT_ASSIGN);
|
if((gachaId == GACHA_ID.ASSIGN|| gachaId == GACHA_ID.TIMELIMIT) && !pickHero) return resResult(STATUS.GACHA_NOT_ASSIGN);
|
||||||
|
|
||||||
let userHeroes = await HeroModel.findByRole(roleId);
|
let userHeroes = await HeroModel.findByRole(roleId);
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ export class GachaHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let costNum = count;
|
let costNum = count;
|
||||||
if(dicGacha.free.count > 0) {
|
if(count == 1 && dicGacha.free.count > 0) { // 单抽的时候免费
|
||||||
if(count > dicGacha.free.count - freeCount) {
|
if(count > dicGacha.free.count - freeCount) {
|
||||||
costNum = count - dicGacha.free.count + freeCount;
|
costNum = count - dicGacha.free.count + freeCount;
|
||||||
freeCount = dicGacha.free.count;
|
freeCount = dicGacha.free.count;
|
||||||
@@ -120,7 +120,7 @@ export class GachaHandler {
|
|||||||
if(!costResult) return resResult(STATUS.GACHA_COST_NOT_ENOUGH);
|
if(!costResult) return resResult(STATUS.GACHA_COST_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
// 给东西
|
// 给东西
|
||||||
let { heroes } = await createHeroes(roleId, roleName, sid, serverId, heroInfo);
|
let { heroes } = await createHeroes(roleId, roleName, sid, serverId, funcs, heroInfo);
|
||||||
await addItems(roleId, roleName, sid, items);
|
await addItems(roleId, roleName, sid, items);
|
||||||
// 更新数据
|
// 更新数据
|
||||||
point = Math.floor(count/RECRUIT.RECRUIT_BONUS);
|
point = Math.floor(count/RECRUIT.RECRUIT_BONUS);
|
||||||
@@ -157,7 +157,7 @@ export class GachaHandler {
|
|||||||
for(let { hid } of hope) {
|
for(let { hid } of hope) {
|
||||||
let dicHero = gameData.hero.get(hid);
|
let dicHero = gameData.hero.get(hid);
|
||||||
if(!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
if(!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
if(dicHero.quality != HERO_QUALITY_TYPE.GOLD) {
|
if(hid != 0 && dicHero.quality != HERO_QUALITY_TYPE.GOLD) {
|
||||||
return resResult(STATUS.GACHA_HOPE_NOT_GOLD);
|
return resResult(STATUS.GACHA_HOPE_NOT_GOLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,6 +181,7 @@ export class GachaHandler {
|
|||||||
const roleName: string = session.get('roleName');
|
const roleName: string = session.get('roleName');
|
||||||
const sid: string = session.get('sid');
|
const sid: string = session.get('sid');
|
||||||
const serverId: number = session.get('serverId');
|
const serverId: number = session.get('serverId');
|
||||||
|
const funcs: number[] = session.get('funcs');
|
||||||
|
|
||||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, 0);
|
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, 0);
|
||||||
let { point, turntable } = userGacha;
|
let { point, turntable } = userGacha;
|
||||||
@@ -210,7 +211,7 @@ export class GachaHandler {
|
|||||||
for(let i = 0; i < count; i++) {
|
for(let i = 0; i < count; i++) {
|
||||||
heroInfo.push({ hid: hero[0] })
|
heroInfo.push({ hid: hero[0] })
|
||||||
}
|
}
|
||||||
let { heroes, goods } = await createHeroes(roleId, roleName, sid, serverId, heroInfo);
|
let { heroes, goods } = await createHeroes(roleId, roleName, sid, serverId, funcs, heroInfo);
|
||||||
let resultList: GachaResult[] = [];
|
let resultList: GachaResult[] = [];
|
||||||
for(let h of heroes) {
|
for(let h of heroes) {
|
||||||
let result = new GachaResult(contentId);
|
let result = new GachaResult(contentId);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export class SevenDaysHandler {
|
|||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
|
const funcs: number[] = session.get('funcs');
|
||||||
|
|
||||||
let playerData = await getPlayerGrowthData(activityId, serverId, roleId)
|
let playerData = await getPlayerGrowthData(activityId, serverId, roleId)
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
@@ -82,7 +83,7 @@ export class SevenDaysHandler {
|
|||||||
let dicHero = gameData.hero.get(hid);
|
let dicHero = gameData.hero.get(hid);
|
||||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
// createHero
|
// createHero
|
||||||
let hero = await createHero(roleId, roleName, sid, serverId, { hid });
|
let hero = await createHero(roleId, roleName, sid, serverId, funcs, { hid });
|
||||||
addHeros.push(hero);
|
addHeros.push(hero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +103,7 @@ export class SevenDaysHandler {
|
|||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
|
const funcs = session.get('funcs');
|
||||||
|
|
||||||
let playerData = await getPlayerGrowthData(activityId, serverId, roleId)
|
let playerData = await getPlayerGrowthData(activityId, serverId, roleId)
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
@@ -137,7 +139,7 @@ export class SevenDaysHandler {
|
|||||||
let dicHero = gameData.hero.get(hid);
|
let dicHero = gameData.hero.get(hid);
|
||||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
// createHero
|
// createHero
|
||||||
let { heroes } = await createHero(roleId, roleName, sid, serverId, { hid });
|
let { heroes } = await createHero(roleId, roleName, sid, serverId, funcs, { hid });
|
||||||
for(let hero of heroes) {
|
for(let hero of heroes) {
|
||||||
addHeros.push(hero);
|
addHeros.push(hero);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ export class HeroHandler {
|
|||||||
let roleName: string = session.get('roleName');
|
let roleName: string = session.get('roleName');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
let serverId: number = session.get('serverId');
|
let serverId: number = session.get('serverId');
|
||||||
|
let funcs: number[] = session.get('funcs');
|
||||||
|
|
||||||
let {hid} = msg;
|
let {hid} = msg;
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ export class HeroHandler {
|
|||||||
let costResult = await handleCost(roleId, sid, [{id: pieceId, count: pieceCount}]);
|
let costResult = await handleCost(roleId, sid, [{id: pieceId, count: pieceCount}]);
|
||||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
// createHero
|
// createHero
|
||||||
let { heroes } = await createHero(roleId, roleName, sid, serverId, { hid });
|
let { heroes } = await createHero(roleId, roleName, sid, serverId, funcs, { hid });
|
||||||
|
|
||||||
pushComposeOrangeHero(roleId, roleName, serverId, heroes[0]);
|
pushComposeOrangeHero(roleId, roleName, serverId, heroes[0]);
|
||||||
return resResult(STATUS.SUCCESS, {curHero: heroes[0]});
|
return resResult(STATUS.SUCCESS, {curHero: heroes[0]});
|
||||||
@@ -207,7 +208,7 @@ export class HeroHandler {
|
|||||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, sid, roleId, hero, update);
|
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, sid, roleId, hero, update);
|
||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.HERO_LV, hero);
|
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.HERO_LV, hero, [oldLv]);
|
||||||
|
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid, lv : hero.lv, exp : hero.exp
|
hid, lv : hero.lv, exp : hero.exp
|
||||||
@@ -426,6 +427,7 @@ export class HeroHandler {
|
|||||||
|
|
||||||
//进阶
|
//进阶
|
||||||
async heroJobStageUp(msg: {hid:number}, session: BackendSession) {
|
async heroJobStageUp(msg: {hid:number}, session: BackendSession) {
|
||||||
|
console.log(JSON.stringify([...gameData.jobClassMaxGrades]))
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
let funcs: number[] = session.get('funcs');
|
let funcs: number[] = session.get('funcs');
|
||||||
@@ -444,6 +446,7 @@ export class HeroHandler {
|
|||||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
let nextHeroJob = getJobByGradeAndClass(heroJob.job_class, heroJob.grade + 1);
|
let nextHeroJob = getJobByGradeAndClass(heroJob.job_class, heroJob.grade + 1);
|
||||||
|
if(!nextHeroJob) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
|
|
||||||
//重算战力并下发
|
//重算战力并下发
|
||||||
let update = {
|
let update = {
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ export async function handleComBtlProgress(teamStatus, robotHurtTimer: Map<strin
|
|||||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result}));
|
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result}));
|
||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTaskInComBattleEnd(roleIds, capId, quality);
|
await checkTaskInComBattleEnd(roleIds.filter(roleId => {}), capId, quality);
|
||||||
|
|
||||||
teamMap.delete(teamCode);
|
teamMap.delete(teamCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export async function changeEquip(roleId: string, sid: string, equipA: EquipType
|
|||||||
if (!!hid) //需要卸下或者替换的武将
|
if (!!hid) //需要卸下或者替换的武将
|
||||||
heroB = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);//需要替换的武将
|
heroB = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);//需要替换的武将
|
||||||
|
|
||||||
if (!!equipA) {//需要卸下的装备
|
if (!!equipA) {//需要卸下的装备
|
||||||
if (!!heroB) {
|
if (!!heroB) {
|
||||||
let goodInfo = getGoodById(equipA.id);
|
let goodInfo = getGoodById(equipA.id);
|
||||||
if (goodInfo.lvLimited > heroB.lv) {
|
if (goodInfo.lvLimited > heroB.lv) {
|
||||||
@@ -76,8 +76,10 @@ export async function changeEquip(roleId: string, sid: string, equipA: EquipType
|
|||||||
let res = await dressEquip(roleId, sid, heroB, equipA, funcs);//替换给武将,并计算战力
|
let res = await dressEquip(roleId, sid, heroB, equipA, funcs);//替换给武将,并计算战力
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
if(equipB) {
|
||||||
return res;
|
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (!!heroB) {//从穿戴装备的武将上卸下装备
|
} else if (!!heroB) {//从穿戴装备的武将上卸下装备
|
||||||
await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
||||||
@@ -99,8 +101,8 @@ export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, he
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTask(roleId, sid, funcs, TASK_TYPE.EQUIP_SUM, 1, true, {});
|
await checkTask(roleId, sid, funcs, TASK_TYPE.EQUIP_SUM, 1, true, {});
|
||||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [1]);
|
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [-1]);
|
||||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [1]);
|
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [-1]);
|
||||||
|
|
||||||
return { seqId: equip.seqId, hid: 0};
|
return { seqId: equip.seqId, hid: 0};
|
||||||
}
|
}
|
||||||
@@ -119,8 +121,8 @@ export async function dressEquip(roleId: string, sid: string, hero:HeroType, equ
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTask(roleId, sid, funcs, TASK_TYPE.EQUIP_SUM, -1, true, {});
|
await checkTask(roleId, sid, funcs, TASK_TYPE.EQUIP_SUM, -1, true, {});
|
||||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [-1]);
|
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [1]);
|
||||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [-1]);
|
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [1]);
|
||||||
|
|
||||||
return { seqId: equip.seqId, hid: hero.hid };
|
return { seqId: equip.seqId, hid: hero.hid };
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,8 @@ export async function increaseFrdCnt(role1: RoleType, role2: RoleType, originalF
|
|||||||
return getResStr(STATUS.FRIEND_THEY_CNT_MAX);
|
return getResStr(STATUS.FRIEND_THEY_CNT_MAX);
|
||||||
}
|
}
|
||||||
originalFriendCnt = incMyFrdCnt.friendCnt;
|
originalFriendCnt = incMyFrdCnt.friendCnt;
|
||||||
role1 = incMyFrdCnt; role2 = incHisFrdCnt;
|
role1.friendCnt = incMyFrdCnt.friendCnt;
|
||||||
|
role2.friendCnt = incHisFrdCnt.friendCnt;
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export async function switchOnFunc(roleId: string, type: number, param: number,
|
|||||||
*/
|
*/
|
||||||
export async function chackFunOpenWhenLogin(role: any, session: BackendSession|FrontendSession) {
|
export async function chackFunOpenWhenLogin(role: any, session: BackendSession|FrontendSession) {
|
||||||
await switchOnFunc(role.roleId, FUNC_OPT_TYPE.LEVEL_UP, role.lv, session);
|
await switchOnFunc(role.roleId, FUNC_OPT_TYPE.LEVEL_UP, role.lv, session);
|
||||||
|
|
||||||
await checkResetTrain(role.roleId, role.serverId);
|
await checkResetTrain(role.roleId, role.serverId);
|
||||||
await getUserGuildWithRefActive(role.roleId, '', true)
|
await getUserGuildWithRefActive(role.roleId, '', true)
|
||||||
}
|
}
|
||||||
@@ -209,8 +209,10 @@ function getPoolByHope(hope: Hope[], qualtiy: number) {
|
|||||||
let hopeMap = new Map<number, Hope>();
|
let hopeMap = new Map<number, Hope>();
|
||||||
let hasGetHope: number[] = [];
|
let hasGetHope: number[] = [];
|
||||||
for(let h of hope) {
|
for(let h of hope) {
|
||||||
hopeMap.set(h.id, h);
|
if(h.hid > 0) {
|
||||||
if(h.hasGet) hasGetHope.push(h.id);
|
hopeMap.set(h.id, h);
|
||||||
|
if(h.hasGet) hasGetHope.push(h.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let list = gameData.gachaHope.map(cur => {
|
let list = gameData.gachaHope.map(cur => {
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ export async function pushFigureUpdate(roleId: string, sid: string, figureInfo:
|
|||||||
* @param serverId
|
* @param serverId
|
||||||
* @param heroInfo
|
* @param heroInfo
|
||||||
*/
|
*/
|
||||||
export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam[]) {
|
export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[], heroInfo: CreateHeroParam[]) {
|
||||||
|
|
||||||
let hids = heroInfo.map(cur => cur.hid);
|
let hids = heroInfo.map(cur => cur.hid);
|
||||||
let userHeroesMap = await HeroModel.findMapByHidRange(hids, roleId);
|
let userHeroesMap = await HeroModel.findMapByHidRange(hids, roleId);
|
||||||
@@ -332,7 +332,7 @@ export async function createHeroes(roleId: string, roleName: string, sid: string
|
|||||||
let resultHeroes: HeroType[] = [], resultItems: ItemInter[] = [];
|
let resultHeroes: HeroType[] = [], resultItems: ItemInter[] = [];
|
||||||
if(newHeroInfo.length > 0) {
|
if(newHeroInfo.length > 0) {
|
||||||
|
|
||||||
let { heroes, role, figureInfo, calHeroResults, calAllHeroResults, taskPushMessage } = await pubCreateHeroes(roleId, roleName, serverId, newHeroInfo);
|
let { heroes, role, figureInfo, calHeroResults, calAllHeroResults, taskPushMessage } = await pubCreateHeroes(roleId, roleName, serverId, newHeroInfo, funcs);
|
||||||
|
|
||||||
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
|
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
|
||||||
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
|
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
|
||||||
@@ -357,7 +357,7 @@ export async function createHeroes(roleId: string, roleName: string, sid: string
|
|||||||
return { heroes: resultHeroes, goods: resultItems }
|
return { heroes: resultHeroes, goods: resultItems }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam) {
|
export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[], heroInfo: CreateHeroParam) {
|
||||||
let result = await createHeroes(roleId, roleName, sid, serverId, [heroInfo]);
|
let result = await createHeroes(roleId, roleName, sid, serverId, funcs, [heroInfo]);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -92,6 +92,7 @@ export async function checkTaskInBattleEnd(roleId: string, sid: string, funcs: n
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function checkTaskInComBattleEnd(roleIds: string[], capId: string, quality: number) {
|
export async function checkTaskInComBattleEnd(roleIds: string[], capId: string, quality: number) {
|
||||||
|
console.log('********', roleIds, capId, quality)
|
||||||
for (let roleId of roleIds) {
|
for (let roleId of roleIds) {
|
||||||
if (roleId == capId && roleIds.length > 1) { // 招募队友
|
if (roleId == capId && roleIds.length > 1) { // 招募队友
|
||||||
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, 1, true, {});
|
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, 1, true, {});
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"env":"development"}
|
{"env":"dev"}
|
||||||
@@ -585,7 +585,7 @@ export enum TASK_TYPE {
|
|||||||
LOGIN_SUM = 1, // 累计登录
|
LOGIN_SUM = 1, // 累计登录
|
||||||
LOGIN_SERIES = 2, // 连续登录
|
LOGIN_SERIES = 2, // 连续登录
|
||||||
ROLE_LV = 3, // 主公等级
|
ROLE_LV = 3, // 主公等级
|
||||||
GASHA = 4, // 招募 暂无
|
GASHA = 4, // 招募
|
||||||
HERO_NUM = 5, // 武将数量
|
HERO_NUM = 5, // 武将数量
|
||||||
HERO_STAR_UP = 6, // 升星次数
|
HERO_STAR_UP = 6, // 升星次数
|
||||||
HERO_QUALITY = 7, // 拥有品质
|
HERO_QUALITY = 7, // 拥有品质
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export default class ActivityGrowth extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//删除活动领取记录
|
//删除活动领取记录
|
||||||
public static async deleteActivity(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
public static async deleteActivity(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||||
let result = await ActivityGrowthModel.deleteMany({ roleId, acvitityId, dayIndex, cellIndex });
|
let result = await ActivityGrowthModel.deleteMany({ roleId, acvitityId, dayIndex, cellIndex });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,9 +190,9 @@ export default class Role extends BaseModel {
|
|||||||
|
|
||||||
@prop({ required: true, default: 1 })
|
@prop({ required: true, default: 1 })
|
||||||
loginCnt: number; // 登录次数
|
loginCnt: number; // 登录次数
|
||||||
@prop({ required: true, default: nowSeconds() })
|
@prop({ required: true, default: nowSeconds })
|
||||||
createTime: number; // 创建时间
|
createTime: number; // 创建时间
|
||||||
@prop({ required: true, default: nowSeconds() })
|
@prop({ required: true, default: 0 })
|
||||||
loginTime: number; // 更新 / 登录时间
|
loginTime: number; // 更新 / 登录时间
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
quitTime: number; // 更新 / 登录时间
|
quitTime: number; // 更新 / 登录时间
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { prop } from '@typegoose/typegoose';
|
|
||||||
import { ActivityModelType } from '../../db/Activity';
|
import { ActivityModelType } from '../../db/Activity';
|
||||||
|
|
||||||
// 活动数据
|
// 活动数据
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { prop } from '@typegoose/typegoose';
|
|
||||||
import { TASK_TYPE } from '../../consts';
|
import { TASK_TYPE } from '../../consts';
|
||||||
import { ActivityModelType } from '../../db/Activity';
|
import { ActivityModelType } from '../../db/Activity';
|
||||||
import { ActivityGrowthModelType } from '../../db/ActivityGrowth';
|
import { ActivityGrowthModelType } from '../../db/ActivityGrowth';
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ arr.forEach(o => {
|
|||||||
o.ceAttr = parseCeAttr(o);
|
o.ceAttr = parseCeAttr(o);
|
||||||
dicJob.set(o.jobid, _.pick(o, Object.keys(DicJobKeys)));
|
dicJob.set(o.jobid, _.pick(o, Object.keys(DicJobKeys)));
|
||||||
let jobClass = jobClassMaxGrades.get(o.job_class);
|
let jobClass = jobClassMaxGrades.get(o.job_class);
|
||||||
if (!!jobClass && jobClass.grade < o.grade) {
|
if (!jobClass || jobClass.grade < o.grade) {
|
||||||
jobClassMaxGrades.set(o.job_class, {grade: o.grade,jobid: o.jobid});
|
jobClassMaxGrades.set(o.job_class, {grade: o.grade,jobid: o.jobid});
|
||||||
}
|
}
|
||||||
jobClassAndgrades.set(o.job_class+'_'+o.grade,{unlockLevel:o.unlockLevel, jobid:o.jobid});
|
jobClassAndgrades.set(o.job_class+'_'+o.grade,{unlockLevel:o.unlockLevel, jobid:o.jobid});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
import path = require('path');
|
import path = require('path');
|
||||||
import { ABI_TYPE, COM_BTL_LV_RANGE } from '../consts';
|
import { ABI_TYPE, COM_BTL_LV_RANGE } from '../consts';
|
||||||
import { decodeIdCntArrayStr, getRandEelm } from './util';
|
import { decodeIdCntArrayStr } from './util';
|
||||||
import { IT_TYPE } from '../consts';
|
import { IT_TYPE } from '../consts';
|
||||||
|
|
||||||
let gamedata = {};
|
let gamedata = {};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import { HeroModel, HeroUpdate, HeroType } from '../db/Hero';
|
import { HeroModel, HeroType } from '../db/Hero';
|
||||||
import { ItemModel } from '../db/Item';
|
import { ItemModel } from '../db/Item';
|
||||||
import { EquipModel, RandSe, Holes } from './../db/Equip';
|
import { EquipModel, RandSe, Holes } from './../db/Equip';
|
||||||
import { BagInter, EquipInter } from './interface';
|
import { BagInter, EquipInter } from './interface';
|
||||||
@@ -222,12 +222,12 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = fals
|
|||||||
return figure
|
return figure
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createHero(roleId: string, roleName: string, serverId: number, heroInfo: CreateHeroParam) {
|
export async function createHero(roleId: string, roleName: string, serverId: number, heroInfo: CreateHeroParam, funcs?: number[]) {
|
||||||
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage } = await createHeroes(roleId, roleName, serverId, [heroInfo])
|
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage } = await createHeroes(roleId, roleName, serverId, [heroInfo], funcs)
|
||||||
return { hero: heroes[0], role, figureInfo, calHeroResult: calHeroResults[0], calAllHeroResult: calAllHeroResults[0], taskPushMessage }
|
return { hero: heroes[0], role, figureInfo, calHeroResult: calHeroResults[0], calAllHeroResult: calAllHeroResults[0], taskPushMessage }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createHeroes(roleId: string, roleName: string, serverId: number, heroInfos: CreateHeroParam[]) {
|
export async function createHeroes(roleId: string, roleName: string, serverId: number, heroInfos: CreateHeroParam[], funcs?: number[]) {
|
||||||
|
|
||||||
let heroNum = 0;
|
let heroNum = 0;
|
||||||
let skinIds = new Array<number>();
|
let skinIds = new Array<number>();
|
||||||
@@ -254,10 +254,10 @@ export async function createHeroes(roleId: string, roleName: string, serverId: n
|
|||||||
|
|
||||||
let role = await RoleModel.incRoleInfo(roleId, { heroNum }, { heroNumUpdatedAt: nowSeconds() });
|
let role = await RoleModel.incRoleInfo(roleId, { heroNum }, { heroNumUpdatedAt: nowSeconds() });
|
||||||
// 任务
|
// 任务
|
||||||
let m1 = await checkTask(roleId, TASK_TYPE.HERO_NUM, heroNum, true, {});
|
let m1 = await checkTask(roleId, TASK_TYPE.HERO_NUM, heroNum, true, {}, funcs);
|
||||||
let m2 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY, heroes);
|
let m2 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY, heroes, funcs);
|
||||||
let m3 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, heroes);
|
let m3 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, heroes, funcs);
|
||||||
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes);
|
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes, funcs);
|
||||||
let taskPushMessage = m1.concat(m2, m3, m4);
|
let taskPushMessage = m1.concat(m2, m3, m4);
|
||||||
//成长任务
|
//成长任务
|
||||||
await accomplishTask(roleId, TASK_TYPE.HERO_NUM, heroNum)
|
await accomplishTask(roleId, TASK_TYPE.HERO_NUM, heroNum)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export async function checkTaskWithRole(roleId: string, taskType: number, role:
|
|||||||
let today = getTodayZeroPoint();
|
let today = getTodayZeroPoint();
|
||||||
if (today > role.loginTime) {
|
if (today > role.loginTime) {
|
||||||
if (today - role.loginTime > 24 * 60 * 60) {
|
if (today - role.loginTime > 24 * 60 * 60) {
|
||||||
pushMessage = await checkTask(roleId, taskType, 0, false, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, false, {}, funcs);
|
||||||
} else {
|
} else {
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ export async function checkTaskWithHero(roleId: string, taskType: number, hero:
|
|||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality, star: hero.star }, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality, star: hero.star }, funcs);
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.HERO_LV) {
|
else if (taskType == TASK_TYPE.HERO_LV) {
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { lv: hero.lv }, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, { lv: hero.lv, oldLv: args[0] }, funcs);
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.HERO_TRAIN) {
|
else if (taskType == TASK_TYPE.HERO_TRAIN) {
|
||||||
let dicHero = gameData.hero.get(hero.hid);
|
let dicHero = gameData.hero.get(hero.hid);
|
||||||
@@ -283,6 +283,7 @@ export async function checkTaskWithGoods(roleId: string, taskType: number, goods
|
|||||||
|
|
||||||
// 根据taskType判断有哪些任务需要check的
|
// 根据taskType判断有哪些任务需要check的
|
||||||
export async function checkTask(roleId: string, taskType: number, count: number, isInc: boolean, param: TaskParam, funcs?: number[]) {
|
export async function checkTask(roleId: string, taskType: number, count: number, isInc: boolean, param: TaskParam, funcs?: number[]) {
|
||||||
|
console.log('******checkTask', roleId, taskType, count, isInc, param, funcs)
|
||||||
let tasks = gameData.taskType.get(taskType) || [];
|
let tasks = gameData.taskType.get(taskType) || [];
|
||||||
let pushMessage = new Array<TaskListReturn>();
|
let pushMessage = new Array<TaskListReturn>();
|
||||||
let groups = new Map<string, { task0: DicTask, tasks: DicTask[] }>();
|
let groups = new Map<string, { task0: DicTask, tasks: DicTask[] }>();
|
||||||
@@ -343,7 +344,7 @@ export async function checkTaskRec(roleId: string, type: number, group: number,
|
|||||||
isMatch = taskParam[1] == param.quality && taskParam[2] == param.star;
|
isMatch = taskParam[1] == param.quality && taskParam[2] == param.star;
|
||||||
break;
|
break;
|
||||||
case TASK_TYPE.HERO_LV:
|
case TASK_TYPE.HERO_LV:
|
||||||
isMatch = taskParam[1] == param.lv;
|
isMatch = param.lv >= taskParam[1] && param.oldLv < taskParam[1];
|
||||||
break;
|
break;
|
||||||
case TASK_TYPE.HERO_TRAIN:
|
case TASK_TYPE.HERO_TRAIN:
|
||||||
isMatch = taskParam[1] == param.count;
|
isMatch = taskParam[1] == param.count;
|
||||||
@@ -457,11 +458,7 @@ function checkRecResult(rec: UserTaskRecType, id: number, condition: number) {
|
|||||||
if (!rec) return false;
|
if (!rec) return false;
|
||||||
if (rec.received && rec.received.includes(id)) return false; // 已领取,不再推送
|
if (rec.received && rec.received.includes(id)) return false; // 已领取,不再推送
|
||||||
|
|
||||||
if (rec.count >= condition) {
|
return rec
|
||||||
return rec
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -561,3 +558,21 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin
|
|||||||
}
|
}
|
||||||
return addCount;
|
return addCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建账号时临时获得可开启功能,主要用于check 主公升级任务
|
||||||
|
* 该函数不会存储funcs,如pvp开启会在entryHandler里面再查一次funcs,那时候正式开启
|
||||||
|
* @param dataFuncs
|
||||||
|
* @param lv
|
||||||
|
*/
|
||||||
|
export async function getCreateUserFuncs(dataFuncs: number[], lv: number) {
|
||||||
|
let addFuncs: number[] = [];
|
||||||
|
for(let [id, dicFunSwitch] of gameData.funcsSwitch) {
|
||||||
|
if (dataFuncs.includes(id)) continue; // 已开启过了
|
||||||
|
|
||||||
|
if (dicFunSwitch && lv >= dicFunSwitch.param) {
|
||||||
|
addFuncs.push(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return addFuncs;
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import { getAge } from '../pubUtils/timeUtil';
|
|||||||
import { shouldRefresh, resResult } from '../pubUtils/util';
|
import { shouldRefresh, resResult } from '../pubUtils/util';
|
||||||
import { authenticate } from '../pubUtils/httpUtil';
|
import { authenticate } from '../pubUtils/httpUtil';
|
||||||
import { createHeroes } from '../pubUtils/itemUtils';
|
import { createHeroes } from '../pubUtils/itemUtils';
|
||||||
import { checkTask } from 'app/pubUtils/taskUtil';
|
import { checkTask, getCreateUserFuncs } from 'app/pubUtils/taskUtil';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Service
|
* Test Service
|
||||||
@@ -302,6 +302,7 @@ export default class Auth extends Service {
|
|||||||
|
|
||||||
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 });
|
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 });
|
||||||
if (role) {
|
if (role) {
|
||||||
|
let funcs = await getCreateUserFuncs(role.funcs, role.lv);
|
||||||
let heroInfos = [];
|
let heroInfos = [];
|
||||||
for (let hid of DEFAULT_HEROES) {
|
for (let hid of DEFAULT_HEROES) {
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
@@ -314,7 +315,7 @@ export default class Auth extends Service {
|
|||||||
hid, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0
|
hid, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await createHeroes(roleId, role.roleName, serverId, heroInfos);
|
await createHeroes(roleId, role.roleName, serverId, heroInfos, funcs);
|
||||||
|
|
||||||
for (let { id, count } of DEFAULT_ITEMS) {
|
for (let { id, count } of DEFAULT_ITEMS) {
|
||||||
let dicGoods = gameData.goods.get(id);
|
let dicGoods = gameData.goods.get(id);
|
||||||
@@ -336,7 +337,7 @@ export default class Auth extends Service {
|
|||||||
await RoleModel.addCoin(roleId, DEFAULT_COIN);
|
await RoleModel.addCoin(roleId, DEFAULT_COIN);
|
||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTask(roleId, TASK_TYPE.ROLE_LV, role.lv, false, {});
|
await checkTask(roleId, TASK_TYPE.ROLE_LV, role.lv, false, {}, funcs);
|
||||||
|
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user