任务:修复任务无法达成bug
This commit is contained in:
@@ -75,7 +75,7 @@ export class GachaHandler {
|
||||
|
||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, activityId);
|
||||
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);
|
||||
|
||||
@@ -104,7 +104,7 @@ export class GachaHandler {
|
||||
}
|
||||
|
||||
let costNum = count;
|
||||
if(dicGacha.free.count > 0) {
|
||||
if(count == 1 && dicGacha.free.count > 0) { // 单抽的时候免费
|
||||
if(count > dicGacha.free.count - freeCount) {
|
||||
costNum = count - dicGacha.free.count + freeCount;
|
||||
freeCount = dicGacha.free.count;
|
||||
@@ -120,7 +120,7 @@ export class GachaHandler {
|
||||
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);
|
||||
// 更新数据
|
||||
point = Math.floor(count/RECRUIT.RECRUIT_BONUS);
|
||||
@@ -157,7 +157,7 @@ export class GachaHandler {
|
||||
for(let { hid } of hope) {
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -181,6 +181,7 @@ export class GachaHandler {
|
||||
const roleName: string = session.get('roleName');
|
||||
const sid: string = session.get('sid');
|
||||
const serverId: number = session.get('serverId');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
|
||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, 0);
|
||||
let { point, turntable } = userGacha;
|
||||
@@ -210,7 +211,7 @@ export class GachaHandler {
|
||||
for(let i = 0; i < count; i++) {
|
||||
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[] = [];
|
||||
for(let h of heroes) {
|
||||
let result = new GachaResult(contentId);
|
||||
|
||||
@@ -48,6 +48,7 @@ export class SevenDaysHandler {
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const roleName = session.get('roleName');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
|
||||
let playerData = await getPlayerGrowthData(activityId, serverId, roleId)
|
||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
@@ -82,7 +83,7 @@ export class SevenDaysHandler {
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
// createHero
|
||||
let hero = await createHero(roleId, roleName, sid, serverId, { hid });
|
||||
let hero = await createHero(roleId, roleName, sid, serverId, funcs, { hid });
|
||||
addHeros.push(hero);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +103,7 @@ export class SevenDaysHandler {
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const roleName = session.get('roleName');
|
||||
const funcs = session.get('funcs');
|
||||
|
||||
let playerData = await getPlayerGrowthData(activityId, serverId, roleId)
|
||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
@@ -137,7 +139,7 @@ export class SevenDaysHandler {
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
// 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) {
|
||||
addHeros.push(hero);
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ export class HeroHandler {
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
let serverId: number = session.get('serverId');
|
||||
let funcs: number[] = session.get('funcs');
|
||||
|
||||
let {hid} = msg;
|
||||
|
||||
@@ -139,7 +140,7 @@ export class HeroHandler {
|
||||
let costResult = await handleCost(roleId, sid, [{id: pieceId, count: pieceCount}]);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
// 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]);
|
||||
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);
|
||||
|
||||
// 任务
|
||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.HERO_LV, hero);
|
||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.HERO_LV, hero, [oldLv]);
|
||||
|
||||
const curHero = {
|
||||
hid, lv : hero.lv, exp : hero.exp
|
||||
@@ -426,6 +427,7 @@ export class HeroHandler {
|
||||
|
||||
//进阶
|
||||
async heroJobStageUp(msg: {hid:number}, session: BackendSession) {
|
||||
console.log(JSON.stringify([...gameData.jobClassMaxGrades]))
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let funcs: number[] = session.get('funcs');
|
||||
@@ -444,6 +446,7 @@ export class HeroHandler {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
let nextHeroJob = getJobByGradeAndClass(heroJob.job_class, heroJob.grade + 1);
|
||||
if(!nextHeroJob) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
//重算战力并下发
|
||||
let update = {
|
||||
|
||||
@@ -260,7 +260,7 @@ export async function handleComBtlProgress(teamStatus, robotHurtTimer: Map<strin
|
||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result}));
|
||||
|
||||
// 任务
|
||||
await checkTaskInComBattleEnd(roleIds, capId, quality);
|
||||
await checkTaskInComBattleEnd(roleIds.filter(roleId => {}), capId, quality);
|
||||
|
||||
teamMap.delete(teamCode);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export async function changeEquip(roleId: string, sid: string, equipA: EquipType
|
||||
if (!!hid) //需要卸下或者替换的武将
|
||||
heroB = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);//需要替换的武将
|
||||
|
||||
if (!!equipA) {//需要卸下的装备
|
||||
if (!!equipA) {//需要卸下的装备
|
||||
if (!!heroB) {
|
||||
let goodInfo = getGoodById(equipA.id);
|
||||
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);//替换给武将,并计算战力
|
||||
return res;
|
||||
} else {
|
||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
||||
return res;
|
||||
if(equipB) {
|
||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
||||
return res;
|
||||
}
|
||||
}
|
||||
} else if (!!heroB) {//从穿戴装备的武将上卸下装备
|
||||
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 checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [1]);
|
||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [1]);
|
||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [-1]);
|
||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [-1]);
|
||||
|
||||
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 checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [-1]);
|
||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [-1]);
|
||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [1]);
|
||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [1]);
|
||||
|
||||
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);
|
||||
}
|
||||
originalFriendCnt = incMyFrdCnt.friendCnt;
|
||||
role1 = incMyFrdCnt; role2 = incHisFrdCnt;
|
||||
role1.friendCnt = incMyFrdCnt.friendCnt;
|
||||
role2.friendCnt = incHisFrdCnt.friendCnt;
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ export async function switchOnFunc(roleId: string, type: number, param: number,
|
||||
*/
|
||||
export async function chackFunOpenWhenLogin(role: any, session: BackendSession|FrontendSession) {
|
||||
await switchOnFunc(role.roleId, FUNC_OPT_TYPE.LEVEL_UP, role.lv, session);
|
||||
|
||||
await checkResetTrain(role.roleId, role.serverId);
|
||||
await getUserGuildWithRefActive(role.roleId, '', true)
|
||||
}
|
||||
@@ -209,8 +209,10 @@ function getPoolByHope(hope: Hope[], qualtiy: number) {
|
||||
let hopeMap = new Map<number, Hope>();
|
||||
let hasGetHope: number[] = [];
|
||||
for(let h of hope) {
|
||||
hopeMap.set(h.id, h);
|
||||
if(h.hasGet) hasGetHope.push(h.id);
|
||||
if(h.hid > 0) {
|
||||
hopeMap.set(h.id, h);
|
||||
if(h.hasGet) hasGetHope.push(h.id);
|
||||
}
|
||||
}
|
||||
|
||||
let list = gameData.gachaHope.map(cur => {
|
||||
|
||||
@@ -312,7 +312,7 @@ export async function pushFigureUpdate(roleId: string, sid: string, figureInfo:
|
||||
* @param serverId
|
||||
* @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 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[] = [];
|
||||
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 });
|
||||
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 }
|
||||
}
|
||||
|
||||
export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam) {
|
||||
let result = await createHeroes(roleId, roleName, sid, serverId, [heroInfo]);
|
||||
export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[], heroInfo: CreateHeroParam) {
|
||||
let result = await createHeroes(roleId, roleName, sid, serverId, funcs, [heroInfo]);
|
||||
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) {
|
||||
console.log('********', roleIds, capId, quality)
|
||||
for (let roleId of roleIds) {
|
||||
if (roleId == capId && roleIds.length > 1) { // 招募队友
|
||||
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_SERIES = 2, // 连续登录
|
||||
ROLE_LV = 3, // 主公等级
|
||||
GASHA = 4, // 招募 暂无
|
||||
GASHA = 4, // 招募
|
||||
HERO_NUM = 5, // 武将数量
|
||||
HERO_STAR_UP = 6, // 升星次数
|
||||
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 });
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -190,9 +190,9 @@ export default class Role extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: 1 })
|
||||
loginCnt: number; // 登录次数
|
||||
@prop({ required: true, default: nowSeconds() })
|
||||
@prop({ required: true, default: nowSeconds })
|
||||
createTime: number; // 创建时间
|
||||
@prop({ required: true, default: nowSeconds() })
|
||||
@prop({ required: true, default: 0 })
|
||||
loginTime: number; // 更新 / 登录时间
|
||||
@prop({ required: true, default: 0 })
|
||||
quitTime: number; // 更新 / 登录时间
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { prop } from '@typegoose/typegoose';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
|
||||
// 活动数据
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { prop } from '@typegoose/typegoose';
|
||||
import { TASK_TYPE } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityGrowthModelType } from '../../db/ActivityGrowth';
|
||||
|
||||
@@ -45,7 +45,7 @@ arr.forEach(o => {
|
||||
o.ceAttr = parseCeAttr(o);
|
||||
dicJob.set(o.jobid, _.pick(o, Object.keys(DicJobKeys)));
|
||||
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});
|
||||
}
|
||||
jobClassAndgrades.set(o.job_class+'_'+o.grade,{unlockLevel:o.unlockLevel, jobid:o.jobid});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import { ABI_TYPE, COM_BTL_LV_RANGE } from '../consts';
|
||||
import { decodeIdCntArrayStr, getRandEelm } from './util';
|
||||
import { decodeIdCntArrayStr } from './util';
|
||||
import { IT_TYPE } from '../consts';
|
||||
|
||||
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 { EquipModel, RandSe, Holes } from './../db/Equip';
|
||||
import { BagInter, EquipInter } from './interface';
|
||||
@@ -222,12 +222,12 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = fals
|
||||
return figure
|
||||
}
|
||||
|
||||
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])
|
||||
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], funcs)
|
||||
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 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 m1 = await checkTask(roleId, TASK_TYPE.HERO_NUM, heroNum, true, {});
|
||||
let m2 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY, heroes);
|
||||
let m3 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, heroes);
|
||||
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes);
|
||||
let m1 = await checkTask(roleId, TASK_TYPE.HERO_NUM, heroNum, true, {}, funcs);
|
||||
let m2 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY, heroes, funcs);
|
||||
let m3 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, heroes, funcs);
|
||||
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes, funcs);
|
||||
let taskPushMessage = m1.concat(m2, m3, m4);
|
||||
//成长任务
|
||||
await accomplishTask(roleId, TASK_TYPE.HERO_NUM, heroNum)
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function checkTaskWithRole(roleId: string, taskType: number, role:
|
||||
let today = getTodayZeroPoint();
|
||||
if (today > role.loginTime) {
|
||||
if (today - role.loginTime > 24 * 60 * 60) {
|
||||
pushMessage = await checkTask(roleId, taskType, 0, false, {}, funcs);
|
||||
pushMessage = await checkTask(roleId, taskType, 1, false, {}, funcs);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
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) {
|
||||
let dicHero = gameData.hero.get(hero.hid);
|
||||
@@ -283,6 +283,7 @@ export async function checkTaskWithGoods(roleId: string, taskType: number, goods
|
||||
|
||||
// 根据taskType判断有哪些任务需要check的
|
||||
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 pushMessage = new Array<TaskListReturn>();
|
||||
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;
|
||||
break;
|
||||
case TASK_TYPE.HERO_LV:
|
||||
isMatch = taskParam[1] == param.lv;
|
||||
isMatch = param.lv >= taskParam[1] && param.oldLv < taskParam[1];
|
||||
break;
|
||||
case TASK_TYPE.HERO_TRAIN:
|
||||
isMatch = taskParam[1] == param.count;
|
||||
@@ -457,11 +458,7 @@ function checkRecResult(rec: UserTaskRecType, id: number, condition: number) {
|
||||
if (!rec) return false;
|
||||
if (rec.received && rec.received.includes(id)) return false; // 已领取,不再推送
|
||||
|
||||
if (rec.count >= condition) {
|
||||
return rec
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
return rec
|
||||
}
|
||||
|
||||
|
||||
@@ -561,3 +558,21 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin
|
||||
}
|
||||
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 { authenticate } from '../pubUtils/httpUtil';
|
||||
import { createHeroes } from '../pubUtils/itemUtils';
|
||||
import { checkTask } from 'app/pubUtils/taskUtil';
|
||||
import { checkTask, getCreateUserFuncs } from 'app/pubUtils/taskUtil';
|
||||
|
||||
/**
|
||||
* 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 });
|
||||
if (role) {
|
||||
let funcs = await getCreateUserFuncs(role.funcs, role.lv);
|
||||
let heroInfos = [];
|
||||
for (let hid of DEFAULT_HEROES) {
|
||||
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
|
||||
});
|
||||
}
|
||||
await createHeroes(roleId, role.roleName, serverId, heroInfos);
|
||||
await createHeroes(roleId, role.roleName, serverId, heroInfos, funcs);
|
||||
|
||||
for (let { id, count } of DEFAULT_ITEMS) {
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
@@ -336,7 +337,7 @@ export default class Auth extends Service {
|
||||
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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user