活动:添加新任务类型
This commit is contained in:
@@ -20,7 +20,7 @@ import { getRoleIds } from '../pubUtils/friendUtil';
|
||||
import { getTeamSearchByQuality, rmRoleFromQueue } from './redisService';
|
||||
import { addUserToChannel } from './roleService';
|
||||
import { ChannelUser } from '../domain/ChannelUser';
|
||||
import { checkTaskInComBattleEnd } from './taskService';
|
||||
import { checkActivityTask, checkTaskInComBattleEnd } from './taskService';
|
||||
import { getRewardByBlueprtId, gameData, comBtlRangeByLv, getBossHpByBlueprtId } from '../pubUtils/data';
|
||||
import { getFriendPointObject } from '../pubUtils/itemUtils';
|
||||
import { DicWar } from '../pubUtils/dictionary/DicWar';
|
||||
@@ -133,7 +133,7 @@ export async function checkComBattleDrop(roleId: string, battleCode: string) {
|
||||
}
|
||||
}
|
||||
await ComBattleTeamModel.updateRewardSt(team.teamCode, roleId, true);
|
||||
return {status: 0, fixReward};
|
||||
return { status: 0, fixReward };
|
||||
}
|
||||
|
||||
export function clearComBtlTimer(teamCode: string, timerMap: Map<string, NodeJS.Timer>) {
|
||||
@@ -258,21 +258,22 @@ export async function handleComBtlProgress(teamStatus: MemComBtlTeam, robotHurtT
|
||||
st.fixReward = await getRealReward(teamStatus.blueprtId, st);
|
||||
};
|
||||
}
|
||||
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: battleSt, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr});
|
||||
let team = await ComBattleTeamModel.syncTeamData({ teamCode, status: battleSt, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr });
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
|
||||
// 战斗胜利队长扣减藏宝图
|
||||
if (result && teamStatus.capId != 'robot') {
|
||||
const { sid } = channel.getMember(teamStatus.capId);
|
||||
let res = await decreaseItems(teamStatus.capId, sid, [{id: teamStatus.blueprtId, count: 1}]);
|
||||
let res = await decreaseItems(teamStatus.capId, sid, [{ id: teamStatus.blueprtId, count: 1 }]);
|
||||
if (res === true) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
||||
}
|
||||
clearRobotHurtTimer(teamStatus, robotHurtTimer);
|
||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result}));
|
||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, { teamCode, result }));
|
||||
|
||||
// 任务
|
||||
await checkTaskInComBattleEnd(teamStatus.roleStatus, capId, quality);
|
||||
|
||||
|
||||
teamMap.delete(teamCode);
|
||||
}
|
||||
}
|
||||
@@ -291,11 +292,11 @@ export function updateRobotHurt(teamStatus: MemComBtlTeam, roleSt: RoleStatus, c
|
||||
for (let boss of teamStatus.bossHpArr) {
|
||||
if (boss.curHp === 0) continue;
|
||||
if (boss.curHp >= eachHurtHp) {
|
||||
actBossHurts.push({dataId: boss.dataId, hurtHp: eachHurtHp});
|
||||
actBossHurts.push({ dataId: boss.dataId, hurtHp: eachHurtHp });
|
||||
robotTotalHurt += eachHurtHp;
|
||||
boss.curHp -= eachHurtHp;
|
||||
} else if (boss.curHp > 0) { // 丢弃溢出的伤害
|
||||
actBossHurts.push({dataId: boss.dataId, hurtHp: boss.curHp});
|
||||
actBossHurts.push({ dataId: boss.dataId, hurtHp: boss.curHp });
|
||||
robotTotalHurt += boss.curHp;
|
||||
boss.curHp = 0;
|
||||
}
|
||||
@@ -373,7 +374,7 @@ export async function dismissTeam(teamStatus: MemComBtlTeam, teamMap: Map<string
|
||||
let rmSt = teamMap.delete(teamCode);
|
||||
if (!rmSt) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
|
||||
channel.pushMessage('onTeamDismiss', resResult(STATUS.SUCCESS, {teamCode}));
|
||||
channel.pushMessage('onTeamDismiss', resResult(STATUS.SUCCESS, { teamCode }));
|
||||
channel.destroy();
|
||||
clearComBtlTimer(teamCode, teamDisTimer); // 队伍解散停止解散计时
|
||||
return resResult(STATUS.SUCCESS);
|
||||
@@ -457,13 +458,13 @@ export function randEquipPrintId(warInfo: DicWar) {
|
||||
*/
|
||||
export async function getComBattleFriendAdd(roleStatus: RoleStatus[]) {
|
||||
let hasAdd: string[] = []; //roleIds
|
||||
for(let myRoleStatus of roleStatus) {
|
||||
for(let rs of roleStatus) {
|
||||
if(myRoleStatus.roleId == rs.roleId) continue;
|
||||
if(myRoleStatus.isRobot || rs.isRobot) continue;
|
||||
for (let myRoleStatus of roleStatus) {
|
||||
for (let rs of roleStatus) {
|
||||
if (myRoleStatus.roleId == rs.roleId) continue;
|
||||
if (myRoleStatus.isRobot || rs.isRobot) continue;
|
||||
|
||||
let {roleIds} = getRoleIds([myRoleStatus.roleId, rs.roleId]);
|
||||
if(hasAdd.includes(roleIds)) continue;
|
||||
let { roleIds } = getRoleIds([myRoleStatus.roleId, rs.roleId]);
|
||||
if (hasAdd.includes(roleIds)) continue;
|
||||
|
||||
let add = await getFriendLvAdd(myRoleStatus.roleId, rs.roleId);
|
||||
rs.addFrdRatio(add);
|
||||
@@ -486,7 +487,7 @@ async function teammateValid(roleInfo: Partial<RoleType>, roleId: string, roleId
|
||||
if (!roleInfo || roleIds.indexOf(roleId) !== -1) return false;
|
||||
|
||||
const isBlack = await teammateInBlackList(roleId, roleIds);
|
||||
if(isBlack) return false;
|
||||
if (isBlack) return false;
|
||||
|
||||
let { topLineupCe } = roleInfo;
|
||||
if (topLineupCe < ceLimit) return false;
|
||||
@@ -523,7 +524,7 @@ export async function getValidTeammateRoleSt(roleId: string, roleIds: string[],
|
||||
* @returns
|
||||
*/
|
||||
export async function teammateInBlackList(roleId: string, roleIds: string[]) {
|
||||
for(let teammateRoleId of roleIds) {
|
||||
for (let teammateRoleId of roleIds) {
|
||||
const isBlack = await FriendRelationModel.isInBlackList(roleId, teammateRoleId);
|
||||
if (isBlack === true) return true;
|
||||
}
|
||||
@@ -627,7 +628,7 @@ export async function addValidSearchingRoles(comTeam: MemComBtlTeam, channelServ
|
||||
const channel = channelService.getChannel(comTeam.teamCode, false);
|
||||
addUserToChannel(channel, new ChannelUser(teammateRoleId, sid));
|
||||
}
|
||||
channelService.pushMessageByUids('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: comTeam}), teammates.map(t => {return {uid: t.roleId, sid: t.sid}}));
|
||||
channelService.pushMessageByUids('onTeamJoin', resResult(STATUS.SUCCESS, { teamInfo: comTeam }), teammates.map(t => { return { uid: t.roleId, sid: t.sid } }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +668,7 @@ export async function addRobotsToTeam(comTeam: MemComBtlTeam, roleId: string, ro
|
||||
addRoleStToTeam(comTeam, st);
|
||||
await ComBattleTeamModel.addRole(teamCode, st);
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: comTeam}));
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, { teamInfo: comTeam }));
|
||||
setDismissTimer(comTeam, teamMap, roleId, teamDisTimer, channel);
|
||||
}
|
||||
|
||||
@@ -688,7 +689,7 @@ export async function addRobotsLater(comTeam: MemComBtlTeam, roleInfo: RoleType,
|
||||
|
||||
if (validToJoin(teamStatus)) {
|
||||
const robotCnt = 3 - teamStatus.roleIds.length;
|
||||
for(let robotIdx = 0; robotIdx < robotCnt; robotIdx++) {
|
||||
for (let robotIdx = 0; robotIdx < robotCnt; robotIdx++) {
|
||||
const joinTime = getRandValueByMinMax(COM_BTL_CONST.MIN_CAP_TIME, COM_BTL_CONST.MAX_CAP_TIME, 0);
|
||||
setTimeout(async () => {
|
||||
const curTeamStatus = teamMap.get(teamCode);
|
||||
@@ -708,10 +709,10 @@ export async function addRobotsLater(comTeam: MemComBtlTeam, roleInfo: RoleType,
|
||||
* @returns
|
||||
*/
|
||||
export async function oneTeamNotInBlack(teams: ComBattleTeamType[], roleId: string) {
|
||||
for(let team of teams) {
|
||||
for (let team of teams) {
|
||||
let { roleIds } = team;
|
||||
const inBlackList = await teammateInBlackList(roleId, roleIds);
|
||||
if(!inBlackList) {
|
||||
if (!inBlackList) {
|
||||
return team;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as taskUtil from '../pubUtils/taskUtil';
|
||||
import { RoleType } from '../db/Role';
|
||||
import { RoleModel, RoleType } from '../db/Role';
|
||||
import { pinus, FrontendOrBackendSession } from 'pinus';
|
||||
import { resResult, shouldRefresh } from '../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE, TASK_FUN_TYPE, SHOP_REFRESH_TYPE } from '../consts';
|
||||
@@ -120,13 +120,20 @@ export async function checkTaskInComBattleEnd(roleStatus: RoleStatus[], capId: s
|
||||
console.log('********', JSON.stringify(roleStatus), capId, quality)
|
||||
for (let { roleId, isRobot } of roleStatus) {
|
||||
if (!isRobot) {
|
||||
|
||||
let { serverId } = await RoleModel.findByRoleId(roleId);
|
||||
|
||||
if (roleId == capId && roleStatus.length > 1) { // 招募队友
|
||||
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, 1, true, {});
|
||||
} else if (roleId !== capId) { // 协助寻宝
|
||||
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_ASSIST_TEAM, 1, true, {});
|
||||
//活动任务
|
||||
await checkActivityTask(serverId, null, null, roleId, TASK_TYPE.COM_BATTLE_ASSIST_TEAM, 1);
|
||||
}
|
||||
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE, 1, true, {});
|
||||
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_QUALITY, 1, true, { quality });
|
||||
//活动任务
|
||||
await checkActivityTask(serverId, null, null, roleId, TASK_TYPE.COM_BATTLE, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1080,6 +1080,17 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin
|
||||
addCount = equips.length;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.COM_BATTLE:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
|
||||
case TASK_TYPE.COM_BATTLE_ASSIST_TEAM:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
addCount = 0;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user