活动:成长活动统计任务,领取奖励接口
This commit is contained in:
@@ -2,6 +2,12 @@ import { Application, BackendSession } from 'pinus';
|
|||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { STATUS, } from '../../../consts';
|
import { STATUS, } from '../../../consts';
|
||||||
import { getPlayerGrowthData } from '../../../services/growthService';
|
import { getPlayerGrowthData } from '../../../services/growthService';
|
||||||
|
import { GrowthItem } from '../../../domain/activityField/growthField';
|
||||||
|
import { addItems, createHero } from '../../../services/rewardService';
|
||||||
|
import { HeroModel } from '../../../db/Hero';
|
||||||
|
import { gameData } from '../../../pubUtils/data';
|
||||||
|
import { ActivityModelType } from '../../../db/Activity';
|
||||||
|
import { ActivityGrowthModel } from '../../../db/ActivityGrowth';
|
||||||
|
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
@@ -22,10 +28,8 @@ export class SevenDaysHandler {
|
|||||||
const { activityId } = msg;
|
const { activityId } = msg;
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
// const funcs: number[] = session.get('funcs');
|
|
||||||
// const sid = session.get('sid');
|
|
||||||
|
|
||||||
let playerData = 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);
|
||||||
|
|
||||||
@@ -39,17 +43,54 @@ export class SevenDaysHandler {
|
|||||||
* @memberof SevenDaysHandler
|
* @memberof SevenDaysHandler
|
||||||
*/
|
*/
|
||||||
async getGrowthCellReward(msg: { activityId: number, dayIndex: number, cellIndex: number, type: number }, session: BackendSession) {
|
async getGrowthCellReward(msg: { activityId: number, dayIndex: number, cellIndex: number, type: number }, session: BackendSession) {
|
||||||
const { activityId } = msg;
|
const { activityId, dayIndex, cellIndex, type } = msg;
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
// const funcs: number[] = session.get('funcs');
|
const sid = session.get('sid');
|
||||||
// const sid = session.get('sid');
|
const roleName = session.get('roleName');
|
||||||
|
|
||||||
let playerData = 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);
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, playerData);
|
let growthItemData: GrowthItem = playerData.findGrowthItem(dayIndex, cellIndex, type);
|
||||||
|
if (!growthItemData) {
|
||||||
|
return resResult(STATUS.ACTIVITY_DATA_ERROR);
|
||||||
|
}
|
||||||
|
if (!growthItemData.isComplete()) {//未完成任务
|
||||||
|
return resResult(STATUS.ACTIVITY_TASK_UNCOMPLETED);
|
||||||
|
}
|
||||||
|
if (!growthItemData.canReceive()) {//已经领取过
|
||||||
|
return resResult(STATUS.ACTIVITY_REWARDED);
|
||||||
|
}
|
||||||
|
|
||||||
|
await ActivityGrowthModel.addCellRecord(activityId, roleId, dayIndex, cellIndex, type, 1);
|
||||||
|
let reward = growthItemData.goodReward();
|
||||||
|
let goods = await addItems(roleId, roleName, sid, reward);
|
||||||
|
let heroReward = growthItemData.heroReward();
|
||||||
|
let addHeros = [];
|
||||||
|
if (heroReward.length > 0) {
|
||||||
|
for (let heroParam of heroReward) {
|
||||||
|
// 检查是否存在武将
|
||||||
|
let hid = heroParam.id;
|
||||||
|
let count = heroParam.count;
|
||||||
|
let hasHero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
|
if (hasHero && count > 1) {//已经有武将
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 根据dic_hero 获得 1. 碎片id 2. 碎片数量 3. 初始武将星级 4. 初始品质
|
||||||
|
let dicHero = gameData.hero.get(hid);
|
||||||
|
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
|
let { pieceId, quality, initialStars: star, pieceCount, jobid: job, name: hName, initialSkin } = dicHero;
|
||||||
|
// createHero
|
||||||
|
let hero = await createHero(roleId, sid, serverId, {
|
||||||
|
roleId, serverId, roleName, hid, hName, star, quality, job, skins: [{ id: initialSkin, enable: true }]
|
||||||
|
});
|
||||||
|
addHeros.push(hero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resResult(STATUS.SUCCESS, { playerData, goods, addHeros });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,17 +100,55 @@ export class SevenDaysHandler {
|
|||||||
* @memberof SevenDaysHandler
|
* @memberof SevenDaysHandler
|
||||||
*/
|
*/
|
||||||
async getGrowthDayReward(msg: { activityId: number, dayIndex: number }, session: BackendSession) {
|
async getGrowthDayReward(msg: { activityId: number, dayIndex: number }, session: BackendSession) {
|
||||||
const { activityId } = msg;
|
const { activityId, dayIndex } = msg;
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
// const funcs: number[] = session.get('funcs');
|
const sid = session.get('sid');
|
||||||
// const sid = session.get('sid');
|
const roleName = session.get('roleName');
|
||||||
|
|
||||||
let playerData = 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);
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, playerData);
|
let dayItemData: GrowthItem = playerData.findDayItem(dayIndex);
|
||||||
|
if (!dayItemData) {
|
||||||
|
return resResult(STATUS.ACTIVITY_DATA_ERROR);
|
||||||
|
}
|
||||||
|
if (playerData.totalPoint - playerData.totalConsumePoint < dayItemData.consumePoint) {
|
||||||
|
return resResult(STATUS.ACTIVITY_NO_POINT);
|
||||||
|
}
|
||||||
|
if (dayItemData.getPointReward) {//已经领取过
|
||||||
|
return resResult(STATUS.ACTIVITY_REWARDED);
|
||||||
|
}
|
||||||
|
|
||||||
|
await ActivityGrowthModel.addDayRecord(activityId, roleId, dayIndex, 1);
|
||||||
|
|
||||||
|
let reward = dayItemData.goodReward();
|
||||||
|
let goods = await addItems(roleId, roleName, sid, reward);
|
||||||
|
let heroReward = dayItemData.heroReward();
|
||||||
|
let addHeros = [];
|
||||||
|
if (heroReward.length > 0) {
|
||||||
|
for (let heroParam of heroReward) {
|
||||||
|
// 检查是否存在武将
|
||||||
|
let hid = heroParam.id;
|
||||||
|
let count = heroParam.count;
|
||||||
|
let hasHero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
|
if (hasHero && count > 1) {//已经有武将
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 根据dic_hero 获得 1. 碎片id 2. 碎片数量 3. 初始武将星级 4. 初始品质
|
||||||
|
let dicHero = gameData.hero.get(hid);
|
||||||
|
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
|
let { pieceId, quality, initialStars: star, pieceCount, jobid: job, name: hName, initialSkin } = dicHero;
|
||||||
|
// createHero
|
||||||
|
let hero = await createHero(roleId, sid, serverId, {
|
||||||
|
roleId, serverId, roleName, hid, hName, star, quality, job, skins: [{ id: initialSkin, enable: true }]
|
||||||
|
});
|
||||||
|
addHeros.push(hero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resResult(STATUS.SUCCESS, { playerData, goods, addHeros });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { GuildTrainReportModel } from '../../../db/GuildTrainReport';
|
|||||||
import { DATA_NAME } from '../../../consts/dataName';
|
import { DATA_NAME } from '../../../consts/dataName';
|
||||||
import { pushGuildTrainSucMsg } from '../../../services/chatService';
|
import { pushGuildTrainSucMsg } from '../../../services/chatService';
|
||||||
import { checkTask } from '../../../services/taskService';
|
import { checkTask } from '../../../services/taskService';
|
||||||
|
import { accomplishTask } from '../../../pubUtils/taskUtil';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new GuildTrainHandler(app);
|
return new GuildTrainHandler(app);
|
||||||
@@ -268,6 +269,8 @@ export class GuildTrainHandler {
|
|||||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_TRAIN_SUCESS, 1, true, {});
|
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_TRAIN_SUCESS, 1, true, {});
|
||||||
}
|
}
|
||||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_TRAIN, 1, true, {});
|
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_TRAIN, 1, true, {});
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.GUILD_TRAIN, 1)
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, result);
|
return resResult(STATUS.SUCCESS, result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { handleCost } from "../../../services/rewardService";
|
|||||||
import { addActive } from "../../../services/guildService";
|
import { addActive } from "../../../services/guildService";
|
||||||
import { Rank } from "../../../services/rankService";
|
import { Rank } from "../../../services/rankService";
|
||||||
import { checkTask } from "../../../services/taskService";
|
import { checkTask } from "../../../services/taskService";
|
||||||
|
import { accomplishTask } from "../../../pubUtils/taskUtil";
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new CityActivityHandler(app);
|
return new CityActivityHandler(app);
|
||||||
@@ -292,6 +293,8 @@ export class CityActivityHandler {
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
|
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid })
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
isSuccess,
|
isSuccess,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { GuildActivityCityModel } from "../../../db/GuildActivityCity";
|
|||||||
import { Rank } from "../../../services/rankService";
|
import { Rank } from "../../../services/rankService";
|
||||||
import { getNextHourPoint } from "../../../pubUtils/timeUtil";
|
import { getNextHourPoint } from "../../../pubUtils/timeUtil";
|
||||||
import { checkTask } from "../../../services/taskService";
|
import { checkTask } from "../../../services/taskService";
|
||||||
|
import { accomplishTask } from "../../../pubUtils/taskUtil";
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new GateActivityHandler(app);
|
return new GateActivityHandler(app);
|
||||||
@@ -256,6 +257,8 @@ export class GateActivityHandler {
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
|
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid })
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
code,
|
code,
|
||||||
...statusResult,
|
...statusResult,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { UserGuildActivityRecModel } from "../../../db/UserGuildActivityRec";
|
|||||||
import { addActive } from "../../../services/guildService";
|
import { addActive } from "../../../services/guildService";
|
||||||
import { Rank } from "../../../services/rankService";
|
import { Rank } from "../../../services/rankService";
|
||||||
import { checkTask } from "../../../services/taskService";
|
import { checkTask } from "../../../services/taskService";
|
||||||
|
import { accomplishTask } from "../../../pubUtils/taskUtil";
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new RaceActivityHandler(app);
|
return new RaceActivityHandler(app);
|
||||||
@@ -177,6 +178,8 @@ export class RaceActivityHandler {
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
|
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid })
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
woodenHorse: guildActivityRec.woodenHorse,
|
woodenHorse: guildActivityRec.woodenHorse,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerC
|
|||||||
import { indexOf, findIndex } from 'underscore';
|
import { indexOf, findIndex } from 'underscore';
|
||||||
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
||||||
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs } from "../../../services/taskService";
|
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs } from "../../../services/taskService";
|
||||||
|
import { accomplishTask } from "../../../pubUtils/taskUtil";
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new EquipHandler(app);
|
return new EquipHandler(app);
|
||||||
@@ -98,6 +99,8 @@ export class EquipHandler {
|
|||||||
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||||
|
|
||||||
|
|
||||||
|
let changeData = [];//变化的等级数据
|
||||||
let { ePlace, lv: playerLv } = hero; // 装备栏
|
let { ePlace, lv: playerLv } = hero; // 装备栏
|
||||||
let oldLvs = ePlace.map(cur => cur.lv);
|
let oldLvs = ePlace.map(cur => cur.lv);
|
||||||
let strengthenArr = new Array<EPlace>();
|
let strengthenArr = new Array<EPlace>();
|
||||||
@@ -110,7 +113,13 @@ export class EquipHandler {
|
|||||||
return resResult(STATUS.ROLE_EQUIP_PLACE_NOT_ENOUGH);
|
return resResult(STATUS.ROLE_EQUIP_PLACE_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
let minLv = strengthenArr[0].lv; // 从最低装备的等级开始
|
let minLv = strengthenArr[0].lv; // 从最低装备的等级开始
|
||||||
for (let { lv } of strengthenArr) {
|
for (let { lv, id } of strengthenArr) {
|
||||||
|
changeData.push({
|
||||||
|
hid: hid,
|
||||||
|
id: id,
|
||||||
|
oldLv: lv,
|
||||||
|
lv: lv,
|
||||||
|
})
|
||||||
if (lv < minLv) minLv = lv;
|
if (lv < minLv) minLv = lv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +138,13 @@ export class EquipHandler {
|
|||||||
if (!cost) { flag = true; break; }
|
if (!cost) { flag = true; break; }
|
||||||
if (coin < costCoin + cost) { flag = true; break; }
|
if (coin < costCoin + cost) { flag = true; break; }
|
||||||
costCoin += cost;
|
costCoin += cost;
|
||||||
|
|
||||||
s.lv++;
|
s.lv++;
|
||||||
|
{//记录等级变化
|
||||||
|
let index = changeData.findIndex(obj => { return obj && obj.id == s.id })
|
||||||
|
if (index != -1) {
|
||||||
|
changeData[index].lv = s.lv;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flag) break;
|
if (flag) break;
|
||||||
@@ -152,6 +166,8 @@ export class EquipHandler {
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_STRENGTHEN, hero, oldLvs);
|
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_STRENGTHEN, hero, oldLvs);
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.EQUIP_STRENGTHEN, 1, changeData)
|
||||||
|
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid,
|
hid,
|
||||||
@@ -168,6 +184,7 @@ export class EquipHandler {
|
|||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
let funcs: number[] = session.get('funcs');
|
let funcs: number[] = session.get('funcs');
|
||||||
|
|
||||||
|
let changeData = [];//变化的等级数据
|
||||||
let { hid, lv: maxLv } = msg; // lv: 升到哪一级
|
let { hid, lv: maxLv } = msg; // lv: 升到哪一级
|
||||||
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||||
@@ -180,8 +197,15 @@ export class EquipHandler {
|
|||||||
return resResult(STATUS.ROLE_EQUIP_PLACE_NOT_ENOUGH);
|
return resResult(STATUS.ROLE_EQUIP_PLACE_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
let minLv = strengthenArr[0].lv; // 从最低装备的等级开始
|
let minLv = strengthenArr[0].lv; // 从最低装备的等级开始
|
||||||
for (let { lv } of strengthenArr) {
|
for (let { lv, id } of strengthenArr) {
|
||||||
|
changeData.push({
|
||||||
|
hid: hid,
|
||||||
|
id: id,
|
||||||
|
oldLv: lv,
|
||||||
|
lv: lv,
|
||||||
|
})
|
||||||
if (lv < minLv) minLv = lv;
|
if (lv < minLv) minLv = lv;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { coin } = await Role.findByRoleId(roleId);
|
let { coin } = await Role.findByRoleId(roleId);
|
||||||
@@ -197,6 +221,12 @@ export class EquipHandler {
|
|||||||
costCoin += cost;
|
costCoin += cost;
|
||||||
|
|
||||||
s.lv++;
|
s.lv++;
|
||||||
|
{//记录等级变化
|
||||||
|
let index = changeData.findIndex(obj => { return obj && obj.id == s.id })
|
||||||
|
if (index != -1) {
|
||||||
|
changeData[index].lv = s.lv;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,6 +247,8 @@ export class EquipHandler {
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_STRENGTHEN, hero, oldLvs);
|
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_STRENGTHEN, hero, oldLvs);
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.EQUIP_STRENGTHEN, 1, changeData)
|
||||||
|
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid,
|
hid,
|
||||||
@@ -554,6 +586,8 @@ export class EquipHandler {
|
|||||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
|
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
|
||||||
await checkTaskWithArgs(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_STAGE, [jewel, oldJewel]);
|
await checkTaskWithArgs(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_STAGE, [jewel, oldJewel]);
|
||||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
|
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.EQUIP_JEWEL_SUM, 1)
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||||
}
|
}
|
||||||
@@ -724,6 +758,8 @@ export class EquipHandler {
|
|||||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
|
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
|
||||||
await checkTaskWithArgs(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_STAGE, [jewel, oldJewel]);
|
await checkTaskWithArgs(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_STAGE, [jewel, oldJewel]);
|
||||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
|
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.EQUIP_JEWEL_SUM, 1)
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { checkBattleHeroesByHid } from '../../../services/normalBattleService';
|
|||||||
import { Rank } from '../../../services/rankService';
|
import { Rank } from '../../../services/rankService';
|
||||||
import { updateUserInfo } from '../../../services/redisService';
|
import { updateUserInfo } from '../../../services/redisService';
|
||||||
import { checkTaskWithHero, checkTask, checkTaskWithArgs } from '../../../services/taskService';
|
import { checkTaskWithHero, checkTask, checkTaskWithArgs } from '../../../services/taskService';
|
||||||
|
import { accomplishTask } from '../../../pubUtils/taskUtil';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new RoleHandler(app);
|
return new RoleHandler(app);
|
||||||
@@ -104,6 +105,8 @@ export class RoleHandler {
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTask(roleId, sid, funcs, TASK_TYPE.ROLE_TITLE, 1, false, { title });
|
await checkTask(roleId, sid, funcs, TASK_TYPE.ROLE_TITLE, 1, false, { title });
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.ROLE_TITLE, update.title)
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { roleId, title: role.title });
|
return resResult(STATUS.SUCCESS, { roleId, title: role.title });
|
||||||
}
|
}
|
||||||
@@ -272,6 +275,10 @@ export class RoleHandler {
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTaskWithArgs(roleId, sid, funcs, TASK_TYPE.ROLE_SCHOOL_UNLOCK, [hid, preHid]);
|
await checkTaskWithArgs(roleId, sid, funcs, TASK_TYPE.ROLE_SCHOOL_UNLOCK, [hid, preHid]);
|
||||||
|
if (hid > 0) {
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.ROLE_SCHOOL_PUT_HERO, 1)
|
||||||
|
}
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
schoolId, positionId, hid, preHid, isOpen
|
schoolId, positionId, hid, preHid, isOpen
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ActivityModel, ActivityModelType } from '../db/Activity';
|
import { ActivityModel, ActivityModelType } from '../db/Activity';
|
||||||
import { ActivityGrowthModel, ActivityGrowthModelType } from '../db/ActivityGrowth';
|
import { ActivityGrowthModel, ActivityGrowthModelType } from '../db/ActivityGrowth';
|
||||||
import { GrowthData } from '../domain/activityField/growthField';
|
import { GrowthData, GrowthItem } from '../domain/activityField/growthField';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取活动数据
|
* 获取活动数据
|
||||||
@@ -30,8 +30,7 @@ export async function getPlayerGrowthData(activityId: number, serverId: number,
|
|||||||
let playerData = new GrowthData(activityData);
|
let playerData = new GrowthData(activityData);
|
||||||
playerData.setPlayerRecords(playerRecords);
|
playerData.setPlayerRecords(playerRecords);
|
||||||
|
|
||||||
return { data: playerData };
|
return playerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { DATA_NAME } from '../consts/dataName';
|
|||||||
import { addRoleToGuildChannel } from "./chatService";
|
import { addRoleToGuildChannel } from "./chatService";
|
||||||
import { Rank } from "./rankService";
|
import { Rank } from "./rankService";
|
||||||
import { checkTask } from "./taskService";
|
import { checkTask } from "./taskService";
|
||||||
|
import { accomplishTask } from "../pubUtils/taskUtil";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 检查该玩家是否有权限做操作
|
* @description 检查该玩家是否有权限做操作
|
||||||
@@ -91,6 +92,9 @@ export async function joinGuild(code: string, guildName: string, lv: number, rol
|
|||||||
await addRoleToGuildChannel(roleId, sid, code);
|
await addRoleToGuildChannel(roleId, sid, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//成长任务-加入军团
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.GUILD_JOIN, 1);
|
||||||
|
|
||||||
session.set('guildCode', code);
|
session.set('guildCode', code);
|
||||||
session.push('guildCode', () => { });
|
session.push('guildCode', () => { });
|
||||||
return { status: 0, guild, userGuild, roleName: role.roleName, memberCnt: guild.memberCnt, guildCe: guild.guildCe }
|
return { status: 0, guild, userGuild, roleName: role.roleName, memberCnt: guild.memberCnt, guildCe: guild.guildCe }
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { BackendSession } from 'pinus';
|
|||||||
import { REDIS_KEY } from '../consts';
|
import { REDIS_KEY } from '../consts';
|
||||||
import { Rank } from './rankService';
|
import { Rank } from './rankService';
|
||||||
import { checkTask } from './taskService';
|
import { checkTask } from './taskService';
|
||||||
|
import { accomplishTask } from '../pubUtils/taskUtil';
|
||||||
|
|
||||||
export async function roleLevelup(roleId: string, kingExp: number, session: BackendSession) {
|
export async function roleLevelup(roleId: string, kingExp: number, session: BackendSession) {
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
@@ -33,6 +34,9 @@ export async function roleLevelup(roleId: string, kingExp: number, session: Back
|
|||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
await checkTask(roleId, session.get('sid'), session.get('funcs'), TASK_TYPE.ROLE_LV, newLv, false, {});
|
await checkTask(roleId, session.get('sid'), session.get('funcs'), TASK_TYPE.ROLE_LV, newLv, false, {});
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.ROLE_LV, newLv);
|
||||||
|
|
||||||
}
|
}
|
||||||
let actordata = [];
|
let actordata = [];
|
||||||
for (let i = lv; i <= newLv; i++) {
|
for (let i = lv; i <= newLv; i++) {
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ export async function checkTaskInBattleEnd(roleId: string, sid: string, funcs: n
|
|||||||
await checkTaskWithWar(roleId, sid, funcs, TASK_TYPE.BATTLE_TOWER, battleId, heroes, 1, star);
|
await checkTaskWithWar(roleId, sid, funcs, TASK_TYPE.BATTLE_TOWER, battleId, heroes, 1, star);
|
||||||
await checkTaskWithWar(roleId, sid, funcs, TASK_TYPE.BATTLE_VESTIGE, battleId, heroes, 1, star);
|
await checkTaskWithWar(roleId, sid, funcs, TASK_TYPE.BATTLE_VESTIGE, battleId, heroes, 1, star);
|
||||||
await checkTaskWithWar(roleId, sid, funcs, TASK_TYPE.BATTLE_EXPEDITION, battleId, heroes, 1, star);
|
await checkTaskWithWar(roleId, sid, funcs, TASK_TYPE.BATTLE_EXPEDITION, battleId, heroes, 1, star);
|
||||||
|
//成长任务
|
||||||
|
await taskUtil.accomplishTask(roleId, TASK_TYPE.BATTLE_MAIN, 1, { warId: battleId })
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,4 +6,5 @@
|
|||||||
|
|
||||||
export enum ACTIVITY_TYPE {
|
export enum ACTIVITY_TYPE {
|
||||||
SEVEN_DAYS = 1, // 七天乐活动
|
SEVEN_DAYS = 1, // 七天乐活动
|
||||||
|
TASK_GROWTH = 2, // 成长任务活动
|
||||||
}
|
}
|
||||||
@@ -653,6 +653,7 @@ export enum TASK_TYPE {
|
|||||||
GUILD_BOSS = 69, // 军团演武台挑战
|
GUILD_BOSS = 69, // 军团演武台挑战
|
||||||
GUILD_TRAIN = 70, // 挑战练兵场
|
GUILD_TRAIN = 70, // 挑战练兵场
|
||||||
GUILD_ACTIVITY = 71, // 军团活动
|
GUILD_ACTIVITY = 71, // 军团活动
|
||||||
|
GUILD_JOIN = 72, // 加入军团
|
||||||
}
|
}
|
||||||
|
|
||||||
// 卡池类型
|
// 卡池类型
|
||||||
|
|||||||
@@ -329,6 +329,10 @@ export const STATUS = {
|
|||||||
UPDATE_PRIVATE_MSG_READ_TIME_ERR: { code: 40001, simStr: '更新私聊阅读时间失败' },
|
UPDATE_PRIVATE_MSG_READ_TIME_ERR: { code: 40001, simStr: '更新私聊阅读时间失败' },
|
||||||
// 运营模块相关状态 50000 - 59999
|
// 运营模块相关状态 50000 - 59999
|
||||||
ACTIVITY_MISSING: { code: 50000, simStr: '活动丢失' },
|
ACTIVITY_MISSING: { code: 50000, simStr: '活动丢失' },
|
||||||
|
ACTIVITY_DATA_ERROR: { code: 50001, simStr: '数据错误' },
|
||||||
|
ACTIVITY_TASK_UNCOMPLETED: { code: 50002, simStr: '任务还未完成' },
|
||||||
|
ACTIVITY_NO_POINT: { code: 50003, simStr: '奖章不足' },
|
||||||
|
ACTIVITY_REWARDED: { code: 50004, simStr: '已经领取过' },
|
||||||
// GM后台相关状态 60000 - 69999
|
// GM后台相关状态 60000 - 69999
|
||||||
GM_ERR_PASSWORD: { code: 60001, simStr: '账号或密码错误' },
|
GM_ERR_PASSWORD: { code: 60001, simStr: '账号或密码错误' },
|
||||||
GM_MISS_API: { code: 60002, simStr: '未找到该接口' },
|
GM_MISS_API: { code: 60002, simStr: '未找到该接口' },
|
||||||
|
|||||||
@@ -18,6 +18,18 @@ export default class Activity extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
data: string; // 活动表中的数据
|
data: string; // 活动表中的数据
|
||||||
|
|
||||||
|
//根据活动类型查询开启的活动数据
|
||||||
|
public static async findOpenActivityByType(type: number, date: Date, lean = true) {
|
||||||
|
let result: ActivityModelType[] = await ActivityModel.find({ type, beginTime: { $lte: date }, endTime: { $gte: date } }).lean(lean);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据活动类型查询活动数据
|
||||||
|
public static async findActivityByType(type: number, lean = true) {
|
||||||
|
let result: ActivityModelType[] = await ActivityModel.find({ type }).lean(lean);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//根据活动id查询活动数据
|
//根据活动id查询活动数据
|
||||||
public static async findActivity(acvitityId: number, lean = true) {
|
public static async findActivity(acvitityId: number, lean = true) {
|
||||||
let result: ActivityModelType = await ActivityModel.findOne({ acvitityId }).lean(lean);
|
let result: ActivityModelType = await ActivityModel.findOne({ acvitityId }).lean(lean);
|
||||||
|
|||||||
@@ -20,12 +20,39 @@ export default class ActivityGrowth extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
totalCount: number; // 累计达成次数
|
totalCount: number; // 累计达成次数
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
count: number; // 领取次数
|
receiveRewardCount: number; // 领取奖励次数
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
addPointCount: number; // 获得奖章个数
|
addPointCount: number; // 获得奖章个数
|
||||||
@prop({ required: true, default: false })
|
@prop({ required: true, default: false })
|
||||||
pointReward: boolean; // 是否兑换领取奖章奖励
|
getPointReward: boolean; // 是否兑换领取奖章奖励
|
||||||
|
|
||||||
|
//任务领取记录
|
||||||
|
public static async addCellRecord(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||||
|
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||||
|
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//当日奖章领取记录
|
||||||
|
public static async addDayRecord(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||||
|
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex },
|
||||||
|
{ $set: { getPointReward: true } }, { upsert: true, new: true }).lean(lean);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据活动统计完成任务次数
|
||||||
|
public static async setTaskCount(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||||
|
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||||
|
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据活动统计完成任务次数
|
||||||
|
public static async addTaskCount(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||||
|
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||||
|
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//根据活动id查询活动数据
|
//根据活动id查询活动数据
|
||||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||||
|
|||||||
@@ -1,23 +1,112 @@
|
|||||||
import { prop } from '@typegoose/typegoose';
|
import { prop } from '@typegoose/typegoose';
|
||||||
|
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';
|
||||||
|
import { RewardInter } from '../../pubUtils/interface';
|
||||||
|
import { parseGoodStrWithType, splitString } from '../../pubUtils/util';
|
||||||
import { ActivityBase } from './activityField';
|
import { ActivityBase } from './activityField';
|
||||||
|
|
||||||
|
|
||||||
// 每日配置数据
|
// 每日配置数据
|
||||||
export class GrowthItem {
|
export class GrowthItem {
|
||||||
dayIndex: number = 0;
|
dayIndex: number; // 第几天,从1开始
|
||||||
cellIndex: number = 0;
|
cellIndex: number; // 当天第几行,从1开始
|
||||||
count: number = 0;
|
name: string; // 任务名称
|
||||||
total: number = 0;
|
taskType: number; // 任务类型 dic_zyz_taskType.json
|
||||||
isReceive: boolean = false;
|
taskParam: string; //任务数据 dic_zyz_taskType.json
|
||||||
|
taskParamArray: Array<number>; //任务数据 dic_zyz_taskType.json
|
||||||
|
point: number; // 任务达成获得的奖章数量,只在当前活动中有用,虚拟
|
||||||
|
reward: string; // 任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||||
|
consumePoint: number; // 奖章兑换奖品,需要消耗的奖章个数
|
||||||
|
pointReward: string; // 奖章兑换奖品,奖励内容,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||||
|
|
||||||
constructor(dayIndex: number, cellIndex: number, count: number, total: number, isReceive: boolean) {
|
totalCount: number = 0; //完成任务累计次数
|
||||||
this.dayIndex = dayIndex;//第几天奖励
|
receiveRewardCount: number = 0; //领取奖励次数
|
||||||
this.cellIndex = cellIndex;//某天第几个奖励
|
addPointCount: number = 0; // 获得奖章个数
|
||||||
this.count = count;//已经领取奖励的次数
|
getPointReward: boolean = false; // 是否兑换领取奖章奖励
|
||||||
this.total = total;//总共可领取奖励次数
|
|
||||||
this.isReceive = isReceive;//是否领取
|
constructor(data: any) {
|
||||||
|
this.dayIndex = data.dayIndex;
|
||||||
|
this.cellIndex = data.cellIndex;
|
||||||
|
this.name = data.name;
|
||||||
|
this.taskType = data.taskType;
|
||||||
|
this.taskParam = data.taskParam;
|
||||||
|
this.point = data.point;
|
||||||
|
this.reward = data.reward;
|
||||||
|
this.consumePoint = data.consumePoint;
|
||||||
|
this.pointReward = data.pointReward;
|
||||||
|
|
||||||
|
this.taskParamArray = splitString(data.taskParam, '&')
|
||||||
|
}
|
||||||
|
|
||||||
|
public heroReward(): RewardInter[] {
|
||||||
|
let rewardArray = [];
|
||||||
|
let rewardData = this.reward.split('|').filter(obj => { return obj && obj != '' });
|
||||||
|
for (let objStr of rewardData) {
|
||||||
|
let reward = parseGoodStrWithType(objStr);
|
||||||
|
rewardArray.push(reward);
|
||||||
|
}
|
||||||
|
return rewardArray.find(obj => { return obj && obj.type == 1 })
|
||||||
|
}
|
||||||
|
|
||||||
|
public goodReward(): RewardInter[] {
|
||||||
|
let rewardArray = [];
|
||||||
|
let rewardData = this.reward.split('|').filter(obj => { return obj && obj != '' });
|
||||||
|
for (let objStr of rewardData) {
|
||||||
|
let reward = parseGoodStrWithType(objStr);
|
||||||
|
rewardArray.push(reward);
|
||||||
|
}
|
||||||
|
return rewardArray.find(obj => { return obj && obj.type == 2 })
|
||||||
|
}
|
||||||
|
|
||||||
|
public canReceive(): boolean {
|
||||||
|
return this.receiveRewardCount != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public isComplete(): boolean {
|
||||||
|
let complete = false;
|
||||||
|
switch (this.taskType) {
|
||||||
|
case TASK_TYPE.ROLE_LV:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.GUILD_JOIN:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.LOGIN_SUM:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.HERO_NUM:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.ROLE_TITLE:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.GASHA:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.EQUIP_STRENGTHEN:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.BATTLE_MAIN:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.EQUIP_JEWEL_SUM:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.GUILD_TRAIN:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.ROLE_SCHOOL_PUT_HERO:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.GUILD_ACTIVITY:
|
||||||
|
complete = this.totalCount >= this.taskParamArray[0];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
complete = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return complete;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,13 +114,41 @@ export class GrowthItem {
|
|||||||
// 成长活动数据
|
// 成长活动数据
|
||||||
export class GrowthData extends ActivityBase {
|
export class GrowthData extends ActivityBase {
|
||||||
list: Array<GrowthItem> = [];
|
list: Array<GrowthItem> = [];
|
||||||
|
totalPoint: number = 0;//获得奖章总数
|
||||||
|
totalConsumePoint: number = 0;//消耗奖章总数
|
||||||
|
|
||||||
|
//第几天的奖章兑换
|
||||||
|
public findDayItem(dayIndex: number) {
|
||||||
|
let index = this.list.findIndex(obj => { return obj && obj.dayIndex == dayIndex && obj.cellIndex == 1 })
|
||||||
|
return (index != -1) ? this.list[index] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public findGrowthItem(dayIndex: number, cellIndex: number, type: number) {
|
||||||
|
let index = this.list.findIndex(obj => { return obj && obj.dayIndex == dayIndex && obj.cellIndex == cellIndex && obj.taskType == type })
|
||||||
|
return (index != -1) ? this.list[index] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public findTaskByType(type: TASK_TYPE) {
|
||||||
|
return this.list.filter(obj => {
|
||||||
|
return obj && obj.taskType == type;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
//解析玩家领取记录
|
//解析玩家领取记录
|
||||||
public setPlayerRecords(data: ActivityGrowthModelType[]) {
|
public setPlayerRecords(data: ActivityGrowthModelType[]) {
|
||||||
|
this.totalPoint = 0;
|
||||||
|
this.totalConsumePoint = 0;
|
||||||
for (let obj of this.list) {
|
for (let obj of this.list) {
|
||||||
let index = data.findIndex(record => { return obj.dayIndex == record.dayIndex && obj.cellIndex == record.cellIndex })
|
let index = data.findIndex(record => { return obj.dayIndex == record.dayIndex && obj.cellIndex == record.cellIndex })
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
obj.count = data[index].count;
|
obj.totalCount = data[index].totalCount;
|
||||||
|
obj.receiveRewardCount = data[index].receiveRewardCount;
|
||||||
|
obj.addPointCount = data[index].addPointCount;
|
||||||
|
obj.getPointReward = data[index].getPointReward;
|
||||||
|
this.totalPoint += data[index].addPointCount;
|
||||||
|
if (data[index].getPointReward) {
|
||||||
|
this.totalConsumePoint += data[index].addPointCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +156,7 @@ export class GrowthData extends ActivityBase {
|
|||||||
public initData(data: string) {
|
public initData(data: string) {
|
||||||
let arr = JSON.parse(data);
|
let arr = JSON.parse(data);
|
||||||
for (let obj of arr) {
|
for (let obj of arr) {
|
||||||
this.list.push(new GrowthItem(obj.dayIndex, obj.cellIndex, obj.count, 0, false));
|
this.list.push(new GrowthItem(obj))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { RoleModel, RoleType } from '../db/Role';
|
|||||||
import { Figure } from '../domain/dbGeneral';
|
import { Figure } from '../domain/dbGeneral';
|
||||||
import { getBeforeDaySeconds, nowSeconds } from './timeUtil';
|
import { getBeforeDaySeconds, nowSeconds } from './timeUtil';
|
||||||
import { calPlayerCeAndSave, reCalAllHeroCe } from './playerCe';
|
import { calPlayerCeAndSave, reCalAllHeroCe } from './playerCe';
|
||||||
import { checkTask, checkTaskWithHeroes, checkTaskWithEquip } from './taskUtil';
|
import { checkTask, checkTaskWithHeroes, checkTaskWithEquip, accomplishTask } from './taskUtil';
|
||||||
|
|
||||||
export async function addSkins(roleId: string, id: number) {
|
export async function addSkins(roleId: string, id: number) {
|
||||||
let skinInfo = gameData.fashion.get(id);
|
let skinInfo = gameData.fashion.get(id);
|
||||||
@@ -254,5 +254,7 @@ export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
|
|||||||
let m3 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, heroes);
|
let m3 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, heroes);
|
||||||
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes);
|
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes);
|
||||||
let taskPushMessage = m1.concat(m2, m3, m4);
|
let taskPushMessage = m1.concat(m2, m3, m4);
|
||||||
|
//成长任务
|
||||||
|
await accomplishTask(roleId, TASK_TYPE.HERO_NUM, heroNum)
|
||||||
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage }
|
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage }
|
||||||
}
|
}
|
||||||
+137
-64
@@ -8,6 +8,11 @@ import { getTodayZeroPoint } from './timeUtil';
|
|||||||
import { HeroType } from '../db/Hero';
|
import { HeroType } from '../db/Hero';
|
||||||
import { EquipType, EquipModel } from '../db/Equip';
|
import { EquipType, EquipModel } from '../db/Equip';
|
||||||
import { ItemInter } from './interface';
|
import { ItemInter } from './interface';
|
||||||
|
import { GrowthData } from '../domain/activityField/growthField';
|
||||||
|
import { splitString } from './util';
|
||||||
|
import { ActivityModel, ActivityModelType } from '../db/Activity';
|
||||||
|
import { ACTIVITY_TYPE } from '../consts/constModules/activityConst';
|
||||||
|
import { ActivityGrowthModel } from '../db/ActivityGrowth';
|
||||||
|
|
||||||
export async function checkTaskWithRoles(taskType: number, roles: RoleType[], funcs?: number[]) {
|
export async function checkTaskWithRoles(taskType: number, roles: RoleType[], funcs?: number[]) {
|
||||||
let pushMessage = new Array<TaskListReturn>();
|
let pushMessage = new Array<TaskListReturn>();
|
||||||
@@ -23,15 +28,15 @@ export async function checkTaskWithRoles(taskType: number, roles: RoleType[], fu
|
|||||||
export async function checkTaskWithRole(roleId: string, taskType: number, role: RoleType, funcs?: number[]) {
|
export async function checkTaskWithRole(roleId: string, taskType: number, role: RoleType, funcs?: number[]) {
|
||||||
let pushMessage = new Array<TaskListReturn>();
|
let pushMessage = new Array<TaskListReturn>();
|
||||||
|
|
||||||
if(taskType == TASK_TYPE.LOGIN_SUM)
|
if (taskType == TASK_TYPE.LOGIN_SUM) {
|
||||||
{
|
|
||||||
let today = getTodayZeroPoint();
|
let today = getTodayZeroPoint();
|
||||||
if (today > role.loginTime) {
|
if (today > role.loginTime) {
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
||||||
|
//成长任务-累计登录游戏天数
|
||||||
|
await accomplishTask(roleId, taskType, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.LOGIN_SERIES)
|
else if (taskType == TASK_TYPE.LOGIN_SERIES) {
|
||||||
{
|
|
||||||
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) {
|
||||||
@@ -41,8 +46,7 @@ export async function checkTaskWithRole(roleId: string, taskType: number, role:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.FRIEND_NUM)
|
else if (taskType == TASK_TYPE.FRIEND_NUM) {
|
||||||
{
|
|
||||||
let { friendCnt } = role;
|
let { friendCnt } = role;
|
||||||
pushMessage = await checkTask(roleId, taskType, friendCnt, false, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, friendCnt, false, {}, funcs);
|
||||||
}
|
}
|
||||||
@@ -62,63 +66,53 @@ export async function checkTaskWithHeroes(roleId: string, taskType: number, hero
|
|||||||
|
|
||||||
export async function checkTaskWithHero(roleId: string, taskType: number, hero: HeroType, args: number[] = [], funcs?: number[]) {
|
export async function checkTaskWithHero(roleId: string, taskType: number, hero: HeroType, args: number[] = [], funcs?: number[]) {
|
||||||
let pushMessage = new Array<TaskListReturn>();
|
let pushMessage = new Array<TaskListReturn>();
|
||||||
if(taskType == TASK_TYPE.HERO_STAR_UP)
|
if (taskType == TASK_TYPE.HERO_STAR_UP) {
|
||||||
{
|
|
||||||
let dicHero = gameData.hero.get(hero.hid);
|
let dicHero = gameData.hero.get(hero.hid);
|
||||||
let starUp = hero.star - dicHero.initialStars;
|
let starUp = hero.star - dicHero.initialStars;
|
||||||
if (hero.colorStar > 1) starUp += hero.colorStar - 1;
|
if (hero.colorStar > 1) starUp += hero.colorStar - 1;
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { star: starUp }, funcs)
|
pushMessage = await checkTask(roleId, taskType, 1, true, { star: starUp }, funcs)
|
||||||
}
|
}
|
||||||
else if(taskType == TASK_TYPE.HERO_QUALITY)
|
else if (taskType == TASK_TYPE.HERO_QUALITY) {
|
||||||
{
|
|
||||||
let dicHero = gameData.hero.get(hero.hid);
|
let dicHero = gameData.hero.get(hero.hid);
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality }, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality }, funcs);
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.HERO_QUALITY_STAR_UP)
|
else if (taskType == TASK_TYPE.HERO_QUALITY_STAR_UP) {
|
||||||
{
|
|
||||||
let dicHero = gameData.hero.get(hero.hid);
|
let dicHero = gameData.hero.get(hero.hid);
|
||||||
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 }, 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);
|
||||||
let initGrage = gameData.job.get(dicHero.jobid).grade;
|
let initGrage = gameData.job.get(dicHero.jobid).grade;
|
||||||
let curGrade = gameData.job.get(hero.job).grade;
|
let curGrade = gameData.job.get(hero.job).grade;
|
||||||
let count = (curGrade - initGrage) * (ABI_STAGE.END - ABI_STAGE.START) + (hero.jobStage - ABI_STAGE.START); // 训练次数
|
let count = (curGrade - initGrage) * (ABI_STAGE.END - ABI_STAGE.START) + (hero.jobStage - ABI_STAGE.START); // 训练次数
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { count }, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, { count }, funcs);
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.HERO_QUALITY_UP)
|
else if (taskType == TASK_TYPE.HERO_QUALITY_UP) {
|
||||||
{
|
|
||||||
let dicHero = gameData.hero.get(hero.hid);
|
let dicHero = gameData.hero.get(hero.hid);
|
||||||
if (hero.quality - dicHero.quality == 1) { // 每个武将升品算一次
|
if (hero.quality - dicHero.quality == 1) { // 每个武将升品算一次
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.HERO_STAGE_UP)
|
else if (taskType == TASK_TYPE.HERO_STAGE_UP) {
|
||||||
{
|
|
||||||
let dicHero = gameData.hero.get(hero.hid);
|
let dicHero = gameData.hero.get(hero.hid);
|
||||||
let initGrage = gameData.job.get(dicHero.jobid).grade;
|
let initGrage = gameData.job.get(dicHero.jobid).grade;
|
||||||
let curGrade = gameData.job.get(hero.job).grade;
|
let curGrade = gameData.job.get(hero.job).grade;
|
||||||
let count = curGrade - initGrage; // 进阶次数
|
let count = curGrade - initGrage; // 进阶次数
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { count }, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, { count }, funcs);
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.HERO_FAVOUR_LV)
|
else if (taskType == TASK_TYPE.HERO_FAVOUR_LV) {
|
||||||
{
|
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { favourLv: hero.favourLv }, funcs)
|
pushMessage = await checkTask(roleId, taskType, 1, true, { favourLv: hero.favourLv }, funcs)
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.EQUIP_BY_HERO)
|
else if (taskType == TASK_TYPE.EQUIP_BY_HERO) {
|
||||||
{
|
|
||||||
// arg[0] 1:穿上 -1:脱下
|
// arg[0] 1:穿上 -1:脱下
|
||||||
let { ePlace } = hero;
|
let { ePlace } = hero;
|
||||||
let count = ePlace.filter(cur => cur.equip).length;
|
let count = ePlace.filter(cur => cur.equip).length;
|
||||||
pushMessage = await checkTask(roleId, taskType, args[0], true, { count, isPutOn: args[0] }, funcs);
|
pushMessage = await checkTask(roleId, taskType, args[0], true, { count, isPutOn: args[0] }, funcs);
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.EQUIP_STRENGTHEN)
|
else if (taskType == TASK_TYPE.EQUIP_STRENGTHEN) {
|
||||||
{
|
|
||||||
// args: 依次为原先的装备的强化等级
|
// args: 依次为原先的装备的强化等级
|
||||||
let { ePlace } = hero;
|
let { ePlace } = hero;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
@@ -134,14 +128,12 @@ export async function checkTaskWithHero(roleId: string, taskType: number, hero:
|
|||||||
|
|
||||||
export async function checkTaskWithEquip(roleId: string, taskType: number, equip: EquipType, args: number[] = [], funcs?: number[]) {
|
export async function checkTaskWithEquip(roleId: string, taskType: number, equip: EquipType, args: number[] = [], funcs?: number[]) {
|
||||||
let pushMessage = new Array<TaskListReturn>();
|
let pushMessage = new Array<TaskListReturn>();
|
||||||
if(taskType == TASK_TYPE.EQUIP_QUALITY)
|
if (taskType == TASK_TYPE.EQUIP_QUALITY) {
|
||||||
{
|
|
||||||
// args[0] 1:装上 -1:脱下
|
// args[0] 1:装上 -1:脱下
|
||||||
let dicGood = gameData.goods.get(equip.id);
|
let dicGood = gameData.goods.get(equip.id);
|
||||||
pushMessage = await checkTask(roleId, taskType, args[0], true, { quality: dicGood.quality }, funcs)
|
pushMessage = await checkTask(roleId, taskType, args[0], true, { quality: dicGood.quality }, funcs)
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.EQUIP_JEWEL)
|
else if (taskType == TASK_TYPE.EQUIP_JEWEL) {
|
||||||
{
|
|
||||||
// args[0] 原来镶嵌了多少宝石
|
// args[0] 原来镶嵌了多少宝石
|
||||||
let { holes } = equip;
|
let { holes } = equip;
|
||||||
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
|
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
|
||||||
@@ -151,15 +143,13 @@ export async function checkTaskWithEquip(roleId: string, taskType: number, equip
|
|||||||
pushMessage = await checkTask(roleId, taskType, -1, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, -1, true, {}, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.EQUIP_COMPOSE_SUIT)
|
else if (taskType == TASK_TYPE.EQUIP_COMPOSE_SUIT) {
|
||||||
{
|
|
||||||
let dicGood = gameData.goods.get(equip.id);
|
let dicGood = gameData.goods.get(equip.id);
|
||||||
if (dicGood.suitId) {
|
if (dicGood.suitId) {
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.EQUIP_SUIT)
|
else if (taskType == TASK_TYPE.EQUIP_SUIT) {
|
||||||
{
|
|
||||||
let dicGood = gameData.goods.get(equip.id);
|
let dicGood = gameData.goods.get(equip.id);
|
||||||
if (dicGood.suitId) {
|
if (dicGood.suitId) {
|
||||||
let suit = gameData.suit.get(dicGood.suitId);
|
let suit = gameData.suit.get(dicGood.suitId);
|
||||||
@@ -183,8 +173,7 @@ export async function checkTaskWithEquip(roleId: string, taskType: number, equip
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.EQUIP_JEWEL_SUM)
|
else if (taskType == TASK_TYPE.EQUIP_JEWEL_SUM) {
|
||||||
{
|
|
||||||
// args[0] 原来镶嵌了多少宝石
|
// args[0] 原来镶嵌了多少宝石
|
||||||
let { holes } = equip;
|
let { holes } = equip;
|
||||||
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
|
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
|
||||||
@@ -196,8 +185,7 @@ export async function checkTaskWithEquip(roleId: string, taskType: number, equip
|
|||||||
export async function checkTaskWithArgs(roleId: string, taskType: number, args: number[], funcs?: number[]) {
|
export async function checkTaskWithArgs(roleId: string, taskType: number, args: number[], funcs?: number[]) {
|
||||||
let pushMessage = new Array<TaskListReturn>();
|
let pushMessage = new Array<TaskListReturn>();
|
||||||
|
|
||||||
if(taskType == TASK_TYPE.ROLE_SCHOOL_PUT_HERO)
|
if (taskType == TASK_TYPE.ROLE_SCHOOL_PUT_HERO) {
|
||||||
{
|
|
||||||
let [hid, preHid] = args;
|
let [hid, preHid] = args;
|
||||||
if (hid > 0 && preHid <= 0) { // 放置
|
if (hid > 0 && preHid <= 0) { // 放置
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
||||||
@@ -205,8 +193,7 @@ export async function checkTaskWithArgs(roleId: string, taskType: number, args:
|
|||||||
pushMessage = await checkTask(roleId, taskType, -1, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, -1, true, {}, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.EQUIP_JEWEL_STAGE)
|
else if (taskType == TASK_TYPE.EQUIP_JEWEL_STAGE) {
|
||||||
{
|
|
||||||
// args 装上的, 卸下的
|
// args 装上的, 卸下的
|
||||||
let [putOnJewel, putOffJewel] = args;
|
let [putOnJewel, putOffJewel] = args;
|
||||||
if (putOnJewel > 0) {
|
if (putOnJewel > 0) {
|
||||||
@@ -220,8 +207,7 @@ export async function checkTaskWithArgs(roleId: string, taskType: number, args:
|
|||||||
pushMessage.concat(push);
|
pushMessage.concat(push);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.CHAT)
|
else if (taskType == TASK_TYPE.CHAT) {
|
||||||
{
|
|
||||||
// args[0] 聊天type 1-系统 2-世界 3-军团 4-组队 5-私聊
|
// args[0] 聊天type 1-系统 2-世界 3-军团 4-组队 5-私聊
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { chatType: args[0] }, funcs)
|
pushMessage = await checkTask(roleId, taskType, 1, true, { chatType: args[0] }, funcs)
|
||||||
}
|
}
|
||||||
@@ -232,60 +218,50 @@ export async function checkTaskWithArgs(roleId: string, taskType: number, args:
|
|||||||
export async function checkTaskWithWar(roleId: string, taskType: number, warId: number, heroes: number[], count: number, star: number, funcs?: number[]) {
|
export async function checkTaskWithWar(roleId: string, taskType: number, warId: number, heroes: number[], count: number, star: number, funcs?: number[]) {
|
||||||
let dicWar = gameData.war.get(warId);
|
let dicWar = gameData.war.get(warId);
|
||||||
let pushMessage = new Array<TaskListReturn>();
|
let pushMessage = new Array<TaskListReturn>();
|
||||||
if(taskType == TASK_TYPE.BATTLE_WITH_HERO)
|
if (taskType == TASK_TYPE.BATTLE_WITH_HERO) {
|
||||||
{
|
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, { warId, heroes }, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, { warId, heroes }, funcs);
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_MAIN)
|
else if (taskType == TASK_TYPE.BATTLE_MAIN) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.NORMAL) {
|
if (dicWar.warType == WAR_TYPE.NORMAL) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, { warId }, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, { warId }, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_MAIN_SWEEP)
|
else if (taskType == TASK_TYPE.BATTLE_MAIN_SWEEP) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.NORMAL) {
|
if (dicWar.warType == WAR_TYPE.NORMAL) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_DAILY_STAR)
|
else if (taskType == TASK_TYPE.BATTLE_DAILY_STAR) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.DAILY) {
|
if (dicWar.warType == WAR_TYPE.DAILY) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, { warId, star }, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, { warId, star }, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_DAILY)
|
else if (taskType == TASK_TYPE.BATTLE_DAILY) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.DAILY) {
|
if (dicWar.warType == WAR_TYPE.DAILY) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, { dailyType: dicWar.dailyType }, funcs)
|
pushMessage = await checkTask(roleId, taskType, count, true, { dailyType: dicWar.dailyType }, funcs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_DUNGEON)
|
else if (taskType == TASK_TYPE.BATTLE_DUNGEON) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.MYSTERY || dicWar.warType == WAR_TYPE.MYSTERY_ELITE) {
|
if (dicWar.warType == WAR_TYPE.MYSTERY || dicWar.warType == WAR_TYPE.MYSTERY_ELITE) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_DUNGEON_WAR)
|
else if (taskType == TASK_TYPE.BATTLE_DUNGEON_WAR) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.MYSTERY || dicWar.warType == WAR_TYPE.MYSTERY_ELITE) {
|
if (dicWar.warType == WAR_TYPE.MYSTERY || dicWar.warType == WAR_TYPE.MYSTERY_ELITE) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, { warId }, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, { warId }, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_TOWER)
|
else if (taskType == TASK_TYPE.BATTLE_TOWER) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.TOWER) {
|
if (dicWar.warType == WAR_TYPE.TOWER) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_VESTIGE)
|
else if (taskType == TASK_TYPE.BATTLE_VESTIGE) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.VESTIGE) {
|
if (dicWar.warType == WAR_TYPE.VESTIGE) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.BATTLE_EXPEDITION)
|
else if (taskType == TASK_TYPE.BATTLE_EXPEDITION) {
|
||||||
{
|
|
||||||
if (dicWar.warType == WAR_TYPE.EXPEDITION) {
|
if (dicWar.warType == WAR_TYPE.EXPEDITION) {
|
||||||
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
pushMessage = await checkTask(roleId, taskType, count, true, {}, funcs);
|
||||||
}
|
}
|
||||||
@@ -296,8 +272,7 @@ export async function checkTaskWithWar(roleId: string, taskType: number, warId:
|
|||||||
|
|
||||||
export async function checkTaskWithGoods(roleId: string, taskType: number, goods: ItemInter[], funcs?: number[]) {
|
export async function checkTaskWithGoods(roleId: string, taskType: number, goods: ItemInter[], funcs?: number[]) {
|
||||||
let pushMessage = new Array<TaskListReturn>();
|
let pushMessage = new Array<TaskListReturn>();
|
||||||
if(taskType == TASK_TYPE.COM_BATTLE_DROP)
|
if (taskType == TASK_TYPE.COM_BATTLE_DROP) {
|
||||||
{
|
|
||||||
for (let { id, count } of goods) {
|
for (let { id, count } of goods) {
|
||||||
let push = await checkTask(roleId, taskType, count, true, { gid: id }, funcs);
|
let push = await checkTask(roleId, taskType, count, true, { gid: id }, funcs);
|
||||||
pushMessage.concat(push);
|
pushMessage.concat(push);
|
||||||
@@ -488,3 +463,101 @@ function checkRecResult(rec: UserTaskRecType, id: number, condition: number) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务统计
|
||||||
|
*
|
||||||
|
* @param {number} serverId 区Id
|
||||||
|
* @param {string} roleId 角色Id
|
||||||
|
* @param {number} taskType 任务类型
|
||||||
|
* @param {number} count 任务数据
|
||||||
|
* @param {number} parma 参数
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export async function accomplishTask(roleId: string, taskType: TASK_TYPE, count: number, parma?: any) {
|
||||||
|
let allActivity: ActivityModelType[] = await ActivityModel.findOpenActivityByType(ACTIVITY_TYPE.TASK_GROWTH, new Date());
|
||||||
|
for (let activity of allActivity) {
|
||||||
|
let growthActivity = new GrowthData(activity);
|
||||||
|
let taskArray = growthActivity.findTaskByType(taskType);
|
||||||
|
for (let task of taskArray) {
|
||||||
|
let addCount = isComplete(roleId, task.taskType, task.taskParam, count, parma);
|
||||||
|
if (addCount) {
|
||||||
|
if (taskType == TASK_TYPE.ROLE_LV || taskType == TASK_TYPE.ROLE_TITLE) {
|
||||||
|
await ActivityGrowthModel.setTaskCount(growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||||
|
} else {
|
||||||
|
await ActivityGrowthModel.addTaskCount(growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 达成任务标准
|
||||||
|
*
|
||||||
|
* @param {string} roleId 角色Id
|
||||||
|
* @param {number} taskType 任务类型
|
||||||
|
* @param {number} taskParam 任务条件数据
|
||||||
|
* @param {number} count 数据
|
||||||
|
* @param {number} parma 参数
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: string, count: number, paramObj?: any): number {
|
||||||
|
console.log('达成任务标准', roleId, taskType, taskParam, count, paramObj)
|
||||||
|
let param = splitString(taskParam, '&');
|
||||||
|
let addCount: number = 0; // 条件是否满足
|
||||||
|
switch (taskType) {
|
||||||
|
case TASK_TYPE.ROLE_LV://重置数据
|
||||||
|
addCount = param[0] <= count ? count : 0;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.GUILD_JOIN:
|
||||||
|
addCount = count;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.LOGIN_SUM:
|
||||||
|
addCount = count;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.HERO_NUM:
|
||||||
|
addCount = count;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.ROLE_TITLE://重置数据
|
||||||
|
addCount = param[0] <= count ? count : 0;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.GASHA:
|
||||||
|
addCount = count;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.EQUIP_STRENGTHEN:
|
||||||
|
for (let obj of paramObj) {
|
||||||
|
// obj.hid;//英雄di
|
||||||
|
// obj.oldLv;//栏位升级前等级
|
||||||
|
// obj.lv;//栏位升级后等级
|
||||||
|
// obj.id;//栏位id
|
||||||
|
if (param[1] > obj.oldLv && param[1] <= obj.lv) {
|
||||||
|
addCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.BATTLE_MAIN:
|
||||||
|
addCount = param[0] == paramObj.warId ? 1 : 0;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.EQUIP_JEWEL_SUM:
|
||||||
|
addCount = count;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.GUILD_TRAIN:
|
||||||
|
addCount = count;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.ROLE_SCHOOL_PUT_HERO:
|
||||||
|
addCount = count;
|
||||||
|
break;
|
||||||
|
case TASK_TYPE.GUILD_ACTIVITY:
|
||||||
|
addCount = count;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
addCount = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return addCount;
|
||||||
|
}
|
||||||
|
|||||||
@@ -525,6 +525,20 @@ export function parseGoodStr(str: string) {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
// 根据类型解析物品 {"type":number, "id": number, "count": number} 格式
|
||||||
|
//type 1.英雄,2.物品
|
||||||
|
export function parseGoodStrWithType(str: string) {
|
||||||
|
let result = new Array<{ type: number, id: number, count: number }>();
|
||||||
|
if (!str) return result;
|
||||||
|
let decodeArr = decodeArrayListStr(str);
|
||||||
|
for (let [type, id, count] of decodeArr) {
|
||||||
|
if (isNaN(parseInt(type)) || isNaN(parseInt(id)) || isNaN(parseInt(count))) {
|
||||||
|
throw new Error('data table format wrong');
|
||||||
|
}
|
||||||
|
result.push({ type: parseInt(type), id: parseInt(id), count: parseInt(count) });
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// 数字列表
|
// 数字列表
|
||||||
export function parseNumberList(str: string) {
|
export function parseNumberList(str: string) {
|
||||||
@@ -600,3 +614,15 @@ export function getRobotInfo() {
|
|||||||
robotRoleId: genCode(8)
|
robotRoleId: genCode(8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function splitString(dataString: string, key: string) {
|
||||||
|
if (!dataString) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
let array = dataString.split(key).filter(obj => { return obj && obj != '' });
|
||||||
|
let numberArray = [];
|
||||||
|
for (let num of array) {
|
||||||
|
numberArray.push(Number(num));
|
||||||
|
}
|
||||||
|
return numberArray;
|
||||||
|
}
|
||||||
@@ -1063,5 +1063,20 @@
|
|||||||
"__EMPTY_3": 0,
|
"__EMPTY_3": 0,
|
||||||
"__EMPTY_4": 0,
|
"__EMPTY_4": 0,
|
||||||
"__EMPTY_5": 0
|
"__EMPTY_5": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 72,
|
||||||
|
"name": "加入军团",
|
||||||
|
"info": "加入军团",
|
||||||
|
"param": "count&",
|
||||||
|
"string": "加入军团次数&",
|
||||||
|
"content": 0,
|
||||||
|
"condition": "count",
|
||||||
|
"__EMPTY": 0,
|
||||||
|
"__EMPTY_1": 0,
|
||||||
|
"__EMPTY_2": 0,
|
||||||
|
"__EMPTY_3": 0,
|
||||||
|
"__EMPTY_4": 0,
|
||||||
|
"__EMPTY_5": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user