测试:添加战斗测试
This commit is contained in:
@@ -19,6 +19,16 @@ export function checkDisplayItems(items) {
|
||||
})
|
||||
}
|
||||
|
||||
export function checkBattleGoods(items) {
|
||||
expect(items).to.be.an('array');
|
||||
items.forEach(item => {
|
||||
expect(item.dropType).to.be.a('number');
|
||||
if(item.seqId) expect(item.seqId).to.be.a('number');
|
||||
expect(item.id).to.be.a('number');
|
||||
expect(item.count).to.be.a('number');
|
||||
})
|
||||
}
|
||||
|
||||
export function checkHero(heroes) {
|
||||
expect(heroes).to.be.an('array');
|
||||
heroes.forEach(hero => {
|
||||
|
||||
259
game-server/test/battle.test.ts
Normal file
259
game-server/test/battle.test.ts
Normal file
@@ -0,0 +1,259 @@
|
||||
import { Client } from './Client';
|
||||
import 'mocha';
|
||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
import { expect } from 'chai';
|
||||
import { addItemsIfNotEnough, checkBattleGoods, checkDisplayItems, checkSuccessResponse, checkTimeStamp, checkWarJson } from './CheckPatten';
|
||||
import { PVP } from '../app/pubUtils/dicParam';
|
||||
import { DEBUG_MAGIC_WORD } from '../app/consts';
|
||||
import { getRandSingleEelm } from '../app/pubUtils/util';
|
||||
|
||||
const NORMAIL_BATTLEID = 101;
|
||||
|
||||
describe('战斗测试', function () {
|
||||
let pinusClient: PinusWSClient;
|
||||
let roleInfo;
|
||||
|
||||
before(function (done) {
|
||||
const c = new Client();
|
||||
const timer = setInterval(() => {
|
||||
if (c.client) {
|
||||
pinusClient = c.client;
|
||||
roleInfo = c.roleInfo;
|
||||
clearInterval(timer);
|
||||
done();
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
pinusClient.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
setTimeout(() => {
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it.only('获得关卡列表', function (done) {
|
||||
pinusClient.request('battle.normalBattleHandler.getBattleList', { type: 1 }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.list).to.be.an('array');
|
||||
res.data.list.forEach(data => {
|
||||
expect(data.battleId).to.be.a('number');
|
||||
expect(data.status).to.be.a('number');
|
||||
expect(data.star).to.be.a('number');
|
||||
expect(data.stars).to.be.an('array');
|
||||
data.stars.forEach(star => {
|
||||
expect(star).to.be.a('number');
|
||||
})
|
||||
expect(data.scriptBefore).to.be.a('string');
|
||||
expect(data.scriptAfter).to.be.a('string');
|
||||
})
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
let battleCode;
|
||||
let paramHeroes;
|
||||
it.only('开始战斗', function (done) {
|
||||
paramHeroes = getParamHeroes(roleInfo);
|
||||
checkBattle(pinusClient, paramHeroes, NORMAIL_BATTLEID, 'normal', data => {
|
||||
battleCode = data.battleCode;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it.only('战斗结算', function (done) {
|
||||
battleEnd(pinusClient, paramHeroes, NORMAIL_BATTLEID, battleCode, 'normal', data => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it.only('战斗扫荡', function (done) {
|
||||
battleSweep(pinusClient, NORMAIL_BATTLEID, 'normal', data => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('保存R剧本', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('根据战场获取R剧本', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('发送剧情弹幕', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('获取剧情弹幕', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('获取每日关卡列表', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('购买每日次数', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('每日关卡开始战斗', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('每日关卡开始战斗', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('每日关卡结束战斗', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('获取奇遇事件', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('奇遇事件回答问题', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('奇遇关卡开始战斗', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('奇遇关卡结束战斗', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('奇遇事件领取奖励', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('获取远征关卡状态', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('重置远征关卡', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('远征获取敌军数据', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('远征关卡开始战斗', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('远征关卡结束战斗', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('领取远征宝箱', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('获取秘境数据', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('购买秘境挑战次数', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('秘境关卡挑战开始', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('秘境关卡挑战结束', function (done) {
|
||||
done();
|
||||
});
|
||||
|
||||
it('获取秘境首通信息', function (done) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
function getParamHeroes(roleInfo) {
|
||||
let heroes = [];
|
||||
for(let i = 0; i < 6; i++) {
|
||||
if(roleInfo.heros.length - 1 < i) break;
|
||||
heroes.push(roleInfo.heros[i].seqId);
|
||||
}
|
||||
return heroes
|
||||
}
|
||||
|
||||
function checkBattle(pinusClient, heroes, battleId, type, cb) {
|
||||
pinusClient.request('battle.normalBattleHandler.checkBattle', { battleId, heroes }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.battleId).to.be.a('number');
|
||||
expect(res.data.battleCode).to.be.a('string');
|
||||
expect(res.data.status).to.equal(0);
|
||||
|
||||
if(type == 'daily') {
|
||||
|
||||
} else if (type == 'tower') {
|
||||
|
||||
} else if (type == 'dungeon') {
|
||||
|
||||
}
|
||||
cb(res.data, heroes);
|
||||
});
|
||||
}
|
||||
|
||||
function checkActorData(actordata) {
|
||||
expect(actordata).to.be.an('array');
|
||||
actordata.forEach(actor => {
|
||||
expect(actor.lv).to.be.a('number');
|
||||
expect(actor.exp).to.be.a('number');
|
||||
expect(actor.getExp).to.be.a('number');
|
||||
expect(actor.mostExp).to.be.a('number');
|
||||
})
|
||||
}
|
||||
|
||||
function battleEnd(pinusClient, heroes, battleId, battleCode, type, cb) {
|
||||
pinusClient.request('battle.normalBattleHandler.battleEnd', { battleId, battleCode, heroes, isSuccess: true, stars: [1,1,1] }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.battleId).to.be.a('number');
|
||||
expect(res.data.battleCode).to.be.a('string');
|
||||
expect(res.data.status).to.equal(1);
|
||||
checkBattleGoods(res.data.battleGoods);
|
||||
expect(res.data.lv).to.be.a('number');
|
||||
expect(res.data.exp).to.be.a('number');
|
||||
expect(res.data.kingExp).to.be.a('number');
|
||||
checkActorData(res.data.actordata);
|
||||
if(type == 'daily') {
|
||||
|
||||
} else if (type == 'tower') {
|
||||
|
||||
} else if (type == 'dungeon') {
|
||||
|
||||
}
|
||||
|
||||
cb(res.data);
|
||||
});
|
||||
}
|
||||
|
||||
function battleSweep(pinusClient, battleId, type, cb) {
|
||||
|
||||
pinusClient.request('battle.normalBattleHandler.battleSweep', { battleId, count: 1 }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.battleId).to.be.a('number');
|
||||
expect(res.data.count).to.be.a('number');
|
||||
checkBattleGoods(res.data.battleGoods);
|
||||
checkActorData(res.data.actordata);
|
||||
expect(res.data.lv).to.be.a('number');
|
||||
expect(res.data.exp).to.be.a('number');
|
||||
expect(res.data.kingExp).to.be.a('number');
|
||||
|
||||
if(type == 'daily') {
|
||||
|
||||
} else if (type == 'tower') {
|
||||
|
||||
} else if (type == 'dungeon') {
|
||||
|
||||
}
|
||||
cb();
|
||||
});
|
||||
}
|
||||
@@ -13,7 +13,7 @@ describe('好友测试测试', function() {
|
||||
let roleInfoT;
|
||||
let applyCode;
|
||||
|
||||
beforeEach(function(done) {
|
||||
before(function(done) {
|
||||
const c = new Client();
|
||||
const cT = new Client('13121622738');
|
||||
const timer = setInterval(() => {
|
||||
@@ -28,7 +28,7 @@ describe('好友测试测试', function() {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
after(function(done) {
|
||||
pinusClient.disconnect();
|
||||
pinusClientT.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('抽卡测试', function () {
|
||||
let pinusClient: PinusWSClient;
|
||||
let roleInfo;
|
||||
|
||||
beforeEach(function (done) {
|
||||
before(function (done) {
|
||||
const c = new Client();
|
||||
const timer = setInterval(() => {
|
||||
if (c.client) {
|
||||
@@ -22,7 +22,7 @@ describe('抽卡测试', function () {
|
||||
}, 500);
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
after(function (done) {
|
||||
pinusClient.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('军团测试', function() {
|
||||
let pinusClient: PinusWSClient;
|
||||
let guildList;
|
||||
|
||||
beforeEach(function(done) {
|
||||
before(function(done) {
|
||||
const c = new Client();
|
||||
const timer = setInterval(() => {
|
||||
if (c.client) {
|
||||
@@ -18,7 +18,7 @@ describe('军团测试', function() {
|
||||
}, 500);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
after(function(done) {
|
||||
pinusClient.disconnect();
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('pvp测试', function () {
|
||||
let receivedBox = [];
|
||||
let hisScore = 0;
|
||||
|
||||
beforeEach(function (done) {
|
||||
before(function (done) {
|
||||
const c = new Client();
|
||||
const timer = setInterval(() => {
|
||||
if (c.client) {
|
||||
@@ -31,7 +31,7 @@ describe('pvp测试', function () {
|
||||
}, 500);
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
after(function (done) {
|
||||
pinusClient.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
setTimeout(() => {
|
||||
@@ -337,6 +337,20 @@ describe('pvp测试', function () {
|
||||
});
|
||||
|
||||
|
||||
it('获得战报', function(done) {
|
||||
pinusClient.request('battle.pvpHandler.getRec', { }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.list).to.be.a('array');
|
||||
res.data.list.forEach(rec => {
|
||||
expect(rec.roleId1).to.be.a('string');
|
||||
expect(rec.roleId2).to.be.a('string');
|
||||
expect(rec.warId).to.be.a('number');
|
||||
checkRecInfo(rec.attackInfo);
|
||||
checkRecInfo(rec.defenseInfo);
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -474,4 +488,34 @@ function checkOldSeasonData(oldSeasonData) {
|
||||
expect(oldSeasonData.seasonNum).to.be.a('number');
|
||||
checkTimeStamp(oldSeasonData.seasonEndTime, 10, true);
|
||||
expect(oldSeasonData.rankLv).to.be.a('number');
|
||||
}
|
||||
|
||||
|
||||
function checkRecInfo(info) {
|
||||
expect(info.roleId).to.be.a('string');
|
||||
expect(info.roleName).to.be.a('string');
|
||||
expect(info.lv).to.be.a('number');
|
||||
expect(info.spine).to.be.a('number');
|
||||
expect(info.head).to.be.a('number');
|
||||
expect(info.frame).to.be.a('number');
|
||||
expect(info.title).to.be.a('number');
|
||||
expect(info.ce).to.be.a('number');
|
||||
expect(info.isSuccess).to.be.a('boolean');
|
||||
expect(info.score).to.be.a('number');
|
||||
checkRecHero(info.heroes);
|
||||
}
|
||||
|
||||
function checkRecHero(heroes) {
|
||||
expect(heroes).to.be.an('array');
|
||||
heroes.forEach(hero => {
|
||||
expect(hero.hid).to.be.a('number');
|
||||
expect(hero.skinId).to.be.a('number');
|
||||
expect(hero.quality).to.be.a('number');
|
||||
expect(hero.star).to.be.a('number');
|
||||
expect(hero.colorStar).to.be.a('number');
|
||||
expect(hero.lv).to.be.a('number');
|
||||
expect(hero.damage).to.be.a('number');
|
||||
expect(hero.heal).to.be.a('number');
|
||||
expect(hero.underDamage).to.be.a('number');
|
||||
})
|
||||
}
|
||||
@@ -10,7 +10,7 @@ describe('排行榜测试', function() {
|
||||
let pinusClient: PinusWSClient;
|
||||
let roleInfo;
|
||||
|
||||
beforeEach(function(done) {
|
||||
before(function(done) {
|
||||
const c = new Client();
|
||||
const timer = setInterval(() => {
|
||||
if (c.client) {
|
||||
@@ -22,7 +22,7 @@ describe('排行榜测试', function() {
|
||||
}, 500);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
after(function(done) {
|
||||
pinusClient.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('任务测试', function () {
|
||||
let pinusClient: PinusWSClient;
|
||||
let roleInfo;
|
||||
|
||||
beforeEach(function (done) {
|
||||
before(function (done) {
|
||||
const c = new Client();
|
||||
const timer = setInterval(() => {
|
||||
if (c.client) {
|
||||
@@ -23,7 +23,7 @@ describe('任务测试', function () {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
after(function (done) {
|
||||
pinusClient.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
setTimeout(() => {
|
||||
@@ -35,6 +35,7 @@ describe('任务测试', function () {
|
||||
checkMainTask(roleInfo.mainTask);
|
||||
checkDailyTask(roleInfo.dailyTask);
|
||||
checkAchievement(roleInfo.achievement);
|
||||
checkPvpTask(roleInfo.pvpTask);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -85,6 +86,9 @@ describe('任务测试', function () {
|
||||
|
||||
});
|
||||
});
|
||||
it('检查领取pvp任务', function (done) {
|
||||
checkReceiveTask(pinusClient, done, TASK_FUN_TYPE.PVP);
|
||||
});
|
||||
|
||||
it('领取每周活跃奖励', function (done) {
|
||||
checkReceiveBox(pinusClient, done, TASK_FUN_TYPE.DAILY)
|
||||
@@ -164,6 +168,13 @@ function checkAchievement(achievement) {
|
||||
})
|
||||
}
|
||||
|
||||
// 检查pvp任务数据
|
||||
function checkPvpTask(pvpTask) {
|
||||
if (!pvpTask) return;
|
||||
expect(pvpTask.taskList).to.be.an('array');
|
||||
pvpTask.taskList.forEach(task => checkSingleTask(task));
|
||||
}
|
||||
|
||||
// 检查在taskList中的某一个任务数据
|
||||
function checkSingleTask(task) {
|
||||
expect(task).to.be.an('object');
|
||||
|
||||
Reference in New Issue
Block a user