聊天:获得橙色武将推送系统消息
测试:增加删除武将等测试接口
This commit is contained in:
@@ -7,7 +7,7 @@ import { Application } from 'pinus';
|
||||
import {FrontendSession} from 'pinus';
|
||||
import { HeroModel } from './../../../db/Hero';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { COM_BTL_QUALITY, ROLE_SELECT, HERO_SELECT, GUILD_SELECT, USER_GUILD_SELECT } from '../../../consts';
|
||||
import { COM_BTL_QUALITY, ROLE_SELECT, HERO_SELECT, GUILD_SELECT, USER_GUILD_SELECT, DEBUG_MAGIC_WORD } from '../../../consts';
|
||||
import { getAp } from '../../../services/actionPointService';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { chackFunOpenWhenLogin } from '../../../services/funcSwitchService';
|
||||
@@ -206,7 +206,7 @@ export class EntryHandler {
|
||||
*/
|
||||
async debugQueryToken(msg: { tel: string, magicWord: string }, session: FrontendSession) {
|
||||
const { tel, magicWord } = msg;
|
||||
if (magicWord !== 'zyz666server518') {
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
}
|
||||
const token = await UserModel.findTokenByTel(tel);
|
||||
|
||||
@@ -4,15 +4,16 @@ import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeServ
|
||||
import { resResult, returnHeroCeRatio, deepCopy } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { HeroModel, Connect } from '../../../db/Hero';
|
||||
import {CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ITID, ABI_STAGE, HERO_CE_RATIO} from '../../../consts';
|
||||
import {CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ITID, ABI_STAGE, HERO_CE_RATIO, DEBUG_MAGIC_WORD, HERO_INITIAL_QUALITY} from '../../../consts';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById, getFavourLvByExp } from '../../../pubUtils/data';
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
import { getDropItems } from '../../../consts/constModules/itemConst'
|
||||
import { getRoleOnlineInfo, getAllOnlineRoles } from '../../../services/redisService';
|
||||
import { pushHeroQualityUpMsg } from '../../../services/chatService';
|
||||
import { CeAttrDataRole, CeAttrData } from '../../../domain/roleField/attribute';
|
||||
import { pushComposeOrangeHero, pushHeroQualityUpMsg } from '../../../services/chatService';
|
||||
import { calculatetopLineup } from '../../../pubUtils/playerCe';
|
||||
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new HeroHandler(app);
|
||||
@@ -33,6 +34,34 @@ export class HeroHandler {
|
||||
|
||||
}
|
||||
|
||||
// ! 测试接口,用来测试前清理并初始化某个武将;代码抄自:gm-server/app/service/users.ts deleteHero
|
||||
public async testCleanUp(msg: {magicWord: string, hid: number}, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
const { magicWord, hid } = msg;
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
}
|
||||
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
if (!dicHero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
await addItems(roleId, roleName, sid, [{
|
||||
id: dicHero.pieceId, count: dicHero.pieceCount
|
||||
}] );
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
await HeroModel.deleteHero(roleId, hid);
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
await calculatetopLineup(role, hid, 0, null);
|
||||
await PvpDefenseModel.deleteHero(roleId, hid);
|
||||
await RoleModel.updateRoleInfo(roleId, { topLineup: role.topLineup, topLineupCe: role.topLineupCe, ce: role.ce - hero.ce });
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
public async addItem(msg: { id: number, count: number}, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
@@ -85,6 +114,9 @@ export class HeroHandler {
|
||||
});
|
||||
let hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, sid, roleId, curHero, {});
|
||||
await calAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, sid, roleId, {}, [initialSkin])
|
||||
if (dicHero.quality === HERO_INITIAL_QUALITY.ORANGE) {
|
||||
pushComposeOrangeHero(roleId, roleName, serverId, hero);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, {curHero: returnHeroCeRatio(hero)});
|
||||
}
|
||||
|
||||
|
||||
@@ -203,10 +203,18 @@ export function wrapRichText(type: string, jumpTo: string, content: string, parm
|
||||
});
|
||||
}
|
||||
|
||||
export async function pushHeroQualityUpMsg(roleId: string, roleName: string, serverId: number | string, 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 content = JSON.stringify({ roleId, roleName, hero });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.HERO_QUALITY_UP, 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}`);
|
||||
await pushGroupMsgToRoom(roomId, msgData);
|
||||
}
|
||||
|
||||
export async function pushHeroQualityUpMsg(roleId: string, roleName: string, serverId: number | string, heroInfo: Partial<HeroType>) {
|
||||
await pushNormalHeroInfoBySource(roleId, roleName, serverId, MSG_SOURCE.HERO_QUALITY_UP, heroInfo);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX } from './../app/consts';
|
||||
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS } from './../app/consts';
|
||||
import { Client } from './Client';
|
||||
import 'mocha';
|
||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
@@ -6,6 +6,8 @@ import { expect } from 'chai';
|
||||
import { checkSuccessResponse } from './CheckPatten';
|
||||
|
||||
const TEXT_MSG = {type: MSG_TYPE.TEXT, content: 'hello world'}
|
||||
const LVBU_HID = 44;
|
||||
const LVBU_PIECE_ID = 21044;
|
||||
|
||||
function sendPrivateMessageParm(targetRoleInfo, msg) {
|
||||
const { roleId: targetRoleId, roleName: targetRoleName } = targetRoleInfo;
|
||||
@@ -19,12 +21,24 @@ function sendGroupMessageParm(channel, channelId, msg) {
|
||||
}
|
||||
|
||||
function checkGroupMsg(msg, roleId, roomId, content) {
|
||||
expect(msg.content).to.equal(TEXT_MSG.content);
|
||||
expect(msg.roleId).to.equal(roleId);
|
||||
expect(msg.content).to.equal(content);
|
||||
expect(msg.roomId).to.equal(roomId);
|
||||
}
|
||||
|
||||
function checkHeroInfoStr(content: string) {
|
||||
expect(content).to.be.a('string');
|
||||
const heroInfo = JSON.parse(content);
|
||||
expect(heroInfo).to.be.an('object');
|
||||
const { roleId, roleName, hero } = heroInfo;
|
||||
expect(roleId).to.be.a('string');
|
||||
expect(roleName).to.be.a('string');
|
||||
const { hid, seqId, hName } = hero;
|
||||
expect(hid).to.be.a('number');
|
||||
expect(seqId).to.be.a('number');
|
||||
expect(hName).to.be.a('string');
|
||||
}
|
||||
|
||||
function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: PinusWSClient, channel: string, channelId: string, done: Mocha.Done) {
|
||||
let msgReceiveCnt = 0;
|
||||
const roomId = `${channel}_${channelId}`;
|
||||
@@ -112,8 +126,35 @@ describe('聊天测试', function() {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
it('测试系统频道消息', function(done) {
|
||||
// TODO: 升品推送
|
||||
it('测试系统频道橙将合成消息', function(done) {
|
||||
const roomId = `${CHANNEL_PREFIX.SYS}_${roleInfo.serverId}`;
|
||||
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: LVBU_HID }, (cleanUpRes) => {
|
||||
if (cleanUpRes.code !== STATUS.HERO_NOT_FIND.code) {
|
||||
checkSuccessResponse(cleanUpRes, false);
|
||||
}
|
||||
pinusClient.request('role.heroHandler.compose', { hid: LVBU_HID }, (composeRes) => {
|
||||
checkSuccessResponse(composeRes);
|
||||
setTimeout(() => {
|
||||
expect(msgReceiveCnt).to.be.equal(2);
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: 升品推送测试
|
||||
it('测试系统频道升品消息', function(done) {
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ export const MSG_SOURCE = {
|
||||
ROLE_SEND_TEXT: 0,
|
||||
PRIVATE_SEND_GIFT: 1,
|
||||
HERO_QUALITY_UP: 2,
|
||||
COMPOSE_ORANGE_HERO: 3,
|
||||
}
|
||||
|
||||
export const ON_MSG_ROUTE = 'onMessage';
|
||||
|
||||
@@ -40,4 +40,10 @@ export const JOB_TYPE = {
|
||||
// 武将战力放大系数
|
||||
export const HERO_CE_RATIO = 100;
|
||||
// 次级属性放大系数
|
||||
export const HERO_SUB_ATTR_RATIO = 1000;
|
||||
export const HERO_SUB_ATTR_RATIO = 1000;
|
||||
|
||||
export const HERO_INITIAL_QUALITY = {
|
||||
BLUE: 1,
|
||||
PURPLE: 2,
|
||||
ORANGE: 3
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ export const TURBO_PARM_SECRET = 'ipqw05du6ob4x130w89t31yrqd6xs005zzltcmg2zpqnvr
|
||||
export const ENCRYPT_IV = 'f7182j5f04e377ux';
|
||||
export const ENCRYPT_KEY = 'fiqaxijabbantusmprc234fj';
|
||||
|
||||
export const DEBUG_MAGIC_WORD = 'zyz666server518';
|
||||
|
||||
export const AUTH_SMS_CNT_PER_DAY = 8;
|
||||
|
||||
export const ADULT_AGE = 18;
|
||||
|
||||
Reference in New Issue
Block a user