装备:活动任务

This commit is contained in:
luying
2022-02-22 15:29:19 +08:00
parent 3f5371df79
commit 12b4b6668b
6 changed files with 342 additions and 60 deletions
+91 -1
View File
@@ -3,6 +3,8 @@ import { EPlace, Stone } from "../db/Hero";
import { gameData } from "../pubUtils/data";
import { JewelType, RandSe } from '../db/Jewel';
import { getJewelRandSe } from '../pubUtils/itemUtils';
import { checkActivityTask, checkTask, checkTaskWithEplaces, checkTaskWithEplace } from './taskService';
import { TASK_TYPE } from '../consts';
export function getRandSeResult(id: number, randSe: RandSe[]) {
let { randomEffect, effectCount } = gameData.jewel.get(id);
@@ -103,4 +105,92 @@ export function checkStoneCanPutOnEquip(equip: EPlace, id: number, stone: number
let dicEquipQualityExtra = gameData.equipQualityExtra.get(equip.quality);
if(!dicEquipQualityExtra || dicEquipQualityExtra.stoneCnt < id) return false;
return true;
}
}
export async function checkTaskInComposeEquip(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number) {
await checkTask(roleId, sid, TASK_TYPE.EQUIP_COMPOSE, newEplace.length - oldEplace.length, true, {});
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_COMPOSE_CNT, oldEplace, newEplace, [ePlaceId]);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_COMPOSE, newEplace.length - oldEplace.length);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_COMPOSE_CNT, 1, { oldEplace, newEplace });
}
export async function checkTaskInEquipLvUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceIds: number[]) {
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_LV_TO, oldEplace, newEplace, ePlaceIds);
await checkTask(roleId, sid, TASK_TYPE.EQUIP_LV_UP, ePlaceIds.length, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_LV_TO, 1, { oldEplace, newEplace, ePlaceIds });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_LV_UP, ePlaceIds.length, true);
}
export async function checkTaskInPutJewel(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, originJewel: JewelType, curJewel: JewelType) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL, oldEquip, newEquip, { jewels: [originJewel, curJewel ] });
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEquip, newEquip, { jewels: [originJewel, curJewel ] });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_JEWEL, 1, { oldEquip, newEquip, jewels: [originJewel, curJewel ] });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, 1, { oldEquip, newEquip, jewels: [originJewel, curJewel ] });
}
export async function checkTaskInPutStone(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, jewel: JewelType) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE_CNT, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT_LV, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEquip, newEquip, { jewels: [ jewel ] });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_STONE, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_STONE_CNT, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STONE_CNT, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STONE_CNT_LV, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, 1, { oldEquip, newEquip, jewels: [ jewel ] });
}
export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean) {
if(isUpStar) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_TO, oldEquip, newEquip);
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_SUIT_SEID_NUM, oldEplace, newEplace, [ePlaceId], { hid });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STAR_UP_TO, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUIT_SEID_NUM, 1, { oldEplace, newEplace, ePlaceId, hid });
}
await checkTask(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, {});
}
export async function checkTaskInEquipQualityUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpQuality: boolean) {
if(isUpQuality) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP, oldEquip, newEquip, { hid });
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_TO, oldEquip, newEquip);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP, 1, { ePlaceId, hid });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP_TO, 1, { oldEquip, newEquip, hid });
}
await checkTask(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1);
}
export async function checkTaskInEquipReset(serverId: number, roleId: string, sid: string) {
await checkTask(roleId, sid, TASK_TYPE.JEWEL_RESET, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_RESET, 1);
}
export async function checkTaskInEquipQuench(serverId: number, roleId: string, sid: string, isSuccess: boolean) {
await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_QUENCH, 1);
if(isSuccess) {
await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1);
}
}
export async function checkTaskInComposeStone(serverId: number, roleId: string, sid: string, count: number) {
await checkTask(roleId, sid, TASK_TYPE.STONE_COMPOSE, count, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.STONE_COMPOSE, count);
}
function getEquipById(oldEplace: EPlace[], newEplace: EPlace[], eplaceId: number) {
let oldEquip = oldEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0);
let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0);
return { oldEquip, newEquip }
}
+4 -10
View File
@@ -40,10 +40,10 @@ export async function checkTaskWithEplaces(roleId: string, sid: string, taskType
pushTaskUpdate(roleId, sid, pushMessage);
}
// export async function checkTaskWithEquip(roleId: string, sid: string, taskType: number, equip: EquipType, args?: number[]) {
// let pushMessage = await taskUtil.checkTaskWithEquip(roleId, taskType, equip, args);
// pushTaskUpdate(roleId, sid, pushMessage);
// }
export async function checkTaskWithEplace(roleId: string, sid: string, taskType: number, oldEquip: EPlace, newEplace: EPlace, params?: any) {
let pushMessage = await taskUtil.checkTaskWithEplace(roleId, taskType, oldEquip, newEplace, params);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithArgs(roleId: string, sid: string, taskType: number, args: number[]) {
let pushMessage = await taskUtil.checkTaskWithArgs(roleId, taskType, args);
@@ -300,12 +300,6 @@ export async function getPvpTask(roleId: string) {
return { taskList }
}
export async function checkTaskInPutJewel(roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, originJewel: JewelType, curJewel: JewelType) {
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL, oldEplace, newEplace, [ePlaceId], { jewels: [originJewel, curJewel ] });
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, oldEplace, newEplace, [ePlaceId]);
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEplace, newEplace, [ePlaceId], { jewels: [originJewel, curJewel ] });
}
// 刷新每日任务
export async function refDailyTask(roleId: string, sid: string) {
let userTask = await UserTaskModel.findByRole(roleId);