测试:修改测试bug
This commit is contained in:
@@ -15,9 +15,9 @@ import { UserGuildApplyModel } from '../../../db/UserGuildApply';
|
||||
import { hasStructureConsume, getStructureConsume, gameData } from '../../../pubUtils/data';
|
||||
import { GuildRecModel } from '../../../db/GuildRec';
|
||||
import { sendMailByContent, SendMailFun } from '../../../services/mailService';
|
||||
import { updateUserInfo, isRoleOnline, getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { updateUserInfo, isRoleOnline, getRoleOnlineInfo } from '../../../services/redisService';
|
||||
|
||||
import { openGuildRefine } from '../../../services/guildRefineService';
|
||||
import { openGuildRefine } from '../../../services/guildRefineService';
|
||||
import { unlockTrain } from '../../../services/guildTrainService';
|
||||
import { removeBossRank } from '../../../services/guildBossService';
|
||||
import { removeTrainRank } from '../../../services/guildTrainService';
|
||||
@@ -45,15 +45,15 @@ export class GuildHandler {
|
||||
|
||||
// 检查权限是否够,包括是否参过团
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.CREATE_GUILD, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
// 检查名字是否重
|
||||
const checkNameResult = await GuildModel.checkName(name, serverId);
|
||||
if(checkNameResult) return resResult(STATUS.GUILD_NAME_DUP);
|
||||
if (checkNameResult) return resResult(STATUS.GUILD_NAME_DUP);
|
||||
|
||||
// 检查元宝是否够
|
||||
const role = await RoleModel.findByRoleId(roleId);
|
||||
if(ARMY.ARMY_CREAT_COST > role.gold) {
|
||||
if (ARMY.ARMY_CREAT_COST > role.gold) {
|
||||
return resResult(STATUS.DAILY_REFRESH_GOLD_LACK);
|
||||
}
|
||||
|
||||
@@ -61,28 +61,28 @@ export class GuildHandler {
|
||||
|
||||
// 创建公会
|
||||
const guild = await GuildModel.createGuild({ name, icon, notice }, role, serverId);
|
||||
if(!guild) return resResult(STATUS.GUILD_CREATE_ERROR);
|
||||
if (!guild) return resResult(STATUS.GUILD_CREATE_ERROR);
|
||||
guild.leader = <RoleType>guild.leader;
|
||||
//创建科技树
|
||||
await openGuildRefine(guild.code);
|
||||
await unlockTrain(guild.code, 1);
|
||||
const userGuild = await UserGuildModel.createUserGuild(guild.code, role, true);
|
||||
if(!userGuild) return resResult(STATUS.GUILD_CREATE_ERROR);
|
||||
if (!userGuild) return resResult(STATUS.GUILD_CREATE_ERROR);
|
||||
|
||||
await RoleModel.joinGuild(roleId, guild.code, guild.name);
|
||||
await UserGuildApplyModel.deleteApply(roleId); // 删除玩家所有对其他公会的申请
|
||||
|
||||
// 加入排行
|
||||
let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, {serverId});
|
||||
let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, { serverId });
|
||||
await r.setRankWithGuildInfo(guild.code, 0, Date.now(), guild);
|
||||
let r2 = new Rank(REDIS_KEY.GUILD_LV_RANK, {serverId});
|
||||
let r2 = new Rank(REDIS_KEY.GUILD_LV_RANK, { serverId });
|
||||
await r2.setRankWithGuildInfo(guild.code, 0, Date.now(), guild);
|
||||
|
||||
let rank = await r.getMyRank({ guildCode: guild.code });
|
||||
|
||||
// 加入channel
|
||||
session.set('guildCode', guild.code);
|
||||
session.push('guildCode', () => {});
|
||||
session.push('guildCode', () => { });
|
||||
addRoleToGuildChannel(roleId, sid, guild.code);
|
||||
|
||||
// 添加动态
|
||||
@@ -91,28 +91,28 @@ export class GuildHandler {
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
|
||||
// 返回
|
||||
const result = { ...guild, rank, myInfo: { ...userGuild, isOnline: true}};
|
||||
const result = { ...guild, rank, myInfo: { ...userGuild, isOnline: true } };
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
// 获取军团列表
|
||||
async getGuildList(msg: { page: number, showPeopleMax: boolean, name: string }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
// const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const { page = 1, showPeopleMax, name } = msg;
|
||||
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_GUILD_LIST, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guildList = await GuildModel.findByCondition(page, showPeopleMax, name, serverId);
|
||||
const applyList = await UserGuildApplyModel.findApplyByRole(roleId);
|
||||
|
||||
const { quitGuildTime: quitTime = 0 } = await RoleModel.findByRoleId(roleId);
|
||||
|
||||
const list = new Array<GuildListInfo>();
|
||||
for(let guild of guildList) {
|
||||
const list = new Array<GuildListInfo>();
|
||||
for (let guild of guildList) {
|
||||
let info = new GuildListInfo(guild);
|
||||
|
||||
let hasApply = applyList.find(cur => cur.guildCode == guild.code);
|
||||
@@ -128,10 +128,10 @@ export class GuildHandler {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const { code, name, notice, introduce, ceLimit, isAuto } = msg;
|
||||
if(!name) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!name) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.SET_INFO, roleId, code);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const select = ['code', 'name', 'notice', 'introduce', 'ceLimit', 'isAuto', 'icon'];
|
||||
const guild = await GuildModel.updateInfo(code, { name, notice, introduce, ceLimit, isAuto }, {}, select.join(' '));
|
||||
@@ -145,7 +145,7 @@ export class GuildHandler {
|
||||
// 返回
|
||||
return resResult(STATUS.SUCCESS, { ...guild });
|
||||
}
|
||||
|
||||
|
||||
// 游客查看军团详细信息
|
||||
async getGuildInfo(msg: { code: string }, session: BackendSession) {
|
||||
|
||||
@@ -154,7 +154,7 @@ export class GuildHandler {
|
||||
const { code } = msg;
|
||||
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_GUILD_INFO, roleId, code);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const select = ['code', 'name', 'notice', 'ceLimit', 'isAuto', 'icon', 'lv', 'memberCnt', 'guildCe'];
|
||||
const guild = await GuildModel.findByCode(code, serverId, select.join(' '));
|
||||
@@ -162,7 +162,7 @@ export class GuildHandler {
|
||||
delete guild.leader;
|
||||
// 返回
|
||||
return resResult(STATUS.SUCCESS, { ...guild, leader: leader.roleName });
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 团长授权头衔
|
||||
@@ -177,96 +177,96 @@ export class GuildHandler {
|
||||
const hisUserGuild = await UserGuildModel.getMyGuild(memberRoleId, 'auth guildCode job');
|
||||
|
||||
const checkMyResult = await checkAuth(GUILD_OPERATE.SET_AUTH, roleId, null, myUserGuild);
|
||||
if(!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.BE_SET_AUTH, memberRoleId, myUserGuild.guildCode, hisUserGuild);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const { guildCode: code } = myUserGuild;
|
||||
|
||||
if(auth == hisUserGuild.auth) {
|
||||
if (auth == hisUserGuild.auth) {
|
||||
return resResult(STATUS.GUILD_AUTH_NOT_CHANGE);
|
||||
}
|
||||
|
||||
// 管理员最大数 等策划表
|
||||
let guild = await GuildModel.findByCode(code, serverId, 'managerCnt lv');
|
||||
if(!guild) {
|
||||
if (!guild) {
|
||||
return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
}
|
||||
|
||||
let managerCntInc = 0;
|
||||
if(auth == GUILD_AUTH.LEADER) { // 转让团长
|
||||
if(hisUserGuild.auth == GUILD_AUTH.MANAGER) {
|
||||
if (auth == GUILD_AUTH.LEADER) { // 转让团长
|
||||
if (hisUserGuild.auth == GUILD_AUTH.MANAGER) {
|
||||
managerCntInc = -1;
|
||||
}
|
||||
} else {
|
||||
managerCntInc = auth == GUILD_AUTH.MANAGER? 1: -1;
|
||||
} else {
|
||||
managerCntInc = auth == GUILD_AUTH.MANAGER ? 1 : -1;
|
||||
}
|
||||
|
||||
let maxManagerCnt = gameData.centerBase.get(guild.lv);
|
||||
if(!maxManagerCnt) return STATUS.DIC_DATA_NOT_FOUND;
|
||||
if (!maxManagerCnt) return STATUS.DIC_DATA_NOT_FOUND;
|
||||
|
||||
if(guild.managerCnt + managerCntInc > maxManagerCnt.managerNum) {
|
||||
if (guild.managerCnt + managerCntInc > maxManagerCnt.managerNum) {
|
||||
return resResult(STATUS.GUILD_MANAGER_REACH_MAX);
|
||||
}
|
||||
|
||||
const userGuild = await UserGuildModel.updateInfo(memberRoleId, { auth, job: auth == GUILD_AUTH.LEADER? GUILD_JOB.JIANGJUN: hisUserGuild.job }, {}, 'auth'); // 设置权限
|
||||
if(!userGuild) {
|
||||
const userGuild = await UserGuildModel.updateInfo(memberRoleId, { auth, job: auth == GUILD_AUTH.LEADER ? GUILD_JOB.JIANGJUN : hisUserGuild.job }, {}, 'auth'); // 设置权限
|
||||
if (!userGuild) {
|
||||
return resResult(STATUS.GUILD_MEMBER_NOT_FOUND);
|
||||
}
|
||||
|
||||
const role = await RoleModel.findByRoleId(memberRoleId);
|
||||
let updateObject = {};
|
||||
if(auth == GUILD_AUTH.LEADER) { // 转让团长
|
||||
if (auth == GUILD_AUTH.LEADER) { // 转让团长
|
||||
updateObject['leader'] = role._id;
|
||||
await UserGuildModel.updateInfo(roleId, { auth: GUILD_AUTH.MEMBER, job: GUILD_JOB.SHIBING }, {}); // 自己降权限
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{field: 'leader', value: new GuildLeader(role) } ]);
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{ field: 'leader', value: new GuildLeader(role) }]);
|
||||
}
|
||||
|
||||
guild = await GuildModel.updateInfo(code, updateObject, { managerCnt: managerCntInc }, 'managerCnt code name'); // 如果有转让团长设置leader
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
|
||||
// 添加动态
|
||||
if(auth == GUILD_AUTH.MANAGER) {
|
||||
if (auth == GUILD_AUTH.MANAGER) {
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.SET_MANAGER, [role.roleName]);
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { managerCnt: guild.managerCnt });
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_MANAGER, memberRoleId, { sendName: roleName, params: [guild.name] });
|
||||
} else if (auth == GUILD_AUTH.LEADER) {
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.SET_LEADER, [roleName, role.roleName]);
|
||||
this.app.rpc.chat.guildRemote.changeLeader.toServer(chatSid, code, guild.managerCnt, role, roleId);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
this.app.rpc.chat.guildRemote.changeLeader.toServer(chatSid, code, guild.managerCnt, role, roleId);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_LEADER, memberRoleId, { sendName: roleName, params: [guild.name] });
|
||||
} else {
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid,code, { managerCnt: guild.managerCnt });
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { managerCnt: guild.managerCnt });
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_MEMBER, memberRoleId, { sendName: roleName, params: [guild.name] });
|
||||
}
|
||||
|
||||
|
||||
// 返回
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
roleId: memberRoleId, auth: userGuild.auth, managerCnt: guild.managerCnt
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 团员获取自己军团详细信息
|
||||
async getMyGuildInfo(msg: { }, session: BackendSession) {
|
||||
async getMyGuildInfo(msg: {}, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'job auth guildCode receivedActive activeRecord activeDaily activeWeekly');
|
||||
if(!userGuild) {
|
||||
if (!userGuild) {
|
||||
return resResult(STATUS.SUCCESS, { hasGuild: false })
|
||||
};
|
||||
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_MY_GUILD_INFO, roleId, userGuild.guildCode, userGuild);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
let guild = await getGuildWithRefActive(userGuild.guildCode, serverId);
|
||||
if(!guild) {
|
||||
if (!guild) {
|
||||
return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -285,18 +285,18 @@ export class GuildHandler {
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.APPLY_GUILD, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
if(!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
if (!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
const { isMemberMax, isAuto, ceLimit, lv } = guild;
|
||||
if(isMemberMax) {
|
||||
if (isMemberMax) {
|
||||
return resResult(STATUS.GUILD_MEMBER_MAX);
|
||||
}
|
||||
|
||||
const role = await RoleModel.findByRoleId(roleId, null, true);
|
||||
if(ceLimit > role.ce) {
|
||||
if (ceLimit > role.ce) {
|
||||
return resResult(STATUS.GUILD_NOT_REACH_CONDI);
|
||||
}
|
||||
// TODO 暂时关闭
|
||||
@@ -305,9 +305,9 @@ export class GuildHandler {
|
||||
// }
|
||||
|
||||
let hasGuild = false;
|
||||
if(isAuto) { // 自动加入
|
||||
if (isAuto) { // 自动加入
|
||||
const joinResult = await joinGuild(code, guild.name, lv, roleId, serverId, session);
|
||||
if(joinResult.status == -1) {
|
||||
if (joinResult.status == -1) {
|
||||
return joinResult.resResult;
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ export class GuildHandler {
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid,rec);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
hasGuild = true;
|
||||
} else { // 不自动加入,插入申请表
|
||||
await UserGuildApplyModel.createUserGuildApply(role, guild, GUILD_APPLY_TYPE.APPLY);
|
||||
@@ -329,17 +329,17 @@ export class GuildHandler {
|
||||
|
||||
// 玩家申请公会
|
||||
async getApplyList(msg: { code: string, lastApplyCode: string }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const { code, lastApplyCode } = msg;
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_APPLY_LIST, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const result = await UserGuildApplyModel.findApplyByGuild(code, lastApplyCode);
|
||||
const list = [];
|
||||
for(let cur of result) {
|
||||
for (let cur of result) {
|
||||
let role = <RoleType>cur.role;
|
||||
delete cur.role;
|
||||
let isOnline = await isRoleOnline(role.roleId);
|
||||
@@ -351,7 +351,7 @@ export class GuildHandler {
|
||||
|
||||
// 团长同意/拒绝公会申请
|
||||
async receiveApply(msg: { code: string, applyCodeList: [string], isReceived: boolean }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
@@ -359,28 +359,28 @@ export class GuildHandler {
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.RECEIVE_APPLY, roleId, code);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const applyList = await UserGuildApplyModel.getListByApplyCode(applyCodeList);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
let roleIds = new Array<string>();
|
||||
if(isReceived) { // 同意申请,加入
|
||||
|
||||
for(let { roleId } of applyList) {
|
||||
if (isReceived) { // 同意申请,加入
|
||||
|
||||
for (let { roleId } of applyList) {
|
||||
const joinResult = await joinGuild(code, guild.name, guild.lv, roleId, serverId, session);
|
||||
if(joinResult.status == -1) continue;
|
||||
if (joinResult.status == -1) continue;
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
// 更新人数增加
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [joinResult.roleName]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid,rec);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
|
||||
roleIds.push(roleId);
|
||||
}
|
||||
} else { // 拒绝申请,删除申请
|
||||
for(let { roleId } of applyList) {
|
||||
for (let { roleId } of applyList) {
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_APPLY_REFUSE, roleId, { sendName: roleName, params: [guild.name] });
|
||||
}
|
||||
|
||||
@@ -391,37 +391,37 @@ export class GuildHandler {
|
||||
}
|
||||
|
||||
// 团长查看(刷新)可邀请人列表
|
||||
async getInviteMemberList(msg: { }, session: BackendSession) {
|
||||
|
||||
async getInviteMemberList(msg: {}, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
|
||||
let myGuild = await UserGuildModel.getMyGuild(roleId, USER_GUILD_SELECT.ENTRY)
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_INIVATION_MEMBER_LIST, roleId, myGuild.guildCode, myGuild);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
let guild = await GuildModel.findByCode(myGuild.guildCode, serverId, GUILD_SELECT.INVITED_MEMBER);
|
||||
let invitedMembers = guild.invitedMembers;
|
||||
if(shouldRefresh(guild.inviteTime, new Date())) {
|
||||
if (shouldRefresh(guild.inviteTime, new Date())) {
|
||||
invitedMembers = [];
|
||||
}
|
||||
|
||||
// 离线时间,三天内在线且尚未加入军团。按以下规则排序 离线时间 玩家等级 玩家战力
|
||||
|
||||
|
||||
const day = <number>getTimeFun().getBeforeDay(3);
|
||||
|
||||
const { quitGuildTime: quitTime = 0 } = await RoleModel.findByRoleId(roleId);
|
||||
let allList = await RoleModel.getInviteList(day, serverId);
|
||||
allList = allList.filter(cur => !invitedMembers.includes(cur.roleId))
|
||||
let list = getRandEelm(allList, 10);
|
||||
if(!list.length) list = allList;
|
||||
if (!list.length) list = allList;
|
||||
list = sortArrRandom(list);
|
||||
|
||||
let result = [];
|
||||
for(let cur of list) {
|
||||
for (let cur of list) {
|
||||
let isOnline = await isRoleOnline(cur.roleId);
|
||||
result.push({...cur, isOnline})
|
||||
result.push({ ...cur, isOnline })
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, { quitTime, list: result });
|
||||
@@ -430,27 +430,27 @@ export class GuildHandler {
|
||||
|
||||
// 团长(一键)邀请人
|
||||
async inviteMember(msg: { code: string, roleIds: string[] }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const { code, roleIds } = msg;
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.INVATE_MEMBER, roleId, code);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId, GUILD_SELECT.INVITED_MEMBER);
|
||||
if(guild.isMemberMax) return resResult(STATUS.GUILD_MEMBER_MAX);
|
||||
if (guild.isMemberMax) return resResult(STATUS.GUILD_MEMBER_MAX);
|
||||
|
||||
const roleList = await RoleModel.findRoleByField('roleId', roleIds);
|
||||
let result = new Array<string>();
|
||||
let uids = [];
|
||||
for(let role of roleList) {
|
||||
if(!role.hasGuild) {
|
||||
for (let role of roleList) {
|
||||
if (!role.hasGuild) {
|
||||
await UserGuildApplyModel.createUserGuildApply(role, guild, GUILD_APPLY_TYPE.INVITE);
|
||||
result.push(role.roleId);
|
||||
let hisInfo = await getRoleOnlineInfo(role.roleId);
|
||||
if(hisInfo.isOnline) {
|
||||
if (hisInfo.isOnline) {
|
||||
uids.push({ uid: role.roleId, sid: hisInfo.sid })
|
||||
}
|
||||
}
|
||||
@@ -464,13 +464,13 @@ export class GuildHandler {
|
||||
|
||||
// 成员收到邀请列表
|
||||
async getInvitationList(msg: { lastApplyCode: string }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const { lastApplyCode } = msg;
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_INVITATION_LIST, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const result = await UserGuildApplyModel.findInviteByRole(roleId, lastApplyCode);
|
||||
const list = result.map(cur => {
|
||||
@@ -487,25 +487,25 @@ export class GuildHandler {
|
||||
|
||||
// 成员同意/拒绝邀请
|
||||
async receiveInvitation(msg: { applyCode: string, isReceived: boolean }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const { applyCode, isReceived } = msg;
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.RECEIVE_INVITAION, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const invite = await UserGuildApplyModel.findByCode(applyCode);
|
||||
if(!invite) return resResult(STATUS.GUILD_INVITE_NOT_FOUND);
|
||||
if (!invite) return resResult(STATUS.GUILD_INVITE_NOT_FOUND);
|
||||
|
||||
let code: string;
|
||||
if(isReceived) { // 同意申请,加入
|
||||
if (isReceived) { // 同意申请,加入
|
||||
const { guildCode } = invite;
|
||||
const guild = await GuildModel.findByCode(guildCode, serverId);
|
||||
|
||||
|
||||
const joinResult = await joinGuild(guildCode, guild.name, guild.lv, roleId, serverId, session);
|
||||
if(joinResult.status == -1) {
|
||||
if (joinResult.status == -1) {
|
||||
return joinResult.resResult;
|
||||
}
|
||||
|
||||
@@ -525,23 +525,23 @@ export class GuildHandler {
|
||||
|
||||
// 获取军团成员
|
||||
async getGuildMember(msg: { code: string, sort: string }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
// const serverId = session.get('serverId');
|
||||
const { code, sort } = msg;
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_MEMBER_LIST_MAIN, roleId, code);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
let select = ['role', 'job'];
|
||||
const checkDetailResult = await checkAuth(GUILD_OPERATE.GET_MEMBER_LIST_DETAIL, roleId, code);
|
||||
if(checkDetailResult) {
|
||||
if (checkDetailResult) {
|
||||
select.push('auth', 'activeWeekly activeUpdateTime');
|
||||
}
|
||||
let list = await UserGuildModel.getListByGuild(code, select.join(' '), { auth: 1 });
|
||||
let result = [];
|
||||
for(let cur of list) {
|
||||
for (let cur of list) {
|
||||
let role = <RoleType>cur.role;
|
||||
delete role._id;
|
||||
delete cur.role;
|
||||
@@ -551,8 +551,8 @@ export class GuildHandler {
|
||||
let leader = result.shift();
|
||||
|
||||
result.sort((a, b) => {
|
||||
if(sort == 'active') {
|
||||
if(b.activeWeekly == a.activeWeekly) {
|
||||
if (sort == 'active') {
|
||||
if (b.activeWeekly == a.activeWeekly) {
|
||||
return a.activeUpdateTime - b.activeUpdateTime
|
||||
} else {
|
||||
return b.activeWeekly - a.activeWeekly
|
||||
@@ -570,17 +570,17 @@ export class GuildHandler {
|
||||
|
||||
// 团长解散军团
|
||||
async dismiss(msg: { code: string }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const { code } = msg;
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.DISMISS, roleId, code);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await GuildModel.dismiss(code, serverId);
|
||||
if(!guild) return resResult(STATUS.GUILD_DELETE_ERROR);
|
||||
if (!guild) return resResult(STATUS.GUILD_DELETE_ERROR);
|
||||
|
||||
await UserGuildModel.dismiss(code);
|
||||
const { members } = guild;
|
||||
@@ -590,11 +590,11 @@ export class GuildHandler {
|
||||
// 删除channel
|
||||
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.dismiss.toServer(chatSid,code);
|
||||
this.app.rpc.chat.guildRemote.dismiss.toServer(chatSid, code);
|
||||
|
||||
let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, {serverId});
|
||||
let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, { serverId });
|
||||
await r.removeFromRank({ guildCode: code });
|
||||
let r2 = new Rank(REDIS_KEY.GUILD_LV_RANK, {serverId});
|
||||
let r2 = new Rank(REDIS_KEY.GUILD_LV_RANK, { serverId });
|
||||
await r2.removeFromRank({ guildCode: code });
|
||||
|
||||
return resResult(STATUS.SUCCESS, { code, status: guild.status });
|
||||
@@ -602,7 +602,7 @@ export class GuildHandler {
|
||||
|
||||
// 成员退出军团
|
||||
async quit(msg: { code: string }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
@@ -611,16 +611,16 @@ export class GuildHandler {
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.QUIT, roleId, code);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const userGuild = await UserGuildModel.quit(code, roleId);
|
||||
if(!userGuild) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
if (!userGuild) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
|
||||
const role = await RoleModel.quitGuild(roleId, nowSeconds());
|
||||
if(!role) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
if (!role) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
|
||||
const guild = await GuildModel.quit(code, roleId, serverId, role.ce, userGuild.auth == GUILD_AUTH.MANAGER);
|
||||
if(!guild) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
if (!guild) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }])
|
||||
|
||||
//删除排名信息
|
||||
@@ -629,18 +629,18 @@ export class GuildHandler {
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.QUIT_GUILD, [roleName]);
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid,rec);
|
||||
this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid,code, roleId, guild, sid);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid, code, roleId, guild, sid);
|
||||
|
||||
session.set('guildCode', '');
|
||||
session.push('guild', () => {});
|
||||
|
||||
session.push('guild', () => { });
|
||||
|
||||
return resResult(STATUS.SUCCESS, { hasGuild: role.hasGuild });
|
||||
}
|
||||
|
||||
// 团长踢退出军团
|
||||
async kick(msg: { code: string, roleId: string }, session: BackendSession) {
|
||||
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
@@ -648,21 +648,21 @@ export class GuildHandler {
|
||||
|
||||
// 检查权限
|
||||
const checkMyAuth = await checkAuth(GUILD_OPERATE.KICK, roleId, code);
|
||||
if(!checkMyAuth) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkMyAuth) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
// 被踢出的权限
|
||||
const checkHisAuth = await checkAuth(GUILD_OPERATE.BE_KICKED, memberRoleId, code);
|
||||
if(!checkHisAuth) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkHisAuth) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
|
||||
const userGuild = await UserGuildModel.quit(code, memberRoleId);
|
||||
if(!userGuild) return resResult(STATUS.GUILD_KICK_ERROR);
|
||||
if (!userGuild) return resResult(STATUS.GUILD_KICK_ERROR);
|
||||
|
||||
const role = await RoleModel.quitGuild(memberRoleId, nowSeconds());
|
||||
if(!role) return resResult(STATUS.GUILD_KICK_ERROR);
|
||||
if (!role) return resResult(STATUS.GUILD_KICK_ERROR);
|
||||
|
||||
const guild = await GuildModel.quit(code, memberRoleId, serverId, role.ce, userGuild.auth == GUILD_AUTH.MANAGER);
|
||||
if(!guild) return resResult(STATUS.GUILD_KICK_ERROR);
|
||||
if (!guild) return resResult(STATUS.GUILD_KICK_ERROR);
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }])
|
||||
|
||||
//删除排名信息
|
||||
@@ -671,11 +671,11 @@ export class GuildHandler {
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
|
||||
const { sid } = await getRoleOnlineInfo(roleId);
|
||||
this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid,code, roleId, guild, sid);
|
||||
this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid, code, roleId, guild, sid);
|
||||
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.QUIT_GUILD, [role.roleName]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid,rec);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_KICK, memberRoleId, { sendName: roleName, params: [guild.name] });
|
||||
|
||||
return resResult(STATUS.SUCCESS, { memberCnt: guild.memberCnt });
|
||||
@@ -709,9 +709,9 @@ export class GuildHandler {
|
||||
return resResult(STATUS.GUILD_MEMBER_NOT_FOUND);
|
||||
}
|
||||
let topUserGuild: UserGuildType;
|
||||
for(let userGuild of topUserGuilds) {
|
||||
for (let userGuild of topUserGuilds) {
|
||||
let role = await RoleModel.findByRoleId(userGuild.roleId, 'quitTime');
|
||||
if(role && role.quitTime > <number>getTimeFun().getBeforeDay(3)) {
|
||||
if (role && role.quitTime > <number>getTimeFun().getBeforeDay(3)) {
|
||||
topUserGuild = userGuild; break;
|
||||
}
|
||||
}
|
||||
@@ -721,7 +721,7 @@ export class GuildHandler {
|
||||
|
||||
// 检查元宝是否够
|
||||
const role = await RoleModel.findByRoleId(roleId);
|
||||
if(ARMY.ARMY_IMPEACH_COST > role.gold) {
|
||||
if (ARMY.ARMY_IMPEACH_COST > role.gold) {
|
||||
return resResult(STATUS.DAILY_REFRESH_GOLD_LACK);
|
||||
}
|
||||
await handleCost(roleId, sid, [getGoldObject(ARMY.ARMY_IMPEACH_COST)]);
|
||||
@@ -737,14 +737,14 @@ export class GuildHandler {
|
||||
|
||||
// 添加动态
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.IMPEACH, [ oldRoleName, topUser.roleName]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid,rec);
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.IMPEACH, [oldRoleName, topUser.roleName]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
|
||||
this.app.rpc.chat.guildRemote.changeLeader.toServer(chatSid,code, guild.managerCnt, topUser, leaderRoleId);
|
||||
this.app.rpc.chat.guildRemote.changeLeader.toServer(chatSid, code, guild.managerCnt, topUser, leaderRoleId);
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_IMPEACH, leaderRoleId, { sendName: roleName, params: [guild.name] });
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_LEADER, topUser.roleId, { sendName: roleName, params: [guild.name] });
|
||||
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{field: 'leader', value: new GuildLeader(topUser) } ]);
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{ field: 'leader', value: new GuildLeader(topUser) }]);
|
||||
|
||||
let isOnline = await isRoleOnline(topUser.roleId);
|
||||
const leader = { ...topUser, ce: topUser.ce, isOnline }
|
||||
@@ -767,45 +767,45 @@ export class GuildHandler {
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId, 'lv structure');
|
||||
if(!guild) {
|
||||
if (!guild) {
|
||||
return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
}
|
||||
|
||||
const { lv, structure } = guild;
|
||||
const curStructure = structure.find(cur => cur.id == id);
|
||||
if(!curStructure) {
|
||||
if (!curStructure) {
|
||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||
}
|
||||
if(id != GUILD_STRUCTURE.ARMY_CENTER && curStructure.lv >= lv) { // 中军大帐以外建筑物
|
||||
if(curStructure.lv >= lv) {
|
||||
if (id != GUILD_STRUCTURE.ARMY_CENTER && curStructure.lv >= lv) { // 中军大帐以外建筑物
|
||||
if (curStructure.lv >= lv) {
|
||||
return resResult(STATUS.GUILD_STRUCTURE_LV_MAX);
|
||||
}
|
||||
}
|
||||
if(!hasStructureConsume(id, curStructure.lv + 1)) {
|
||||
if (!hasStructureConsume(id, curStructure.lv + 1)) {
|
||||
return resResult(STATUS.GUILD_STRUCTURE_LV_MAX);
|
||||
}
|
||||
const cost = getStructureConsume(id, curStructure.lv);
|
||||
|
||||
|
||||
const result = await GuildModel.upStructure(code, id, cost, 'code fund structure lv name');
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
return resResult(STATUS.GUILD_FUND_NOT_ENOUGH);
|
||||
}
|
||||
if(id == GUILD_STRUCTURE.ARMY_CENTER) {
|
||||
if (id == GUILD_STRUCTURE.ARMY_CENTER) {
|
||||
let r = new Rank(REDIS_KEY.GUILD_LV_RANK, { serverId });
|
||||
await r.setRankWithGuildInfo(code, guild.lv, guild.lvUpdateTime, guild);
|
||||
await r.setRankWithGuildInfo(code, guild.lv, guild.lvUpdateTime, guild);
|
||||
}
|
||||
|
||||
|
||||
const resultStructure = result.structure.find(cur => cur.id == id);
|
||||
|
||||
// 修改信息
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid,code, { ...result });
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{field: 'lv', value: result.lv } ]);
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { ...result });
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{ field: 'lv', value: result.lv }]);
|
||||
|
||||
// 添加动态
|
||||
const structureName = GUILD_STRUCTURE_NAME.get(id);
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.STRUCTURE_UP, [structureName, resultStructure.lv.toString()]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid,rec);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
|
||||
// 军团频道聊天消息
|
||||
pushGuildUpStructureMsg(roleId, roleName, result, resultStructure);
|
||||
@@ -841,7 +841,7 @@ export class GuildHandler {
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId, 'members');
|
||||
if(!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
if (!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
const { members } = guild;
|
||||
//下发邮件
|
||||
@@ -865,7 +865,7 @@ export class GuildHandler {
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
if(!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
if (!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
// 发送世界频道消息
|
||||
this.app.rpc.chat.chatRemote.sendWorldMessage.toServer('chat-server-1', serverId, { info });
|
||||
@@ -884,22 +884,22 @@ export class GuildHandler {
|
||||
const { code, id } = msg;
|
||||
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'receivedActive auth guildCode');
|
||||
if(!userGuild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
if (!userGuild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.RECEIVE_ACTIVE, roleId, code, userGuild);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await getGuildWithRefActive(code, serverId);
|
||||
if(!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
if (!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
let activeDayReward = gameData.guildActiveDayReward.get(id);
|
||||
if(!activeDayReward) return resResult(STATUS.GUILD_ACTIVE_BOX_NOT_FOUND);
|
||||
if (!activeDayReward) return resResult(STATUS.GUILD_ACTIVE_BOX_NOT_FOUND);
|
||||
|
||||
if(guild.activeDaily < activeDayReward.activeDayPoint) {
|
||||
if (guild.activeDaily < activeDayReward.activeDayPoint) {
|
||||
return resResult(STATUS.GUILD_ACTIVE_POINT_NOT_REACH);
|
||||
}
|
||||
|
||||
if(userGuild.receivedActive.includes(id)) {
|
||||
if (userGuild.receivedActive.includes(id)) {
|
||||
return resResult(STATUS.GUILD_ACTIVE_BOX_HAS_RECEIVED);
|
||||
}
|
||||
userGuild.receivedActive.push(id);
|
||||
@@ -914,21 +914,21 @@ export class GuildHandler {
|
||||
}
|
||||
|
||||
// 查看活跃排行榜
|
||||
async getActiveRank(msg: { }, session: BackendSession) {
|
||||
async getActiveRank(msg: {}, session: BackendSession) {
|
||||
|
||||
let roleId = session.get('roleId');
|
||||
let serverId = session.get('serverId')
|
||||
|
||||
const myUserGuild = await UserGuildModel.getMyGuild(roleId, 'auth guildCode');
|
||||
if(!myUserGuild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
if (!myUserGuild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
// 检查权限
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_ACTIVE_RANK, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, { serverId });
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({ guildCode: myUserGuild.guildCode });
|
||||
if(!myRank) {
|
||||
if (!myRank) {
|
||||
let guild = await GuildModel.findByCode(myUserGuild.guildCode, serverId, 'code icon name lv leader activeWeekly');
|
||||
myRank = await r.generMyRankWithGuild(myUserGuild.guildCode, guild.activeWeekly, guild.activeUpdateTime, guild);
|
||||
}
|
||||
@@ -944,7 +944,7 @@ export class GuildHandler {
|
||||
const { code, active, id } = msg;
|
||||
|
||||
const result = await addActive(roleId, serverId, id, null, active);
|
||||
if(result.status == 0) return result.resResult;
|
||||
if (result.status == 0) return result.resResult;
|
||||
const { guild, userGuild } = result;
|
||||
|
||||
let { activeDaily, activeWeekly } = guild;
|
||||
@@ -956,7 +956,7 @@ export class GuildHandler {
|
||||
}
|
||||
|
||||
// debug接口: 调用定时任务
|
||||
async debugWeeklyRask(msg: { }, session: BackendSession) {
|
||||
async debugWeeklyRask(msg: {}, session: BackendSession) {
|
||||
|
||||
await settleGuildWeekly();
|
||||
return resResult(STATUS.SUCCESS);
|
||||
@@ -968,7 +968,7 @@ export class GuildHandler {
|
||||
const { code, count } = msg;
|
||||
const guild = await GuildModel.updateInfo(code, {}, { fund: count }, 'fund');
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, {fund: guild.fund});
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { fund: guild.fund });
|
||||
return resResult(STATUS.SUCCESS, { code, fund: guild.fund });
|
||||
}
|
||||
|
||||
@@ -980,8 +980,63 @@ export class GuildHandler {
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
const leader = <RoleType>guild.leader;
|
||||
let threeDaysBefore = <number>getTimeFun().getBeforeDay(3);
|
||||
await RoleModel.updateRoleInfo(leader.roleId, { quitTime: threeDaysBefore } );
|
||||
await RoleModel.updateRoleInfo(leader.roleId, { quitTime: threeDaysBefore });
|
||||
|
||||
return resResult(STATUS.SUCCESS, { code });
|
||||
}
|
||||
}
|
||||
|
||||
// debug接口: 加入公会
|
||||
async debugJoinGuild(msg: { code: string }, session: BackendSession) {
|
||||
const { code } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
if (!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
const { isMemberMax, isAuto, ceLimit, lv } = guild;
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
if (role.guildCode) {
|
||||
let oldCode = role.guildCode;
|
||||
const userGuild = await UserGuildModel.quit(oldCode, roleId);
|
||||
if (!userGuild) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
|
||||
role = await RoleModel.quitGuild(roleId, nowSeconds());
|
||||
if (!role) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
|
||||
const guild = await GuildModel.quit(oldCode, roleId, serverId, role.ce, userGuild.auth == GUILD_AUTH.MANAGER);
|
||||
if (!guild) return resResult(STATUS.GUILD_QUIT_ERROR);
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }])
|
||||
|
||||
//删除排名信息
|
||||
await removeBossRank(oldCode, roleId);
|
||||
await removeTrainRank(oldCode, roleId, guild.trainId);
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, oldCode, GUILD_REC_TYPE.QUIT_GUILD, [roleName]);
|
||||
let chatSid = await getGuildChannelSid(oldCode);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid, oldCode, roleId, guild, sid);
|
||||
|
||||
session.set('guildCode', '');
|
||||
session.push('guild', () => { });
|
||||
}
|
||||
|
||||
const joinResult = await joinGuild(code, guild.name, lv, roleId, serverId, session);
|
||||
if (joinResult.status == -1) {
|
||||
return joinResult.resResult;
|
||||
}
|
||||
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [roleName]);
|
||||
// 更新人数增加
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
return resResult(STATUS.SUCCESS, { code });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CHANNEL_PREFIX, MSG_SOURCE, CHANNEL_TYPE } from './../../../consts/cons
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop,delPrivateMsg } from '../../../services/chatService';
|
||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg } from '../../../services/chatService';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { checkActivityTask, checkTaskWithArgs } from '../../../services/taskService';
|
||||
|
||||
@@ -92,15 +92,17 @@ export class ChatHandler {
|
||||
let channelId = '';
|
||||
if (channel === CHANNEL_PREFIX.WORLD) channelId = `${serverId}`;
|
||||
if (channel === CHANNEL_PREFIX.GUILD) channelId = guildCode;
|
||||
|
||||
const msgData = await createGroupMsg(roleId, roleName, channel, channelId, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode);
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
|
||||
// 任务
|
||||
await checkTaskWithArgs(roleId, sid, funcs, TASK_TYPE.CHAT, [CHANNEL_TYPE.get(channel)]);
|
||||
|
||||
//活动任务
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.CHAT, 1, { chatType: CHANNEL_TYPE.get(channel) })
|
||||
return resResult(STATUS.SUCCESS);
|
||||
|
||||
return resResult(STATUS.SUCCESS, msgData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,11 +27,11 @@ export class HeroHandler {
|
||||
public async test(msg: {}, session: BackendSession) {
|
||||
let sid = session.get('sid');
|
||||
|
||||
for(let i = 0; i < 3; i++) {
|
||||
let heroes = await HeroModel.find({}).sort({createdAt: 1}).limit(1000).skip(i*1000).lean();
|
||||
for(let {hid, roleId, roleName, skins} of heroes) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
let heroes = await HeroModel.find({}).sort({ createdAt: 1 }).limit(1000).skip(i * 1000).lean();
|
||||
for (let { hid, roleId, roleName, skins } of heroes) {
|
||||
await HeroModel.updateHeroInfo(roleId, hid, { skins: [] });
|
||||
for(let {id, enable } of skins) {
|
||||
for (let { id, enable } of skins) {
|
||||
console.log(i, roleId, roleName, id);
|
||||
await addSkin(roleId, roleName, id, enable);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ export class HeroHandler {
|
||||
|
||||
let { star: oldStar, starStage: oldStarStage, quality } = hero;
|
||||
if (oldStar != star || oldStarStage != starStage) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
return resResult(STATUS.WRONG_PARMS, { oldStarStage, oldStar, star, starStage });
|
||||
}
|
||||
if (oldStar == HERO_GROW_MAX.STAR) {
|
||||
return resResult(STATUS.ROLE_STAR_REACH_MAX);
|
||||
|
||||
@@ -109,10 +109,12 @@ export class GachaPull {
|
||||
|
||||
constructor(gachaType: GACHA_ID, lv: number, userHeroes: HeroType[]) {
|
||||
this.gachaType = gachaType;
|
||||
if(gachaType == GACHA_ID.NORMAL) { // 元宝招募,金色武将保底,按次数给保底,抽到就重新计算次数,单抽也算
|
||||
this.dicFloorType = GACHA_FLOOR_TYPE.GOLD;
|
||||
if (gachaType == GACHA_ID.NORMAL) { // 元宝招募,金色武将保底,按次数给保底,抽到就重新计算次数,单抽也算
|
||||
this.dicFloorType = GACHA_FLOOR_TYPE.GOLD;
|
||||
} else if (gachaType == GACHA_ID.ASSIGN || gachaType == GACHA_ID.TIMELIMIT) { // 求贤若渴,和活动抽卡金色保底,伪随机,n次内给且只给一个,单抽也算
|
||||
this.dicFloorType = GACHA_FLOOR_TYPE.ASSIGN;
|
||||
} else {
|
||||
this.dicFloorType = GACHA_FLOOR_TYPE.GOLD;
|
||||
}
|
||||
this.userHeroes = userHeroes;
|
||||
this.lv = lv;
|
||||
@@ -124,23 +126,23 @@ export class GachaPull {
|
||||
let percent = dicGacha.percent;
|
||||
// 设置pickup的武将
|
||||
let newPercent = [];
|
||||
for(let { id, weight } of percent) {
|
||||
if(id == gameData.gachaContentHero.get(0)) {
|
||||
for (let { id, weight } of percent) {
|
||||
if (id == gameData.gachaContentHero.get(0)) {
|
||||
newPercent.push({ id, weight, goodId: userGacha.pickHero })
|
||||
} else {
|
||||
newPercent.push({ id, weight });
|
||||
}
|
||||
}
|
||||
this.percent = newPercent;
|
||||
if(dicGacha.floorReward > 0) {
|
||||
if (dicGacha.floorReward > 0) {
|
||||
this.dicFloor = this.percent[dicGacha.floorReward - 1];
|
||||
}
|
||||
this.dicFloorCount = getDicGachaFloor(this.dicFloorType);
|
||||
// 玩家数据
|
||||
let userFloor = userGacha.floor.find(cur => cur.id == this.dicFloorType);
|
||||
if(userFloor) {
|
||||
if (userFloor) {
|
||||
this.floorCount = userFloor.count;
|
||||
this.hasGetFloor = userFloor.hasGetFloor||false;
|
||||
this.hasGetFloor = userFloor.hasGetFloor || false;
|
||||
}
|
||||
this.hope = userGacha.hope;
|
||||
}
|
||||
@@ -150,27 +152,27 @@ export class GachaPull {
|
||||
this.hasGetFloor = item.hasGetFloor;
|
||||
this.percent = item.percent;
|
||||
this.dicFloorCount = item.floorCount;
|
||||
if(item.floorReward >= 0) {
|
||||
if (item.floorReward >= 0) {
|
||||
this.dicFloor = item.percent[item.floorReward]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private getFloorResult(base: { id: number, weight: number, goodId?: number }) {
|
||||
if(!this.dicFloor) return base;
|
||||
if (!this.dicFloor) return base;
|
||||
|
||||
let isTarget = base.id == this.dicFloor.id; // 是否抽到的就是那个保底
|
||||
if(this.dicFloorType == GACHA_FLOOR_TYPE.GOLD) { // 元宝招募 橙色 按次数保底,抽到就重计
|
||||
if(isTarget || this.floorCount + 1 >= this.dicFloorCount) {
|
||||
if (this.dicFloorType == GACHA_FLOOR_TYPE.GOLD) { // 元宝招募 橙色 按次数保底,抽到就重计
|
||||
if (isTarget || this.floorCount + 1 >= this.dicFloorCount) {
|
||||
this.floorCount = 0;
|
||||
return this.dicFloor;
|
||||
} else {
|
||||
this.floorCount ++;
|
||||
this.floorCount++;
|
||||
return base;
|
||||
}
|
||||
} else if (this.dicFloorType == GACHA_FLOOR_TYPE.ASSIGN) {
|
||||
let result = base;
|
||||
if(isTarget || this.floorCount + 1 >= this.dicFloorCount) {
|
||||
if(this.hasGetFloor) { // 已经获得过一次保底了, 不给,换个给
|
||||
if (isTarget || this.floorCount + 1 >= this.dicFloorCount) {
|
||||
if (this.hasGetFloor) { // 已经获得过一次保底了, 不给,换个给
|
||||
let { dic } = getRandEelmWithWeight(this.percent.filter(cur => cur.id != this.dicFloor.id));
|
||||
result = dic
|
||||
} else {
|
||||
@@ -178,16 +180,16 @@ export class GachaPull {
|
||||
result = this.dicFloor;
|
||||
}
|
||||
}
|
||||
this.floorCount ++;
|
||||
if(this.floorCount >= this.dicFloorCount) {
|
||||
this.floorCount++;
|
||||
if (this.floorCount >= this.dicFloorCount) {
|
||||
this.hasGetFloor = false;
|
||||
this.floorCount = 0;
|
||||
}
|
||||
console.log('******', this.floorCount, this.dicFloorCount, this.hasGetFloor )
|
||||
console.log('******', this.floorCount, this.dicFloorCount, this.hasGetFloor)
|
||||
return result;
|
||||
} else {
|
||||
return base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +203,7 @@ export class GachaPull {
|
||||
let { type, param, count } = dic;
|
||||
if (type == GACHA_CONTENT_TYPE.HERO) {
|
||||
let pool: number[] = [];
|
||||
if(this.hope.length > 0) {
|
||||
if (this.hope.length > 0) {
|
||||
pool = this.getPoolByHope(this.hope, param[0]); // 根据心愿单获得卡池
|
||||
} else {
|
||||
pool = getAllHeroByQuality(param[0]); // 没有心愿单就根据武将颜色
|
||||
@@ -251,7 +253,7 @@ export class GachaPull {
|
||||
if (h.hasGet) hasGetHope.push(h.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let list = gameData.gachaHope.map(cur => {
|
||||
return { ...cur, hasGet: hopeMap.get(cur.id)?.hasGet || false };
|
||||
})
|
||||
@@ -303,17 +305,17 @@ export class GachaPull {
|
||||
}
|
||||
|
||||
private getPurpleFloor(count: number, index: number, contentId: number, resultList: GachaResult[]) {
|
||||
if(this.gachaType == GACHA_ID.NORMAL && count == 10 && index == count - 1) { // 10连到最后一抽
|
||||
if (this.gachaType == GACHA_ID.NORMAL && count == 10 && index == count - 1) { // 10连到最后一抽
|
||||
let { type, param } = gameData.gachaContent.get(contentId);
|
||||
if(type != GACHA_CONTENT_TYPE.HERO || param[0] < HERO_QUALITY_TYPE.PURPLE) {
|
||||
if (type != GACHA_CONTENT_TYPE.HERO || param[0] < HERO_QUALITY_TYPE.PURPLE) {
|
||||
let hasPurple = false;
|
||||
for(let { contentId } of resultList) {
|
||||
for (let { contentId } of resultList) {
|
||||
let { type, param } = gameData.gachaContent.get(contentId);
|
||||
if(type == GACHA_CONTENT_TYPE.HERO && param[0] >= HERO_QUALITY_TYPE.PURPLE) {
|
||||
if (type == GACHA_CONTENT_TYPE.HERO && param[0] >= HERO_QUALITY_TYPE.PURPLE) {
|
||||
hasPurple = true; break;
|
||||
}
|
||||
}
|
||||
if(!hasPurple) {
|
||||
if (!hasPurple) {
|
||||
return gameData.gachaContentHero.get(HERO_QUALITY_TYPE.PURPLE);
|
||||
}
|
||||
}
|
||||
@@ -324,9 +326,9 @@ export class GachaPull {
|
||||
// 获得需要储存的数据
|
||||
// 一般抽卡getter
|
||||
public getUserGachaParam(userGacha: UserGachaType) {
|
||||
let floor = userGacha.floor||[];
|
||||
let floor = userGacha.floor || [];
|
||||
let curFloor = floor.find(cur => cur.id == this.dicFloorType);
|
||||
if(curFloor) {
|
||||
if (curFloor) {
|
||||
curFloor.hasGetFloor = this.hasGetFloor;
|
||||
curFloor.count = this.floorCount;
|
||||
} else {
|
||||
|
||||
@@ -4,43 +4,40 @@ import { checkSuccessResponse } from './CheckPatten';
|
||||
import { ON_ADD_CHANNEL_ROUTE } from '../app/consts';
|
||||
|
||||
export class Client {
|
||||
private _client;
|
||||
private _roleInfo;
|
||||
constructor(tel: string = '13636354764') {
|
||||
this._client = new PinusWSClient();
|
||||
|
||||
let host = '127.0.0.1';
|
||||
let port = '3050';
|
||||
this._client.init({
|
||||
host: host,
|
||||
port: port
|
||||
}, (data) => {
|
||||
// 连接成功执行函数
|
||||
// console.log('gate连接成功');
|
||||
this._client.request('connector.entryHandler.debugQueryToken', {tel, magicWord: 'zyz666server518'}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.token).to.be.an('string');
|
||||
this._client.on(ON_ADD_CHANNEL_ROUTE, (msg) => {
|
||||
checkSuccessResponse(msg);
|
||||
expect(msg.data.roleId).to.be.a('string');
|
||||
expect(msg.data.channelName).to.be.a('string');
|
||||
});
|
||||
this._client.request('connector.entryHandler.enter', {serverId: 1, ...res.data}, (enterRes) => {
|
||||
// 消息回调
|
||||
// console.log('connector返回');
|
||||
checkSuccessResponse(enterRes);
|
||||
expect(enterRes.data.role).to.be.an('object');
|
||||
this._roleInfo = enterRes.data.role;
|
||||
});
|
||||
});
|
||||
private _client;
|
||||
private _roleInfo;
|
||||
constructor(tel: string = '13636354764') {
|
||||
this._client = new PinusWSClient();
|
||||
let host = '127.0.0.1';
|
||||
let port = '3050';
|
||||
this._client.init({
|
||||
host: host,
|
||||
port: port
|
||||
}, (data) => {
|
||||
// 连接成功执行函数
|
||||
this._client.request('connector.entryHandler.debugQueryToken', { tel, magicWord: 'zyz666server518' }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.token).to.be.an('string');
|
||||
this._client.on(ON_ADD_CHANNEL_ROUTE, (msg) => {
|
||||
checkSuccessResponse(msg);
|
||||
expect(msg.data.roleId).to.be.a('string');
|
||||
expect(msg.data.channelName).to.be.a('string');
|
||||
});
|
||||
this._client.request('connector.entryHandler.enter', { serverId: 1, ...res.data }, (enterRes) => {
|
||||
// 消息回调
|
||||
checkSuccessResponse(enterRes);
|
||||
expect(enterRes.data.role).to.be.an('object');
|
||||
this._roleInfo = enterRes.data.role;
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get roleInfo() {
|
||||
return this._roleInfo;
|
||||
}
|
||||
get roleInfo() {
|
||||
return this._roleInfo;
|
||||
}
|
||||
|
||||
get client() {
|
||||
return this._client;
|
||||
}
|
||||
get client() {
|
||||
return this._client;
|
||||
}
|
||||
}
|
||||
@@ -50,13 +50,13 @@ function checkDividends(dividends) {
|
||||
}
|
||||
}
|
||||
|
||||
describe('拍卖行测试', function() {
|
||||
describe('拍卖行测试', function () {
|
||||
let pinusClient: PinusWSClient;
|
||||
let pinusClientT: PinusWSClient; // 用做测试队友
|
||||
let roleInfo;
|
||||
let roleInfoT;
|
||||
|
||||
beforeEach(function(done) {
|
||||
before(function (done) {
|
||||
const c = new Client();
|
||||
const cT = new Client('13121622738');
|
||||
const timer = setInterval(() => {
|
||||
@@ -71,18 +71,22 @@ describe('拍卖行测试', function() {
|
||||
}, 500);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
after(function (done) {
|
||||
console.log('ddddddddddddddddddd');
|
||||
pinusClient.disconnect();
|
||||
pinusClientT.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
setTimeout(() => {
|
||||
done();
|
||||
console.log('ddddddddddddddddddd 1111');
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('添加拍品', function(done) {
|
||||
it('添加拍品', function (done) {
|
||||
const sourceCode = Math.random().toString(36).slice(-8);
|
||||
console.log('XXXXXXXXXXXXXXXXX 1 ');
|
||||
pinusClient.request('battle.auctionHandler.debugAddLots', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE, sourceCode, rewards: [{ id: GOOD_ID_TIEJIAN, count: 1 }, { id: GOOD_ID_GANGJIAN, count: 2 }] }, (res) => {
|
||||
console.log('XXXXXXXXXXXXXXXXX 1 ', JSON.stringify(res))
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
for (let lot of res.data.lots) {
|
||||
@@ -92,20 +96,29 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('获取拍卖行数据', function(done) {
|
||||
pinusClient.request('battle.auctionHandler.getAuction', {}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
checkLots(res.data.lots);
|
||||
expect(res.data.dividends).to.be.an('array');
|
||||
checkDividends(res.data.dividends);
|
||||
it('获取拍卖行数据', function (done) {
|
||||
console.log('XXXXXXXXXXXXXXXXX 2 ', '获取拍卖行数据')
|
||||
try {
|
||||
pinusClient.request('battle.auctionHandler.getAuction', {}, (res) => {
|
||||
console.log('XXXXXXXXXXXXXXXXX 2 ', JSON.stringify(res))
|
||||
checkSuccessResponse(res);
|
||||
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
checkLots(res.data.lots);
|
||||
expect(res.data.dividends).to.be.an('array');
|
||||
checkDividends(res.data.dividends);
|
||||
done();
|
||||
});
|
||||
} catch (e) {
|
||||
console.log('offer got err:', e);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('出价,竞价和一口价', function(done) {
|
||||
it('出价,竞价和一口价', function (done) {
|
||||
let gid = null;
|
||||
pinusClient.on('onEquipAdd', (res) => {
|
||||
console.log('XXXXXXXXXXXXXXXXX 3', JSON.stringify(res))
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.equipInfos).to.be.an('array');
|
||||
for (let info of res.data.equipInfos) {
|
||||
@@ -123,13 +136,14 @@ describe('拍卖行测试', function() {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
let unsoldLots = res.data.lots.filter(lot => {return lot.status !== LOT_STATUS.SOLD && lot.curBuyer !== roleInfo.roleId});
|
||||
let unsoldLots = res.data.lots.filter(lot => { return lot.status !== LOT_STATUS.SOLD && lot.curBuyer !== roleInfo.roleId });
|
||||
if (unsoldLots.length === 0) {
|
||||
console.warn('没有可出价的拍品');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
pinusClient.request('battle.auctionHandler.offer', { code: unsoldLots[0].code, max: false }, (res) => {
|
||||
console.log('XXXXXXXXXXXXXXXXX 4 ', JSON.stringify(res))
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
if (res.data.dividend) {
|
||||
@@ -146,6 +160,7 @@ describe('拍卖行测试', function() {
|
||||
}
|
||||
gid = unsoldLots[0].gid;
|
||||
pinusClient.request('battle.auctionHandler.offer', { code: unsoldLots[0].code, max: true }, (res) => {
|
||||
console.log('XXXXXXXXXXXXXXXXX 5 ', JSON.stringify(res))
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
checkDividend(res.data.dividend);
|
||||
@@ -157,8 +172,9 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('关注后取关', function(done) {
|
||||
it('关注后取关', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.getAuction', {}, (res) => {
|
||||
console.log('XXXXXXXXXXXXXXXXX 6 ', JSON.stringify(res))
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
checkLots(res.data.lots);
|
||||
@@ -184,15 +200,16 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('查看分红', function(done) {
|
||||
it('查看分红', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.checkDividend', {}, (res) => {
|
||||
console.log('XXXXXXXXXXXXXXXXX 7 ', JSON.stringify(res))
|
||||
checkSuccessResponse(res);
|
||||
checkDividends(res.data.dividends);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('领取分红', function(done) {
|
||||
it('领取分红', function (done) {
|
||||
pinusClient.on('onItemUpdate', (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.goods).to.be.an('array');
|
||||
@@ -225,7 +242,7 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('查看我的关注', function(done) {
|
||||
it('查看我的关注', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.getAuction', {}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
@@ -251,7 +268,7 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('更新拍品阶段的测试接口', function(done) {
|
||||
it('更新拍品阶段的测试接口', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.getAuction', {}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
@@ -272,7 +289,7 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('查看我的拍卖纪录', function(done) {
|
||||
it('查看我的拍卖纪录', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.offerRecs', { count: 10 }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.bidRecs).to.be.an('array');
|
||||
@@ -293,7 +310,7 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
|
||||
|
||||
it('获取军团拍卖记录', function(done) {
|
||||
it('获取军团拍卖记录', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.guildLotRecs', { count: 10 }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lotRecs).to.be.an('array');
|
||||
@@ -315,28 +332,28 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('测试接口,军团拍卖定时', function(done) {
|
||||
it('测试接口,军团拍卖定时', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.debugScheduleStartGuild', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||
checkSuccessResponse(res, false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('测试接口,世界拍卖定时', function(done) {
|
||||
it('测试接口,世界拍卖定时', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.debugScheduleStartWorld', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||
checkSuccessResponse(res, false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('测试接口,拍卖结束定时', function(done) {
|
||||
it('测试接口,拍卖结束定时', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.debugScheduleStopAuction', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||
checkSuccessResponse(res, false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('测试接口,结算分红定时', function(done) {
|
||||
it('测试接口,结算分红定时', function (done) {
|
||||
pinusClient.request('battle.auctionHandler.debugScheduleSendUngotDividend', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||
checkSuccessResponse(res, false);
|
||||
done();
|
||||
|
||||
@@ -5,18 +5,18 @@ import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
import { expect } from 'chai';
|
||||
import { checkSuccessResponse } from './CheckPatten';
|
||||
|
||||
const TEXT_MSG = {type: MSG_TYPE.TEXT, content: 'hello world'}
|
||||
const TEXT_MSG = { type: MSG_TYPE.TEXT, content: 'hello world' }
|
||||
const LVBU_HID = 44;
|
||||
const XIAHOUQINGYI_HID = 53;
|
||||
|
||||
function sendPrivateMessageParm(targetRoleInfo, msg) {
|
||||
const { roleId: targetRoleId, roleName: targetRoleName } = targetRoleInfo;
|
||||
const result = {targetRoleId, targetRoleName, ...msg};
|
||||
return result;
|
||||
const { roleId: targetRoleId, roleName: targetRoleName } = targetRoleInfo;
|
||||
const result = { targetRoleId, targetRoleName, ...msg };
|
||||
return result;
|
||||
}
|
||||
|
||||
function sendGroupMessageParm(channel, channelId, msg) {
|
||||
const result = {channel, channelId, ...msg};
|
||||
const result = { channel, channelId, ...msg };
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: P
|
||||
checkSuccessResponse(res, false);
|
||||
setTimeout(() => {
|
||||
expect(msgReceiveCnt).to.be.equal(2);
|
||||
pinusClientT.off(ON_GROUP_MSG_ROUTE);
|
||||
pinusClient.off(ON_GROUP_MSG_ROUTE);
|
||||
done();
|
||||
}, 2000);
|
||||
});
|
||||
@@ -83,7 +85,7 @@ function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: P
|
||||
// checkSuccessResponse(composeRes);
|
||||
// setTimeout(() => {
|
||||
// expect(msgReceiveCnt).to.be.equal(2);
|
||||
|
||||
|
||||
// done();
|
||||
// }, 1000);
|
||||
|
||||
@@ -91,13 +93,13 @@ function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: P
|
||||
// });
|
||||
// }
|
||||
|
||||
describe('聊天测试', function() {
|
||||
describe('聊天测试', function () {
|
||||
let pinusClient: PinusWSClient;
|
||||
let pinusClientT: PinusWSClient; // 用做测试队友
|
||||
let roleInfo;
|
||||
let roleInfoT;
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
const c = new Client();
|
||||
const cT = new Client('13121622738');
|
||||
const timer = setInterval(() => {
|
||||
@@ -112,7 +114,7 @@ describe('聊天测试', function() {
|
||||
}, 500);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function (done) {
|
||||
pinusClient.disconnect();
|
||||
pinusClientT.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
@@ -121,20 +123,22 @@ describe('聊天测试', function() {
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('两个玩家互相发送', function(done) {
|
||||
it('两个玩家互相发送', function (done) {
|
||||
pinusClientT.on(ON_PRIVATE_MSG_ROUTE, (msg) => {
|
||||
checkSuccessResponse(msg);
|
||||
expect(msg.data.content).to.equal(TEXT_MSG.content);
|
||||
done();
|
||||
});
|
||||
|
||||
pinusClient.request('chat.chatHandler.sendPrivateMessage', sendPrivateMessageParm(roleInfoT, TEXT_MSG), (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.content).to.equal(TEXT_MSG.content);
|
||||
});
|
||||
setTimeout(() => {
|
||||
pinusClient.request('chat.chatHandler.sendPrivateMessage', sendPrivateMessageParm(roleInfoT, TEXT_MSG), (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.content).to.equal(TEXT_MSG.content);
|
||||
done();
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
it('获取私聊历史消息', function(done) {
|
||||
it('获取私聊历史消息', function (done) {
|
||||
for (let i = 0; i < DEFAULT_MSG_PER_PAGE; i++) {
|
||||
pinusClient.request('chat.chatHandler.sendPrivateMessage', sendPrivateMessageParm(roleInfoT, TEXT_MSG), (res) => {
|
||||
checkSuccessResponse(res);
|
||||
@@ -142,7 +146,7 @@ describe('聊天测试', function() {
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
pinusClient.request('chat.chatHandler.getPrivateMessage', {targetRoleId: roleInfoT.roleId}, (res) => {
|
||||
pinusClient.request('chat.chatHandler.getPrivateMessage', { targetRoleId: roleInfoT.roleId }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.targetRoleId).to.be.a('string');
|
||||
expect(res.data.msgs).to.be.an('array');
|
||||
@@ -155,7 +159,7 @@ describe('聊天测试', function() {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
it('最近私聊的用户信息', function() {
|
||||
it('最近私聊的用户信息', function () {
|
||||
function checkChatInfos(roleInfo) {
|
||||
const chatInfos = roleInfo.recentPrivateChats;
|
||||
if (!chatInfos) {
|
||||
@@ -174,11 +178,14 @@ describe('聊天测试', function() {
|
||||
checkChatInfos(roleInfoT);
|
||||
});
|
||||
|
||||
it('最近群聊的消息', function() {
|
||||
it('最近群聊的消息', function () {
|
||||
function checkMsgs(msgs, roleName) {
|
||||
if (!msgs) {
|
||||
return;
|
||||
}
|
||||
expect(msgs).to.be.an('array');
|
||||
if (msgs.length === 0) {
|
||||
console.warn(`用户${roleName}缺少群消息`);
|
||||
console.log(`用户${roleName}缺少群消息`);
|
||||
}
|
||||
for (let msg of msgs) {
|
||||
expect(msg.roleId).to.be.a('string');
|
||||
@@ -196,16 +203,16 @@ describe('聊天测试', function() {
|
||||
checkAllGroupMsgs(roleInfoT);
|
||||
});
|
||||
|
||||
it('测试系统频道橙将合成消息', function(done) {
|
||||
it('测试系统频道橙将合成消息', function (done) {
|
||||
let msgReceiveCnt = 0;
|
||||
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkHeroInfoStr(res.data.content);
|
||||
// checkHeroInfoStr(res.data.content);
|
||||
msgReceiveCnt += 1;
|
||||
});
|
||||
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkHeroInfoStr(res.data.content);
|
||||
// checkHeroInfoStr(res.data.content);
|
||||
msgReceiveCnt += 1;
|
||||
});
|
||||
pinusClient.request('role.heroHandler.testCleanUp', { magicWord: DEBUG_MAGIC_WORD, hid: LVBU_HID }, (cleanUpRes) => {
|
||||
@@ -216,22 +223,24 @@ describe('聊天测试', function() {
|
||||
checkSuccessResponse(composeRes);
|
||||
setTimeout(() => {
|
||||
expect(msgReceiveCnt).to.be.equal(2);
|
||||
pinusClientT.off(ON_GROUP_MSG_ROUTE);
|
||||
pinusClient.off(ON_GROUP_MSG_ROUTE);
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('测试系统频道升六星消息', function(done) {
|
||||
it.skip('测试系统频道升六星消息', function (done) {
|
||||
let msgReceiveCnt = 0;
|
||||
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkHeroInfoStr(res.data.content);
|
||||
// checkHeroInfoStr(res.data.content);
|
||||
msgReceiveCnt += 1;
|
||||
});
|
||||
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkHeroInfoStr(res.data.content);
|
||||
// checkHeroInfoStr(res.data.content);
|
||||
msgReceiveCnt += 1;
|
||||
});
|
||||
pinusClient.request('role.heroHandler.testCleanUp', { magicWord: DEBUG_MAGIC_WORD, hid: XIAHOUQINGYI_HID }, (cleanUpRes) => {
|
||||
@@ -243,9 +252,11 @@ describe('聊天测试', function() {
|
||||
for (let i = 2; i <= HERO_GROW_MAX.STAR; i++) {
|
||||
for (let j = 0; j < ABI_STAGE.END; j++) {
|
||||
setTimeout(() => {
|
||||
pinusClient.request('role.heroHandler.starUp', {hid: XIAHOUQINGYI_HID, star: i, starStage: j}, (starUpRes) => {
|
||||
pinusClient.request('role.heroHandler.starUp', { hid: XIAHOUQINGYI_HID, star: i, starStage: j }, (starUpRes) => {
|
||||
if (starUpRes.code === STATUS.ROLE_STAR_REACH_MAX.code) {
|
||||
expect(msgReceiveCnt).to.be.equal(2);
|
||||
pinusClientT.off(ON_GROUP_MSG_ROUTE);
|
||||
pinusClient.off(ON_GROUP_MSG_ROUTE);
|
||||
done();
|
||||
} else {
|
||||
checkSuccessResponse(starUpRes);
|
||||
@@ -258,11 +269,11 @@ describe('聊天测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('测试系统频道升品消息', function(done) {
|
||||
it('测试系统频道升品消息', function (done) {
|
||||
let msgReceiveCnt = 0;
|
||||
function checkHeroInfoRes(res) {
|
||||
checkSuccessResponse(res);
|
||||
checkHeroInfoStr(res.data.content);
|
||||
// checkHeroInfoStr(res.data.content);
|
||||
msgReceiveCnt += 1;
|
||||
}
|
||||
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||
@@ -282,12 +293,14 @@ describe('聊天测试', function() {
|
||||
setTimeout(() => {
|
||||
if (i === HERO_GROW_MAX.STAR && j > 0) {
|
||||
} else {
|
||||
pinusClient.request('role.heroHandler.starUp', {hid: XIAHOUQINGYI_HID, star: i, starStage: j}, (starUpRes) => {
|
||||
pinusClient.request('role.heroHandler.starUp', { hid: XIAHOUQINGYI_HID, star: i, starStage: j }, (starUpRes) => {
|
||||
if (starUpRes.code === STATUS.ROLE_STAR_REACH_MAX.code) {
|
||||
pinusClient.request('role.heroHandler.qualityUp', {hid: XIAHOUQINGYI_HID, quality: 2}, (qualityUpRes) => {
|
||||
pinusClient.request('role.heroHandler.qualityUp', { hid: XIAHOUQINGYI_HID, quality: 2 }, (qualityUpRes) => {
|
||||
checkSuccessResponse(qualityUpRes);
|
||||
setTimeout(() => {
|
||||
expect(msgReceiveCnt).to.be.equal(2);
|
||||
pinusClientT.off(ON_GROUP_MSG_ROUTE);
|
||||
pinusClient.off(ON_GROUP_MSG_ROUTE);
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
@@ -303,15 +316,31 @@ describe('聊天测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('测试世界频道消息', function(done) {
|
||||
it('测试世界频道消息', function (done) {
|
||||
testGroupMsg(pinusClient, roleInfo, pinusClientT, CHANNEL_PREFIX.WORLD, roleInfo.serverId, done);
|
||||
});
|
||||
|
||||
it('测试军团频道消息', function(done) {
|
||||
it('测试加入相同军团', function (done) {
|
||||
console.log("1: ", roleInfo.roleId, roleInfo.guildCode)
|
||||
console.log("2: ", roleInfoT.roleId, roleInfoT.guildCode)
|
||||
if (roleInfo.guildCode !== roleInfoT.guildCode) {
|
||||
pinusClientT.request('battle.guildHandler.debugJoinGuild', { code: roleInfo.guildCode }, (res) => {
|
||||
console.log(roleInfo.guildCode)
|
||||
checkSuccessResponse(res, false);
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('测试军团频道消息', function (done) {
|
||||
console.log(roleInfo.guildCode)
|
||||
console.log(roleInfoT.guildCode)
|
||||
testGroupMsg(pinusClient, roleInfo, pinusClientT, CHANNEL_PREFIX.GUILD, roleInfo.guildCode, done);
|
||||
});
|
||||
|
||||
it('测试军团通知修改推送', function(done) {
|
||||
it('测试军团通知修改推送', function (done) {
|
||||
const newNotice = new Date().toLocaleDateString();
|
||||
let msgReceiveCnt = 0;
|
||||
function checkNoticeRes(res) {
|
||||
@@ -325,10 +354,10 @@ describe('聊天测试', function() {
|
||||
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||
checkNoticeRes(res);
|
||||
});
|
||||
pinusClient.request('battle.guildHandler.getMyGuildInfo', { }, (res) => {
|
||||
pinusClient.request('battle.guildHandler.getMyGuildInfo', {}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data).to.have.deep.property('hasGuild').that.is.an('boolean');
|
||||
if(res.data.hasGuild) {
|
||||
if (res.data.hasGuild) {
|
||||
expect(res.data).to.have.deep.property('code').that.is.an('string');
|
||||
expect(res.data).to.have.deep.property('name').that.is.an('string');
|
||||
expect(res.data).to.have.deep.property('notice').that.is.an('string');
|
||||
@@ -341,6 +370,8 @@ describe('聊天测试', function() {
|
||||
expect(setRes.data.notice).to.be.equal(newNotice);
|
||||
setTimeout(() => {
|
||||
expect(msgReceiveCnt).to.be.equal(2);
|
||||
pinusClientT.off(ON_GROUP_MSG_ROUTE);
|
||||
pinusClient.off(ON_GROUP_MSG_ROUTE);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
@@ -348,7 +379,7 @@ describe('聊天测试', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('更新私聊阅读时间', function(done) {
|
||||
it('更新私聊阅读时间', function (done) {
|
||||
for (let i = 0; i < DEFAULT_MSG_PER_PAGE; i++) {
|
||||
pinusClient.request('chat.chatHandler.sendPrivateMessage', sendPrivateMessageParm(roleInfoT, TEXT_MSG), (res) => {
|
||||
checkSuccessResponse(res);
|
||||
@@ -356,7 +387,7 @@ describe('聊天测试', function() {
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
pinusClientT.request('chat.chatHandler.readPrivateMessage', {targetRoleId: roleInfo.roleId}, (res) => {
|
||||
pinusClientT.request('chat.chatHandler.readPrivateMessage', { targetRoleId: roleInfo.roleId }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data).to.be.an('object');
|
||||
expect(res.data.targetRoleId).to.be.equal(roleInfo.roleId);
|
||||
@@ -367,8 +398,8 @@ describe('聊天测试', function() {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
it('举报消息', function(done) {
|
||||
pinusClient.request('chat.chatHandler.accuse', {targetRoleId: roleInfoT.roleId, targetMsgCode: 'test', reason: 1}, (res) => {
|
||||
it('举报消息', function (done) {
|
||||
pinusClient.request('chat.chatHandler.accuse', { targetRoleId: roleInfoT.roleId, targetMsgCode: 'test', reason: 1 }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data).to.be.an('object');
|
||||
expect(res.data.roleId).to.be.equal(roleInfo.roleId);
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('任务测试', function () {
|
||||
return receiveTaskPromise(pinusClient, { type, id: task.id });
|
||||
});
|
||||
Promise.all(promiseFuns).then(() => {
|
||||
pinusClient.request('role.taskHandler.receiveMainStage', {stage: res.data.mainTask.stage}, (res) => {
|
||||
pinusClient.request('role.taskHandler.receiveMainStage', { stage: res.data.mainTask.stage }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkMainTask(res.data);
|
||||
checkDisplayItems(res.data.goods);
|
||||
@@ -59,7 +59,7 @@ describe('任务测试', function () {
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
it('检查领取每日任务', function (done) {
|
||||
@@ -82,7 +82,7 @@ describe('任务测试', function () {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -128,12 +128,13 @@ function checkReceiveTask(pinusClient, done, type: number) {
|
||||
receiveTask(pinusClient, { type, id: res.data.task.id }, done);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 检查主线任务数据
|
||||
function checkMainTask(mainTask) {
|
||||
if (!mainTask) return;
|
||||
expect(mainTask).to.be.an('object');
|
||||
expect(mainTask.stage).to.be.a('number');
|
||||
expect(mainTask.taskList).to.be.an('array');
|
||||
@@ -142,6 +143,7 @@ function checkMainTask(mainTask) {
|
||||
|
||||
// 检查日常任务数据
|
||||
function checkDailyTask(dailyTask) {
|
||||
if (!dailyTask) return;
|
||||
expect(dailyTask).to.be.an('object');
|
||||
expect(dailyTask.point).to.be.a('number');
|
||||
expect(dailyTask.weeklyPoint).to.be.an('number');
|
||||
@@ -153,6 +155,7 @@ function checkDailyTask(dailyTask) {
|
||||
|
||||
// 检查成就
|
||||
function checkAchievement(achievement) {
|
||||
if (!achievement) return;
|
||||
expect(achievement).to.be.an('object');
|
||||
expect(achievement.point).to.be.a('number');
|
||||
achievement.taskList.forEach(task => checkSingleTask(task));
|
||||
@@ -188,6 +191,6 @@ function checkReceiveBox(pinusClient, done, type: number) {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user