测试:添加战斗测试
This commit is contained in:
@@ -138,7 +138,22 @@ export class GachaHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
let userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { hope: hope.map(cur => { return { ...cur, hasGet: false } }) })
|
||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaId);
|
||||
let { hope: userHope = []} = await refreshGacha(gameData.gacha.get(gachaId), userGacha);
|
||||
for (let { id, hid } of hope) {
|
||||
let curHope = userHope.find(cur => cur.id == id);
|
||||
if(curHope) {
|
||||
if(curHope.hasGet) {
|
||||
continue;
|
||||
} else {
|
||||
curHope.hid = hid;
|
||||
curHope.hasGet = false;
|
||||
}
|
||||
} else {
|
||||
userHope.push({ id, hid, hasGet: false })
|
||||
}
|
||||
}
|
||||
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { hope: userHope });
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
gachaId,
|
||||
|
||||
@@ -256,6 +256,8 @@ export class ShopHandler {
|
||||
} else if (type == TASK_FUN_TYPE.ACHIEVEMENT) {
|
||||
await UserTaskModel.updateInfo(roleId, { achievementBox: [], achievementPoint: 0 });
|
||||
userTask = await removeHistoryTask(roleId, type, new Date(nowSeconds() * 1000 + 86400000));
|
||||
} else if (type == TASK_FUN_TYPE.PVP) {
|
||||
userTask = await removeHistoryTask(roleId, type, new Date(nowSeconds() * 1000 + 86400000));
|
||||
}
|
||||
|
||||
let curTask = await getCurTask(roleId, session);;
|
||||
|
||||
@@ -21,9 +21,9 @@ export async function getDailyBattleList(role: RoleType) {
|
||||
let dicDaily = gameData.daily;
|
||||
|
||||
let result = new Array();
|
||||
for(let {dailyType: type, name, timesPerDay, timesCanBuy } of dicDaily) {
|
||||
for(let {dailyType: type, timesPerDay, timesCanBuy } of dicDaily) {
|
||||
let refreshResult = await DailyRecordModel.refreshRecord(roleId, type);
|
||||
let wars: {battleId: number, cost: number, star: number, status: number, name: string}[] = new Array();
|
||||
let wars: {battleId: number, cost: number, star: number, status: number}[] = new Array();
|
||||
let dicDailyWar = gameData.dailyWarByType.get(type);
|
||||
for(let dic of dicDailyWar) {
|
||||
let war = getDailyWarStatus(dic, warStar);
|
||||
@@ -31,7 +31,7 @@ export async function getDailyBattleList(role: RoleType) {
|
||||
}
|
||||
let checkDailyResult = await getDailyNum(refreshResult, timesPerDay, timesCanBuy);
|
||||
result.push({
|
||||
type, name, ...checkDailyResult,
|
||||
type, ...checkDailyResult,
|
||||
wars
|
||||
});
|
||||
}
|
||||
@@ -39,7 +39,7 @@ export async function getDailyBattleList(role: RoleType) {
|
||||
}
|
||||
|
||||
function getDailyWarStatus(dicDailyWar: DicWar, warStar: WarStar[]) {
|
||||
let {war_id, cost, gk_name, previousGk } = dicDailyWar;
|
||||
let {war_id, cost, previousGk } = dicDailyWar;
|
||||
let status = 0, star = 0;
|
||||
let curBattle = warStar.find(cur => cur.id == war_id);
|
||||
if(curBattle) {
|
||||
@@ -58,7 +58,7 @@ function getDailyWarStatus(dicDailyWar: DicWar, warStar: WarStar[]) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
battleId: war_id, cost, star, status, name: gk_name
|
||||
battleId: war_id, cost, star, status
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,10 +158,10 @@ module.exports = {
|
||||
"battle.normalBattleHandler.getBattleList": {
|
||||
"required uInt32 type": 1
|
||||
},
|
||||
"battle.normalBattleHandler.checkBattle": {
|
||||
"required uInt32 battleId": 1,
|
||||
"repeated uInt32 heroes": 2
|
||||
},
|
||||
// "battle.normalBattleHandler.checkBattle": {
|
||||
// "required uInt32 battleId": 1,
|
||||
// "repeated uInt32 heroes": 2
|
||||
// },
|
||||
"battle.dungeonBattleHandler.buyNum": {
|
||||
"required uInt32 count": 1
|
||||
},
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -353,6 +353,7 @@ export const STATUS = {
|
||||
GACHA_TURNTABLE_POINT_NOT_ENOUGH: { code: 31105, simStr: '转盘积分不足' },
|
||||
GACHA_HAS_VISITED: { code: 31106, simStr: '该武将已拜访过' },
|
||||
GACHA_VISITED_COUNT_OVER: { code: 31107, simStr: '今天武将拜访已超过次数' },
|
||||
GACHA_HOPE_HAS_GET: { code: 31108, simStr: '该心愿已实现' },
|
||||
// 礼包码 31201-31300
|
||||
GIFT_CODE_USED_NUM_MAX: { code: 31201, simStr: '礼包码使用次数超过' },
|
||||
YOU_HAVE_USED_THIS_CODE: { code: 31202, simStr: '您已使用过该码' },
|
||||
|
||||
Reference in New Issue
Block a user