聊天:升星和升品的推送及测试
This commit is contained in:
@@ -11,7 +11,7 @@ import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, g
|
|||||||
import { RewardInter } from '../../../pubUtils/interface';
|
import { RewardInter } from '../../../pubUtils/interface';
|
||||||
import { getDropItems } from '../../../consts/constModules/itemConst'
|
import { getDropItems } from '../../../consts/constModules/itemConst'
|
||||||
import { getRoleOnlineInfo, getAllOnlineRoles } from '../../../services/redisService';
|
import { getRoleOnlineInfo, getAllOnlineRoles } from '../../../services/redisService';
|
||||||
import { pushComposeOrangeHero, pushHeroQualityUpMsg } from '../../../services/chatService';
|
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax } from '../../../services/chatService';
|
||||||
import { calculatetopLineup } from '../../../pubUtils/playerCe';
|
import { calculatetopLineup } from '../../../pubUtils/playerCe';
|
||||||
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ export class HeroHandler {
|
|||||||
let dicHero = gameData.hero.get(hid);
|
let dicHero = gameData.hero.get(hid);
|
||||||
if (!dicHero) return resResult(STATUS.HERO_NOT_FIND);
|
if (!dicHero) return resResult(STATUS.HERO_NOT_FIND);
|
||||||
await addItems(roleId, roleName, sid, [{
|
await addItems(roleId, roleName, sid, [{
|
||||||
id: dicHero.pieceId, count: dicHero.pieceCount
|
id: dicHero.pieceId, count: dicHero.pieceCount * HERO_GROW_MAX.STAR * ABI_STAGE.END
|
||||||
}] );
|
}] );
|
||||||
|
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
@@ -189,6 +189,8 @@ export class HeroHandler {
|
|||||||
// 武将升星
|
// 武将升星
|
||||||
public async starUp(msg: { hid: number, star: number, starStage: number}, session: BackendSession) {
|
public async starUp(msg: { hid: number, star: number, starStage: number}, session: BackendSession) {
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
|
let roleName: string = session.get('roleName');
|
||||||
|
let serverId: string = session.get('serverId');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
|
|
||||||
let {hid, star, starStage} = msg;
|
let {hid, star, starStage} = msg;
|
||||||
@@ -230,6 +232,9 @@ export class HeroHandler {
|
|||||||
colorStar: hero.colorStar,
|
colorStar: hero.colorStar,
|
||||||
colorStarStage: hero.colorStarStage
|
colorStarStage: hero.colorStarStage
|
||||||
}
|
}
|
||||||
|
if (hero.star === HERO_GROW_MAX.STAR) {
|
||||||
|
pushHeroStarMax(roleId, roleName, serverId, hero);
|
||||||
|
}
|
||||||
return resResult(STATUS.SUCCESS, {isUpStar, curHero});
|
return resResult(STATUS.SUCCESS, {isUpStar, curHero});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ export function wrapRichText(type: string, jumpTo: string, content: string, parm
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function pushNormalHeroInfoBySource(roleId: string, roleName: string, serverId: number | string, source: number, heroInfo: Partial<HeroType>) {
|
export async function pushNormalHeroInfoBySource(roleId: string, roleName: string, serverId: number | string, source: number, heroInfo: Partial<HeroType>) {
|
||||||
const hero = pick(heroInfo, ['hName', 'hid', 'seqId', 'quality']);
|
const hero = pick(heroInfo, ['hName', 'hid', 'seqId', 'quality', 'star', 'starStage', 'colorStar', 'colorStarStage']);
|
||||||
const content = JSON.stringify({ roleId, roleName, hero });
|
const content = JSON.stringify({ roleId, roleName, hero });
|
||||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||||
const roomId = groupRoomId(CHANNEL_PREFIX.SYS, `${serverId}`);
|
const roomId = groupRoomId(CHANNEL_PREFIX.SYS, `${serverId}`);
|
||||||
@@ -218,3 +218,7 @@ export async function pushHeroQualityUpMsg(roleId: string, roleName: string, ser
|
|||||||
export async function pushComposeOrangeHero(roleId: string, roleName: string, serverId: number | string, heroInfo: Partial<HeroType>) {
|
export async function pushComposeOrangeHero(roleId: string, roleName: string, serverId: number | string, heroInfo: Partial<HeroType>) {
|
||||||
await pushNormalHeroInfoBySource(roleId, roleName, serverId, MSG_SOURCE.COMPOSE_ORANGE_HERO, heroInfo);
|
await pushNormalHeroInfoBySource(roleId, roleName, serverId, MSG_SOURCE.COMPOSE_ORANGE_HERO, heroInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function pushHeroStarMax(roleId: string, roleName: string, serverId: number | string, heroInfo: Partial<HeroType>) {
|
||||||
|
await pushNormalHeroInfoBySource(roleId, roleName, serverId, MSG_SOURCE.HERO_STAR_MAX, heroInfo);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS } from './../app/consts';
|
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS, HERO_GROW_MAX, ABI_STAGE } from './../app/consts';
|
||||||
import { Client } from './Client';
|
import { Client } from './Client';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||||
@@ -7,7 +7,7 @@ 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 LVBU_HID = 44;
|
||||||
const LVBU_PIECE_ID = 21044;
|
const XIAHOUQINGYI_HID = 53;
|
||||||
|
|
||||||
function sendPrivateMessageParm(targetRoleInfo, msg) {
|
function sendPrivateMessageParm(targetRoleInfo, msg) {
|
||||||
const { roleId: targetRoleId, roleName: targetRoleName } = targetRoleInfo;
|
const { roleId: targetRoleId, roleName: targetRoleName } = targetRoleInfo;
|
||||||
@@ -63,6 +63,34 @@ function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: P
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function testHeroPush(pinusClient: PinusWSClient, pinusClientT: PinusWSClient, hid: number, route: string, routeParam: object, done: Mocha.Done) {
|
||||||
|
// let msgReceiveCnt = 0;
|
||||||
|
// pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||||
|
// checkSuccessResponse(res);
|
||||||
|
// checkHeroInfoStr(res.data.content);
|
||||||
|
// msgReceiveCnt += 1;
|
||||||
|
// });
|
||||||
|
// pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||||
|
// checkSuccessResponse(res);
|
||||||
|
// checkHeroInfoStr(res.data.content);
|
||||||
|
// msgReceiveCnt += 1;
|
||||||
|
// });
|
||||||
|
// pinusClient.request('role.heroHandler.testCleanUp', { magicWord: DEBUG_MAGIC_WORD, hid }, (cleanUpRes) => {
|
||||||
|
// if (cleanUpRes.code !== STATUS.HERO_NOT_FIND.code) {
|
||||||
|
// checkSuccessResponse(cleanUpRes, false);
|
||||||
|
// }
|
||||||
|
// pinusClient.request(route, routeParam, (composeRes) => {
|
||||||
|
// checkSuccessResponse(composeRes);
|
||||||
|
// setTimeout(() => {
|
||||||
|
// expect(msgReceiveCnt).to.be.equal(2);
|
||||||
|
|
||||||
|
// done();
|
||||||
|
// }, 1000);
|
||||||
|
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
describe('聊天测试', function() {
|
describe('聊天测试', function() {
|
||||||
let pinusClient: PinusWSClient;
|
let pinusClient: PinusWSClient;
|
||||||
let pinusClientT: PinusWSClient; // 用做测试队友
|
let pinusClientT: PinusWSClient; // 用做测试队友
|
||||||
@@ -127,7 +155,6 @@ describe('聊天测试', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('测试系统频道橙将合成消息', function(done) {
|
it('测试系统频道橙将合成消息', function(done) {
|
||||||
const roomId = `${CHANNEL_PREFIX.SYS}_${roleInfo.serverId}`;
|
|
||||||
let msgReceiveCnt = 0;
|
let msgReceiveCnt = 0;
|
||||||
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => {
|
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
@@ -153,9 +180,87 @@ describe('聊天测试', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('测试系统频道升六星消息', function(done) {
|
||||||
|
let msgReceiveCnt = 0;
|
||||||
|
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkHeroInfoStr(res.data.content);
|
||||||
|
msgReceiveCnt += 1;
|
||||||
|
});
|
||||||
|
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkHeroInfoStr(res.data.content);
|
||||||
|
msgReceiveCnt += 1;
|
||||||
|
});
|
||||||
|
pinusClient.request('role.heroHandler.testCleanUp', { magicWord: DEBUG_MAGIC_WORD, hid: XIAHOUQINGYI_HID }, (cleanUpRes) => {
|
||||||
|
if (cleanUpRes.code !== STATUS.HERO_NOT_FIND.code) {
|
||||||
|
checkSuccessResponse(cleanUpRes, false);
|
||||||
|
}
|
||||||
|
pinusClient.request('role.heroHandler.compose', { hid: XIAHOUQINGYI_HID }, (composeRes) => {
|
||||||
|
checkSuccessResponse(composeRes);
|
||||||
|
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) => {
|
||||||
|
if (starUpRes.code === STATUS.ROLE_STAR_REACH_MAX.code) {
|
||||||
|
expect(msgReceiveCnt).to.be.equal(2);
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
checkSuccessResponse(starUpRes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 50 * (i - 2) * ABI_STAGE.END + 50 * j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: 升品推送测试
|
// TODO: 升品推送测试
|
||||||
it('测试系统频道升品消息', function(done) {
|
it('测试系统频道升品消息', function(done) {
|
||||||
done();
|
let msgReceiveCnt = 0;
|
||||||
|
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkHeroInfoStr(res.data.content);
|
||||||
|
msgReceiveCnt += 1;
|
||||||
|
});
|
||||||
|
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkHeroInfoStr(res.data.content);
|
||||||
|
msgReceiveCnt += 1;
|
||||||
|
});
|
||||||
|
pinusClient.request('role.heroHandler.testCleanUp', { magicWord: DEBUG_MAGIC_WORD, hid: XIAHOUQINGYI_HID }, (cleanUpRes) => {
|
||||||
|
if (cleanUpRes.code !== STATUS.HERO_NOT_FIND.code) {
|
||||||
|
checkSuccessResponse(cleanUpRes, false);
|
||||||
|
}
|
||||||
|
pinusClient.request('role.heroHandler.compose', { hid: XIAHOUQINGYI_HID }, (composeRes) => {
|
||||||
|
checkSuccessResponse(composeRes);
|
||||||
|
for (let i = 2; i <= HERO_GROW_MAX.STAR; i++) {
|
||||||
|
for (let j = 0; j < ABI_STAGE.END; j++) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (i === HERO_GROW_MAX.STAR && j > 0) {
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
msgReceiveCnt = 0;
|
||||||
|
pinusClient.request('role.heroHandler.qualityUp', {hid: XIAHOUQINGYI_HID, quality: 2}, (qualityUpRes) => {
|
||||||
|
checkSuccessResponse(qualityUpRes);
|
||||||
|
setTimeout(() => {
|
||||||
|
expect(msgReceiveCnt).to.be.equal(2);
|
||||||
|
done();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
checkSuccessResponse(starUpRes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 50 * (i - 2) * ABI_STAGE.END + 50 * j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('测试世界频道消息', function(done) {
|
it('测试世界频道消息', function(done) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export const MSG_SOURCE = {
|
|||||||
PRIVATE_SEND_GIFT: 1,
|
PRIVATE_SEND_GIFT: 1,
|
||||||
HERO_QUALITY_UP: 2,
|
HERO_QUALITY_UP: 2,
|
||||||
COMPOSE_ORANGE_HERO: 3,
|
COMPOSE_ORANGE_HERO: 3,
|
||||||
|
HERO_STAR_MAX: 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ON_MSG_ROUTE = 'onMessage';
|
export const ON_MSG_ROUTE = 'onMessage';
|
||||||
|
|||||||
Reference in New Issue
Block a user