259 lines
6.8 KiB
TypeScript
259 lines
6.8 KiB
TypeScript
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();
|
||
});
|
||
} |