装备:清理旧代码

This commit is contained in:
luying
2022-02-18 17:53:10 +08:00
parent e29326856c
commit 3d6fab2ae6
33 changed files with 169 additions and 1472 deletions

View File

@@ -6,7 +6,6 @@ import { RoleType, RoleModel } from '../db/Role';
import { TaskParam, TaskListReturn } from '../domain/roleField/task';
import { getZeroPoint } from './timeUtil';
import { HeroType } from '../db/Hero';
import { EquipType, EquipModel } from '../db/Equip';
import { ItemInter } from './interface';
import { DailyChallengesData } from '../domain/activityField/dailyChallengesField';
import { splitString } from './util';
@@ -149,61 +148,61 @@ export async function checkTaskWithHero(roleId: string, taskType: number, hero:
}
export async function checkTaskWithEquip(roleId: string, taskType: number, equip: EquipType, args: number[] = []) {
let pushMessage = new Array<TaskListReturn>();
if (taskType == TASK_TYPE.EQUIP_QUALITY) {
// args[0] 1装上 -1脱下
let dicGood = gameData.goods.get(equip.id);
pushMessage = await checkTask(roleId, taskType, args[0], true, { quality: dicGood.quality })
}
else if (taskType == TASK_TYPE.EQUIP_JEWEL) {
// args[0] 原来镶嵌了多少宝石
let { holes } = equip;
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
if (jewelCount > 0 && args[0] <= 0) { // 原来没有,镶嵌上了
pushMessage = await checkTask(roleId, taskType, 1, true, {});
} else if (jewelCount <= 0 && args[0] > 0) { // 原来镶嵌着,现在没了
pushMessage = await checkTask(roleId, taskType, -1, true, {});
}
}
else if (taskType == TASK_TYPE.EQUIP_COMPOSE_SUIT) {
let dicGood = gameData.goods.get(equip.id);
if (dicGood.suitId) {
pushMessage = await checkTask(roleId, taskType, 1, true, {});
}
}
else if (taskType == TASK_TYPE.EQUIP_SUIT) {
let dicGood = gameData.goods.get(equip.id);
if (dicGood.suitId) {
let suit = gameData.suit.get(dicGood.suitId);
let equips = await EquipModel.getEquipsByIds(roleId, suit.tireInfo);
let everyEquip = new Map<number, number>();
for (let equip of equips) {
if (everyEquip.has(equip.id)) {
everyEquip.set(equip.id, everyEquip.get(equip.id) + 1);
} else {
everyEquip.set(equip.id, 1);
}
}
let minCount = 0, curCount = 0;
for (let id of suit.tireInfo) {
let count = everyEquip.get(id) || 0;
if (minCount > count) minCount = count;
if (id == equip.id) curCount = count;
}
if (curCount == minCount) {
pushMessage = await checkTask(roleId, taskType, 1, true, {});
}
}
}
else if (taskType == TASK_TYPE.EQUIP_JEWEL_SUM) {
// args[0] 原来镶嵌了多少宝石
let { holes } = equip;
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
pushMessage = await checkTask(roleId, taskType, jewelCount - args[0], true, {});
}
return pushMessage
}
// export async function checkTaskWithEquip(roleId: string, taskType: number, equip: EquipType, args: number[] = []) {
// let pushMessage = new Array<TaskListReturn>();
// if (taskType == TASK_TYPE.EQUIP_QUALITY) {
// // args[0] 1装上 -1脱下
// let dicGood = gameData.goods.get(equip.id);
// pushMessage = await checkTask(roleId, taskType, args[0], true, { quality: dicGood.quality })
// }
// else if (taskType == TASK_TYPE.EQUIP_JEWEL) {
// // args[0] 原来镶嵌了多少宝石
// let { holes } = equip;
// let jewelCount = holes.filter(cur => cur.jewel > 0).length;
// if (jewelCount > 0 && args[0] <= 0) { // 原来没有,镶嵌上了
// pushMessage = await checkTask(roleId, taskType, 1, true, {});
// } else if (jewelCount <= 0 && args[0] > 0) { // 原来镶嵌着,现在没了
// pushMessage = await checkTask(roleId, taskType, -1, true, {});
// }
// }
// else if (taskType == TASK_TYPE.EQUIP_COMPOSE_SUIT) {
// let dicGood = gameData.goods.get(equip.id);
// if (dicGood.suitId) {
// pushMessage = await checkTask(roleId, taskType, 1, true, {});
// }
// }
// else if (taskType == TASK_TYPE.EQUIP_SUIT) {
// let dicGood = gameData.goods.get(equip.id);
// if (dicGood.suitId) {
// let suit = gameData.suit.get(dicGood.suitId);
// let equips = await EquipModel.getEquipsByIds(roleId, suit.tireInfo);
// let everyEquip = new Map<number, number>();
// for (let equip of equips) {
// if (everyEquip.has(equip.id)) {
// everyEquip.set(equip.id, everyEquip.get(equip.id) + 1);
// } else {
// everyEquip.set(equip.id, 1);
// }
// }
// let minCount = 0, curCount = 0;
// for (let id of suit.tireInfo) {
// let count = everyEquip.get(id) || 0;
// if (minCount > count) minCount = count;
// if (id == equip.id) curCount = count;
// }
// if (curCount == minCount) {
// pushMessage = await checkTask(roleId, taskType, 1, true, {});
// }
// }
// }
// else if (taskType == TASK_TYPE.EQUIP_JEWEL_SUM) {
// // args[0] 原来镶嵌了多少宝石
// let { holes } = equip;
// let jewelCount = holes.filter(cur => cur.jewel > 0).length;
// pushMessage = await checkTask(roleId, taskType, jewelCount - args[0], true, {});
// }
// return pushMessage
// }
export async function checkTaskWithArgs(roleId: string, taskType: number, args: number[]) {
let pushMessage = new Array<TaskListReturn>();
@@ -217,18 +216,18 @@ export async function checkTaskWithArgs(roleId: string, taskType: number, args:
}
}
else if (taskType == TASK_TYPE.EQUIP_JEWEL_STAGE) {
// args 装上的, 卸下的
let [putOnJewel, putOffJewel] = args;
if (putOnJewel > 0) {
let dicGood = gameData.goods.get(putOnJewel);
let push = await checkTask(roleId, taskType, 1, true, { stage: dicGood.lvLimited });
pushMessage.push(...push);
}
if (putOffJewel > 0) {
let dicGood = gameData.goods.get(putOffJewel);
let push = await checkTask(roleId, taskType, -1, true, { stage: dicGood.lvLimited });
pushMessage.push(...push);
}
// // args 装上的, 卸下的
// let [putOnJewel, putOffJewel] = args;
// if (putOnJewel > 0) {
// let dicGood = gameData.goods.get(putOnJewel);
// let push = await checkTask(roleId, taskType, 1, true, { stage: dicGood.lvLimited });
// pushMessage.push(...push);
// }
// if (putOffJewel > 0) {
// let dicGood = gameData.goods.get(putOffJewel);
// let push = await checkTask(roleId, taskType, -1, true, { stage: dicGood.lvLimited });
// pushMessage.push(...push);
// }
}
else if (taskType == TASK_TYPE.CHAT) {
// args[0] 聊天type 1-系统 2-世界 3-军团 4-组队 5-私聊