活动:统计套装宝石相同阶数的任务
This commit is contained in:
@@ -4,7 +4,7 @@ import { ItemInter } from "../../../pubUtils/interface";
|
||||
|
||||
import { resResult, parseGoodStr, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
||||
import { addItems, handleCost, decreaseItems } from "../../../services/rewardService";
|
||||
import { EquipModel, EquipType } from "../../../db/Equip";
|
||||
import Equip, { EquipModel, EquipType } from "../../../db/Equip";
|
||||
import { HeroModel, EPlace } from "../../../db/Hero";
|
||||
import Role from "../../../db/Role";
|
||||
import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
||||
@@ -15,7 +15,7 @@ import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerC
|
||||
|
||||
import { indexOf, findIndex } from 'underscore';
|
||||
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
||||
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs } from "../../../services/taskService";
|
||||
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, checkTaskConditionEquipSuitJewelStage } from "../../../services/taskService";
|
||||
import { accomplishTask } from "../../../pubUtils/taskUtil";
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -509,12 +509,20 @@ export class EquipHandler {
|
||||
curEquip = await dressEquip(roleId, sid, hero, equip, funcs);
|
||||
if (!!curEquip)
|
||||
curEquips.push(curEquip);
|
||||
|
||||
//任务
|
||||
//英雄满装备且都镶嵌相同阶数的宝石
|
||||
let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
if (isTask) {
|
||||
await accomplishTask(roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel })
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (!equip.hid)
|
||||
return resResult(STATUS.EQUIP_NOT_EQUIPED);
|
||||
let curEquip = await takeOffEquipAndCalPlayerCe(roleId, sid, hero, equip, id, funcs);
|
||||
curEquips.push(curEquip);
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curEquips: curEquips });
|
||||
}
|
||||
|
||||
@@ -581,6 +589,12 @@ export class EquipHandler {
|
||||
if (!!equip.hid) {
|
||||
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_ON, sid, roleId, hero, {}, [jewel, oldJewel]);
|
||||
//任务
|
||||
//英雄满装备且都镶嵌相同阶数的宝石
|
||||
let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
if (isTask) {
|
||||
await accomplishTask(roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel })
|
||||
}
|
||||
}
|
||||
|
||||
// 任务
|
||||
@@ -589,6 +603,7 @@ export class EquipHandler {
|
||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
|
||||
//成长任务
|
||||
await accomplishTask(roleId, TASK_TYPE.EQUIP_JEWEL_SUM, 1)
|
||||
await accomplishTask(roleId, TASK_TYPE.EQUIP_JEWEL_STAGE, 1)
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
}
|
||||
@@ -753,6 +768,13 @@ export class EquipHandler {
|
||||
if (!!equip.hid) {
|
||||
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_ON, sid, roleId, hero, {}, [jewel, oldJewel]);
|
||||
|
||||
//任务
|
||||
//英雄满装备且都镶嵌相同阶数的宝石
|
||||
let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
if (isTask) {
|
||||
await accomplishTask(roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel })
|
||||
}
|
||||
}
|
||||
|
||||
// 任务
|
||||
@@ -760,7 +782,7 @@ export class EquipHandler {
|
||||
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 accomplishTask(roleId, TASK_TYPE.EQUIP_JEWEL_SUM, 1)
|
||||
await accomplishTask(roleId, TASK_TYPE.EQUIP_JEWEL_SUM, count)
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
} else {
|
||||
|
||||
@@ -8,22 +8,23 @@ import { EquipType } from "../db/Equip";
|
||||
import { calEquipSeids } from '../pubUtils/playerCe';
|
||||
import { indexOf, findIndex } from 'underscore';
|
||||
import { checkTask, checkTaskWithHero, checkTaskWithEquip } from './taskService';
|
||||
import { accomplishTask } from '../pubUtils/taskUtil';
|
||||
/**
|
||||
* 校验前端传入的消耗数量是否准确,并返回消耗的道具并加上特殊材料needConsumes
|
||||
* @param consumes
|
||||
* @param jewel
|
||||
* @param jewelCount
|
||||
*/
|
||||
export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) {
|
||||
export function checkMaterialEnough(consumes: Array<{ id: number, count: number }>, jewel: number, jewelCount: number) {
|
||||
let comJewelMap = {};
|
||||
consumes = mergeSameGoods(consumes);
|
||||
let needConsumes: Array<{id: number, count: number}> = [];
|
||||
let needConsumes: Array<{ id: number, count: number }> = [];
|
||||
let gidJewelInfo = getGoodById(jewel);//目标宝石信息
|
||||
for (let { id, count } of consumes) {
|
||||
let jewelInfo = getJewelById(id);
|
||||
if (!jewelInfo || !jewelInfo.count) //筛选出特殊材料,特殊材料没有合成下一级需要的count数量
|
||||
continue;
|
||||
needConsumes.push({ id, count});//将该宝石加入消耗中
|
||||
needConsumes.push({ id, count });//将该宝石加入消耗中
|
||||
comJewelMap[id] = count + (comJewelMap[id] || 0);
|
||||
for (let i = jewelInfo.lvLimited; i < gidJewelInfo.lvLimited; i++) {//当前消耗的宝石升级到目标宝石的消耗
|
||||
if (((comJewelMap[id] || 0) % jewelInfo.count != 0)) {//jewelInfo的count,表示宝石id合成下一级需要的数量
|
||||
@@ -32,11 +33,11 @@ export function checkMaterialEnough(consumes:Array<{id: number, count: number}>,
|
||||
let comcount = Math.floor(((comJewelMap[id] || 0)) / jewelInfo.count);
|
||||
if (comcount < 1) {
|
||||
break;//不能合成,跳出循环,等待下次合成
|
||||
}
|
||||
}
|
||||
comJewelMap[jewelInfo.nextJewelId] = comcount + (comJewelMap[jewelInfo.nextJewelId] || 0);//jewelInfo的nextJewelId,表示宝石id合成下一级的宝石good_id
|
||||
delete comJewelMap[id];
|
||||
if (!!jewelInfo.specialCount)
|
||||
needConsumes.push({ count: jewelInfo.specialCount * comcount, id: jewelInfo.nextSpecialId});//消耗中曾加合成下一级需要的特殊消耗物品的数量
|
||||
needConsumes.push({ count: jewelInfo.specialCount * comcount, id: jewelInfo.nextSpecialId });//消耗中曾加合成下一级需要的特殊消耗物品的数量
|
||||
jewelInfo = getJewelById(jewelInfo.nextJewelId);
|
||||
}
|
||||
}
|
||||
@@ -93,21 +94,21 @@ export async function changeEquip(roleId: string, sid: string, equipA: EquipType
|
||||
* @param hero
|
||||
* @param id
|
||||
*/
|
||||
export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, hero:HeroType, equip: EquipType, id: number, funcs: number[] ) {
|
||||
export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, hero: HeroType, equip: EquipType, id: number, funcs: number[]) {
|
||||
console.log(roleId, sid, hero, equip, id)
|
||||
if(hero) {
|
||||
if (hero) {
|
||||
let args = calEquipSeids(hero);
|
||||
hero = await HeroModel.removeEquip(roleId, hero.hid, id, equip._id);
|
||||
|
||||
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, args);
|
||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [-1]);
|
||||
} else {
|
||||
await EquipModel.putOnOrOff( equip._id, 0 );
|
||||
await EquipModel.putOnOrOff(equip._id, 0);
|
||||
}
|
||||
// 任务
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.EQUIP_SUM, -1, true, {});
|
||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [-1]);
|
||||
return { seqId: equip.seqId, hid: 0};
|
||||
return { seqId: equip.seqId, hid: 0 };
|
||||
}
|
||||
/**
|
||||
* 穿戴装备并重算战力
|
||||
@@ -116,7 +117,7 @@ export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, he
|
||||
* @param hero
|
||||
* @param equip
|
||||
*/
|
||||
export async function dressEquip(roleId: string, sid: string, hero:HeroType, equip: EquipType, funcs: number[]) {
|
||||
export async function dressEquip(roleId: string, sid: string, hero: HeroType, equip: EquipType, funcs: number[]) {
|
||||
let args = calEquipSeids(hero);
|
||||
|
||||
hero = await HeroModel.addEquip(roleId, hero.hid, equip.ePlaceId, equip._id);
|
||||
@@ -126,6 +127,7 @@ 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 accomplishTask(roleId, TASK_TYPE.EQUIP_QUALITY, 1, { quality: equip.quality })
|
||||
|
||||
return { seqId: equip.seqId, hid: hero.hid };
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { ItemInter } from '../pubUtils/interface';
|
||||
import { UserTaskModel, UserTaskType } from '../db/UserTask';
|
||||
import { UserTaskRecModel } from '../db/UserTaskRec';
|
||||
import { UserTaskHistoryModel } from '../db/UserTaskHistory';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { gameData, getGoodById } from '../pubUtils/data';
|
||||
import { getCurWeekDate, getSeconds } from '../pubUtils/timeUtil';
|
||||
import { RoleStatus } from '../db/ComBattleTeam';
|
||||
|
||||
@@ -95,7 +95,7 @@ export async function checkTaskInBattleEnd(roleId: string, sid: string, funcs: n
|
||||
export async function checkTaskInComBattleEnd(roleStatus: RoleStatus[], capId: string, quality: number) {
|
||||
console.log('********', JSON.stringify(roleStatus), capId, quality)
|
||||
for (let { roleId, isRobot } of roleStatus) {
|
||||
if(!isRobot) {
|
||||
if (!isRobot) {
|
||||
if (roleId == capId && roleStatus.length > 1) { // 招募队友
|
||||
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, 1, true, {});
|
||||
} else if (roleId !== capId) { // 协助寻宝
|
||||
@@ -239,4 +239,33 @@ export async function refDailyTaskBox(roleId: string, sid: string, debug = false
|
||||
point, weeklyPoint, box
|
||||
}), uids);
|
||||
}
|
||||
}
|
||||
|
||||
//任务条件
|
||||
//英雄满装备且都镶嵌相同阶数的宝石
|
||||
export async function checkTaskConditionEquipSuitJewelStage(hero: HeroType) {
|
||||
let isTask = true;//是否满足任务条件
|
||||
let jewelLevel = -1;//宝石阶数
|
||||
for (let i = 0; i < hero.ePlace.length; i++) {
|
||||
let equipObj = <EquipType>hero.ePlace[i].equip;
|
||||
let equipObjInfo = getGoodById(equipObj.id);
|
||||
if (equipObj.holes.length == equipObjInfo.hole && equipObjInfo.hole > 0) {
|
||||
for (let j = 0; j < equipObj.holes.length; j++) {
|
||||
let jewel = equipObj.holes[j].jewel;
|
||||
let jewelInfo = getGoodById(jewel);
|
||||
if (jewelLevel == -1) {
|
||||
jewelLevel = jewelInfo.lvLimited;
|
||||
} else if (jewelInfo.lvLimited != jewelLevel) {
|
||||
//宝石阶数不同
|
||||
isTask = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//宝石没有镶满
|
||||
isTask = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return { isTask, jewelLevel };
|
||||
}
|
||||
Reference in New Issue
Block a user