测试:pvp测试
This commit is contained in:
@@ -12,7 +12,7 @@ import { PVPConfigModel } from '../../../db/SystemConfig';
|
|||||||
import { Rank } from '../../../services/rankService';
|
import { Rank } from '../../../services/rankService';
|
||||||
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
|
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
|
||||||
import { Attack, AttackHero, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp';
|
import { Attack, AttackHero, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp';
|
||||||
import { FIGURE_UNLOCK_CONDITION, LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
import { DEBUG_MAGIC_WORD, FIGURE_UNLOCK_CONDITION, LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
||||||
import { PVP } from '../../../pubUtils/dicParam';
|
import { PVP } from '../../../pubUtils/dicParam';
|
||||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||||
import { addItems, handleCost, unlockFigure } from '../../../services/rewardService';
|
import { addItems, handleCost, unlockFigure } from '../../../services/rewardService';
|
||||||
@@ -592,4 +592,33 @@ export class PvpHandler {
|
|||||||
return resResult(STATUS.SUCCESS, { challengeCnt, challengeRefTime });
|
return resResult(STATUS.SUCCESS, { challengeCnt, challengeRefTime });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async debugResetRefOppCnt(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
|
let roleId = session.get('roleId');
|
||||||
|
await PvpDefenseModel.updateInfo(roleId, { refOppCnt: 0 });
|
||||||
|
return resResult(STATUS.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
async debugResetAttackCnt(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
|
let roleId = session.get('roleId');
|
||||||
|
await PvpDefenseModel.updateInfo(roleId, { setAttackCnt: 0, buyAttackCnt: 0 });
|
||||||
|
return resResult(STATUS.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
async debugResetBox(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
|
let roleId = session.get('roleId');
|
||||||
|
await PvpDefenseModel.updateInfo(roleId, { hisScore: 5000, receivedBox: [] });
|
||||||
|
return resResult(STATUS.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ export class AuctionHandler {
|
|||||||
return resResult(STATUS.TOKEN_ERR);
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
const guildCode: string = session.get('guildCode');
|
let guildCode: string = session.get('guildCode');
|
||||||
const serverId: number = session.get('serverId');
|
const serverId: number = session.get('serverId');
|
||||||
if (!guildCode) {//创建公会
|
if (!guildCode) {//创建公会
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
@@ -265,6 +265,9 @@ export class AuctionHandler {
|
|||||||
|
|
||||||
await RoleModel.joinGuild(roleId, guild.code, guild.name);
|
await RoleModel.joinGuild(roleId, guild.code, guild.name);
|
||||||
await UserGuildApplyModel.deleteApply(roleId); // 删除玩家所有对其他公会的申请
|
await UserGuildApplyModel.deleteApply(roleId); // 删除玩家所有对其他公会的申请
|
||||||
|
guildCode = guild.code;
|
||||||
|
session.set('guildCode', guildCode);
|
||||||
|
session.push('guildCode', () => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
let rewards = getAuctionRewardByPoolId(poolId);
|
let rewards = getAuctionRewardByPoolId(poolId);
|
||||||
|
|||||||
@@ -49,9 +49,73 @@ export function checkHero(heroes) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addItem(pinusClient, id, count, cb) {
|
export function addItem(pinusClient, id: number, count: number, cb) {
|
||||||
pinusClient.request('role.heroHandler.addItem', { id, count }, res => {
|
pinusClient.request('role.heroHandler.addItem', { id, count }, res => {
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
cb(res);
|
cb(res);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addItemsIfNotEnough(roleInfo, pinusClient, id: number, count: number, cb) {
|
||||||
|
if(id == 31001) {
|
||||||
|
if(roleInfo.coin < count) {
|
||||||
|
return addItem(pinusClient, id, count, () => {
|
||||||
|
roleInfo.coin += count;
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (id == 31002) {
|
||||||
|
if(roleInfo.gold < count) {
|
||||||
|
return addItem(pinusClient, id, count, () => {
|
||||||
|
roleInfo.gold += count;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let consumeGoods = roleInfo.consumeGoods||[];
|
||||||
|
let cur = consumeGoods.find(cur => cur.id == id);
|
||||||
|
if(!cur || cur.count < count) {
|
||||||
|
return addItem(pinusClient, id, count, () => {
|
||||||
|
if(!cur) {
|
||||||
|
consumeGoods.push({ id, count });
|
||||||
|
} else {
|
||||||
|
cur.count += count;
|
||||||
|
}
|
||||||
|
roleInfo.consumeGoods = consumeGoods;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkTimeStamp(time, len, canBeZero) {
|
||||||
|
if(canBeZero) {
|
||||||
|
if(time == 0) return true;
|
||||||
|
} else {
|
||||||
|
expect(time).to.be.a('number');
|
||||||
|
expect(time.toString().length).to.equal(len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkWarJson(heroes) {
|
||||||
|
expect(heroes).to.be.an('array');
|
||||||
|
heroes.forEach(hero => {
|
||||||
|
expect(hero.actorId).to.be.a('number');
|
||||||
|
expect(hero.skinId).to.be.a('number');
|
||||||
|
expect(hero.actorName).to.be.a('string');
|
||||||
|
expect(hero.dataId).to.be.a('number');
|
||||||
|
expect(hero.relation).to.be.a('number');
|
||||||
|
expect(hero.dirction).to.be.a('number');
|
||||||
|
expect(hero.outIndex).to.be.a('number');
|
||||||
|
expect(hero.x).to.be.a('number');
|
||||||
|
expect(hero.y).to.be.a('number');
|
||||||
|
expect(hero.var).to.be.a('number');
|
||||||
|
expect(hero.lv).to.be.a('number');
|
||||||
|
expect(hero.hide).to.be.a('number');
|
||||||
|
expect(hero.initial_ai).to.be.a('number');
|
||||||
|
expect(hero.attribute).to.be.a('string');
|
||||||
|
expect(hero.star).to.be.a('number');
|
||||||
|
expect(hero.skill).to.be.a('string');
|
||||||
|
expect(hero.seid).to.be.a('string');
|
||||||
|
expect(hero.spine).to.be.a('string');
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ import { Client } from './Client';
|
|||||||
import 'mocha';
|
import 'mocha';
|
||||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { checkSuccessResponse } from './CheckPatten';
|
import { addItemsIfNotEnough, checkSuccessResponse } from './CheckPatten';
|
||||||
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE, CURRENCY_BY_TYPE, CURRENCY_TYPE, AUCTION_STAGE, DIVIDEND_STATUS } from '../app/consts';
|
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE, CURRENCY_BY_TYPE, CURRENCY_TYPE, AUCTION_STAGE, DIVIDEND_STATUS } from '../app/consts';
|
||||||
import { LOT_STATUS } from '../../shared/consts';
|
import { LOT_STATUS } from '../../shared/consts';
|
||||||
|
|
||||||
@@ -52,19 +52,14 @@ function checkDividends(dividends) {
|
|||||||
|
|
||||||
describe('拍卖行测试', function () {
|
describe('拍卖行测试', function () {
|
||||||
let pinusClient: PinusWSClient;
|
let pinusClient: PinusWSClient;
|
||||||
let pinusClientT: PinusWSClient; // 用做测试队友
|
|
||||||
let roleInfo;
|
let roleInfo;
|
||||||
let roleInfoT;
|
|
||||||
|
|
||||||
before(function (done) {
|
before(function (done) {
|
||||||
const c = new Client();
|
const c = new Client();
|
||||||
const cT = new Client('13121622738');
|
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
if (c.client && cT.client) {
|
if (c.client) {
|
||||||
pinusClient = c.client;
|
pinusClient = c.client;
|
||||||
roleInfo = c.roleInfo;
|
roleInfo = c.roleInfo;
|
||||||
pinusClientT = cT.client;
|
|
||||||
roleInfoT = cT.roleInfo;
|
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@@ -73,7 +68,6 @@ describe('拍卖行测试', function () {
|
|||||||
|
|
||||||
after(function (done) {
|
after(function (done) {
|
||||||
pinusClient.disconnect();
|
pinusClient.disconnect();
|
||||||
pinusClientT.disconnect();
|
|
||||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
done();
|
done();
|
||||||
@@ -118,48 +112,50 @@ describe('拍卖行测试', function () {
|
|||||||
expect(info.id).to.be.equal(gid);
|
expect(info.id).to.be.equal(gid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pinusClient.request('guild.auctionHandler.getAuction', {}, (res) => {
|
addItemsIfNotEnough(roleInfo, pinusClient, 31002, 100000, () => {
|
||||||
checkSuccessResponse(res);
|
pinusClient.request('guild.auctionHandler.getAuction', {}, (res) => {
|
||||||
expect(res.data.lots).to.be.an('array');
|
|
||||||
checkLots(res.data.lots);
|
|
||||||
expect(res.data.dividends).to.be.an('array');
|
|
||||||
checkDividends(res.data.dividends);
|
|
||||||
if (res.data.lots.length === 0) {
|
|
||||||
console.warn('没有拍品');
|
|
||||||
done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let unsoldLots = res.data.lots.filter(lot => { return lot.status !== LOT_STATUS.SOLD && lot.curBuyer !== roleInfo.roleId });
|
|
||||||
if (unsoldLots.length === 0) {
|
|
||||||
console.warn('没有可出价的拍品');
|
|
||||||
done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pinusClient.request('guild.auctionHandler.offer', { code: unsoldLots[0].code, max: false }, (res) => {
|
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
checkLot(res.data.lot);
|
expect(res.data.lots).to.be.an('array');
|
||||||
if (res.data.dividend) {
|
checkLots(res.data.lots);
|
||||||
checkDividend(res.data.dividend);
|
expect(res.data.dividends).to.be.an('array');
|
||||||
}
|
checkDividends(res.data.dividends);
|
||||||
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
if (res.data.lots.length === 0) {
|
||||||
|
console.warn('没有拍品');
|
||||||
unsoldLots.shift();
|
|
||||||
if (unsoldLots.length === 0) {
|
|
||||||
console.warn('没有测试一口价的情况');
|
|
||||||
done();
|
done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gid = unsoldLots[0].gid;
|
let unsoldLots = res.data.lots.filter(lot => { return lot.status !== LOT_STATUS.SOLD && lot.curBuyer !== roleInfo.roleId });
|
||||||
pinusClient.request('guild.auctionHandler.offer', { code: unsoldLots[0].code, max: true }, (res) => {
|
if (unsoldLots.length === 0) {
|
||||||
|
console.warn('没有可出价的拍品');
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pinusClient.request('guild.auctionHandler.offer', { code: unsoldLots[0].code, max: false }, (res) => {
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
checkLot(res.data.lot);
|
checkLot(res.data.lot);
|
||||||
if(res.data.dividend) {
|
if (res.data.dividend) {
|
||||||
checkDividend(res.data.dividend);
|
checkDividend(res.data.dividend);
|
||||||
}
|
}
|
||||||
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
||||||
setTimeout(() => {
|
|
||||||
|
unsoldLots.shift();
|
||||||
|
if (unsoldLots.length === 0) {
|
||||||
|
console.warn('没有测试一口价的情况');
|
||||||
done();
|
done();
|
||||||
}, 1000);
|
return;
|
||||||
|
}
|
||||||
|
gid = unsoldLots[0].gid;
|
||||||
|
pinusClient.request('guild.auctionHandler.offer', { code: unsoldLots[0].code, max: true }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkLot(res.data.lot);
|
||||||
|
if(res.data.dividend) {
|
||||||
|
checkDividend(res.data.dividend);
|
||||||
|
}
|
||||||
|
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
||||||
|
setTimeout(() => {
|
||||||
|
done();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+396
-84
@@ -2,24 +2,36 @@ import { Client } from './Client';
|
|||||||
import 'mocha';
|
import 'mocha';
|
||||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { checkSuccessResponse } from './CheckPatten';
|
import { addItemsIfNotEnough, checkDisplayItems, checkSuccessResponse, checkTimeStamp, checkWarJson } from './CheckPatten';
|
||||||
/*
|
import { PVP } from '../app/pubUtils/dicParam';
|
||||||
describe('pvp测试', function() {
|
import { DEBUG_MAGIC_WORD } from '../app/consts';
|
||||||
let pinusClient: PinusWSClient;
|
import { getRandSingleEelm } from '../app/pubUtils/util';
|
||||||
let detailRoleId;
|
|
||||||
|
|
||||||
beforeEach(function(done) {
|
describe('pvp测试', function () {
|
||||||
|
let pinusClient: PinusWSClient;
|
||||||
|
let roleInfo;
|
||||||
|
let oppPlayers = [];
|
||||||
|
let setAttackCnt = 0;
|
||||||
|
let buyAttackCnt = 0;
|
||||||
|
let refOppCnt = 0;
|
||||||
|
let challengeCnt = 0;
|
||||||
|
let attack;
|
||||||
|
let receivedBox = [];
|
||||||
|
let hisScore = 0;
|
||||||
|
|
||||||
|
beforeEach(function (done) {
|
||||||
const c = new Client();
|
const c = new Client();
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
if (c.client) {
|
if (c.client) {
|
||||||
pinusClient = c.client;
|
pinusClient = c.client;
|
||||||
|
roleInfo = c.roleInfo;
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function(done) {
|
afterEach(function (done) {
|
||||||
pinusClient.disconnect();
|
pinusClient.disconnect();
|
||||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -27,15 +39,155 @@ describe('pvp测试', function() {
|
|||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('获得主界面信息', function(done) {
|
it('获得主界面信息', function (done) {
|
||||||
getData(pinusClient, false, function(data) {
|
getData(pinusClient, false, function (data) {
|
||||||
detailRoleId = data.oppPlayers[0].roleId;
|
oppPlayers = data.oppPlayers;
|
||||||
done();
|
setAttackCnt = data.setAttackCnt;
|
||||||
|
buyAttackCnt = data.buyAttackCnt;
|
||||||
|
refOppCnt = data.refOppCnt;
|
||||||
|
challengeCnt = data.challengeCnt;
|
||||||
|
attack = data.attack;
|
||||||
|
done();
|
||||||
}); // 先不结算赛季
|
}); // 先不结算赛季
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('保存防守阵容', function (done) {
|
||||||
|
let myHeroes = roleInfo.heros || [];
|
||||||
|
let heroes = [];
|
||||||
|
for (let i = 0; i < 6; i++) {
|
||||||
|
if (myHeroes.length - 1 < i) break;
|
||||||
|
heroes.push({
|
||||||
|
actorId: myHeroes[i].hid,
|
||||||
|
ai: Math.floor(Math.random() * 2),
|
||||||
|
dataId: 2001 + i,
|
||||||
|
order: i + 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pinusClient.request('battle.pvpHandler.saveDefense', { warId: 4501, buff: 50101, heroes }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkDefense(res.data.defense);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function debugResetAttackCnt(cb) {
|
||||||
|
pinusClient.request('battle.pvpHandler.debugResetAttackCnt', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||||
|
setAttackCnt = 0;
|
||||||
|
buyAttackCnt = 0;
|
||||||
|
cb();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
it('购买保存挑战阵容次数', function (done) {
|
||||||
|
if (buyAttackCnt >= PVP.PVP_BUY_SET_ATTACK_CNT) {
|
||||||
|
debugResetAttackCnt(() => {
|
||||||
|
buyAttackCount();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
buyAttackCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
function buyAttackCount() {
|
||||||
|
pinusClient.request('battle.pvpHandler.buyAttackCnt', { count: 1 }, res => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
expect(res.data.refOppCnt).to.be.a('number');
|
||||||
|
expect(res.data.setAttackCnt).to.be.a('number');
|
||||||
|
expect(res.data.buyAttackCnt).to.be.a('number');
|
||||||
|
refOppCnt = res.data.refOppCnt;
|
||||||
|
setAttackCnt = res.data.setAttackCnt;
|
||||||
|
buyAttackCnt = res.data.buyAttackCnt;
|
||||||
|
if (res.data.oppPlayers) {
|
||||||
|
checkOppPlayers(res.data.oppPlayers);
|
||||||
|
oppPlayers = res.data.oppPlayers;
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('保存挑战阵容', function (done) {
|
||||||
|
if (setAttackCnt >= buyAttackCnt + PVP.PVP_SET_ATTACK_FREE_CNT) { // 次数不足
|
||||||
|
debugResetAttackCnt(() => {
|
||||||
|
saveAttack();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
saveAttack();
|
||||||
|
}
|
||||||
|
function saveAttack() {
|
||||||
|
let myHeroes = roleInfo.heros || [];
|
||||||
|
let heroes = [];
|
||||||
|
for (let i = 0; i < 6; i++) {
|
||||||
|
if (myHeroes.length - 1 < i) break;
|
||||||
|
heroes.push({
|
||||||
|
actorId: myHeroes[i].hid,
|
||||||
|
order: i + 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pinusClient.request('battle.pvpHandler.saveAttack', { heroes }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkAttack(res.data.attack);
|
||||||
|
attack = res.data.attack;
|
||||||
|
checkOppPlayers(res.data.oppPlayers);
|
||||||
|
expect(res.data.setAttackCnt).to.equal(setAttackCnt + 1);
|
||||||
|
setAttackCnt = res.data.setAttackCnt;
|
||||||
|
oppPlayers = res.data.oppPlayers;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function debugResetRefOppCnt(cb) {
|
||||||
|
pinusClient.request('battle.pvpHandler.debugResetRefOppCnt', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||||
|
refOppCnt = 0
|
||||||
|
cb();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
it('刷新匹配对手', function (done) {
|
||||||
|
if (refOppCnt >= 8) { // 次数不足
|
||||||
|
debugResetRefOppCnt(() => {
|
||||||
|
refreshOppPlayer();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
refreshOppPlayer();
|
||||||
|
}
|
||||||
|
function refreshOppPlayer() {
|
||||||
|
addItemsIfNotEnough(roleInfo, pinusClient, 31002, 50, () => {
|
||||||
|
pinusClient.request('battle.pvpHandler.refreshOppPlayer', {}, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkOppPlayers(res.data.oppPlayers);
|
||||||
|
expect(res.data.refOppCnt).to.equal(refOppCnt + 1);
|
||||||
|
expect(res.data.setAttackCnt).to.equal(setAttackCnt);
|
||||||
|
setAttackCnt = res.data.setAttackCnt;
|
||||||
|
refOppCnt = res.data.refOppCnt;
|
||||||
|
oppPlayers = res.data.oppPlayers;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let chosenOpp;
|
||||||
|
let curWarId;
|
||||||
|
let battleCode;
|
||||||
|
let chosenOppHeroes;
|
||||||
|
|
||||||
|
it('获取对手阵容具体信息', function (done) {
|
||||||
|
chosenOpp = getRandSingleEelm(oppPlayers);
|
||||||
|
pinusClient.request('battle.pvpHandler.getOppPlayer', { roleId: chosenOpp.roleId }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
expect(res.data.roleId).to.equal(chosenOpp.roleId);
|
||||||
|
expect(res.data.pos).to.equal(chosenOpp.pos);
|
||||||
|
expect(res.data.warId).to.be.a('number');
|
||||||
|
curWarId = res.data.warId
|
||||||
|
expect(res.data.buff).to.be.a('number');
|
||||||
|
checkWarJson(res.data.heroes);
|
||||||
|
chosenOppHeroes = res.data.heroes;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('获取对手详细信息', function(done) {
|
it('获取对手详细信息', function(done) {
|
||||||
pinusClient.request('battle.pvpHandler.getPlayerDetail', { roleId: detailRoleId }, (res) => {
|
pinusClient.request('battle.pvpHandler.getPlayerDetail', { roleId: chosenOpp.roleId }, (res) => {
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
expect(res.data.roleId).to.be.a('string');
|
expect(res.data.roleId).to.be.a('string');
|
||||||
expect(res.data.roleName).to.be.a('string');
|
expect(res.data.roleName).to.be.a('string');
|
||||||
@@ -51,6 +203,8 @@ describe('pvp测试', function() {
|
|||||||
expect(res.data.heroes).to.be.a('array');
|
expect(res.data.heroes).to.be.a('array');
|
||||||
res.data.heroes.forEach(hero => {
|
res.data.heroes.forEach(hero => {
|
||||||
expect(hero.actorId).to.be.a('number');
|
expect(hero.actorId).to.be.a('number');
|
||||||
|
expect(hero.isDefense).to.be.a('boolean');
|
||||||
|
expect(hero.skinId).to.be.a('number');
|
||||||
expect(hero.lv).to.be.a('number');
|
expect(hero.lv).to.be.a('number');
|
||||||
expect(hero.star).to.be.a('number');
|
expect(hero.star).to.be.a('number');
|
||||||
expect(hero.colorStar).to.be.a('number');
|
expect(hero.colorStar).to.be.a('number');
|
||||||
@@ -61,16 +215,70 @@ describe('pvp测试', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('刷新对手', function(done) {
|
function debugAddChallengeCnt(cb) {
|
||||||
pinusClient.request('battle.pvpHandler.debugAddChallengeCnt', { challengeCnt: 1 }, cb => {
|
pinusClient.request('battle.pvpHandler.debugAddChallengeCnt', { magicWord: DEBUG_MAGIC_WORD, challengeCnt: 10 }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
pinusClient.request('battle.pvpHandler.refreshOppPlayer', { }, (res) => {
|
expect(res.data.challengeCnt).to.be.a('number');
|
||||||
checkSuccessResponse(res);
|
challengeCnt = res.data.challengeCnt;
|
||||||
checkOppPlayers(res.data.oppPlayers);
|
cb();
|
||||||
expect(res.data.refOppCnt).to.be.a('number');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
it('开始挑战', function (done) {
|
||||||
|
if(challengeCnt <= 0) {
|
||||||
|
debugAddChallengeCnt(() => {
|
||||||
|
pvpStart();
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
pvpStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
function pvpStart() {
|
||||||
|
chosenOpp = getRandSingleEelm(oppPlayers);
|
||||||
|
pinusClient.request('battle.pvpHandler.pvpStart', { warId: curWarId, roleId: chosenOpp.roleId }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
expect(res.data.battleCode).to.a('string');
|
||||||
|
battleCode = res.data.battleCode;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('结束挑战', function (done) {
|
||||||
|
if(!attack || !attack.heroes) {
|
||||||
|
console.error('没有挑战阵容'); return;
|
||||||
|
}
|
||||||
|
function ranDamage() {
|
||||||
|
return Math.floor(Math.random() * 1000)
|
||||||
|
}
|
||||||
|
let myHeroes = attack.heroes.map(cur => {
|
||||||
|
return { hid: cur.actorId, damage: ranDamage(), heal: ranDamage(), underDamage: ranDamage()}
|
||||||
|
});
|
||||||
|
let oppHeroes = chosenOppHeroes.filter(cur => cur.actorId > 0).map(cur => {
|
||||||
|
return { hid: cur.actorId, damage: ranDamage(), heal: ranDamage(), underDamage: ranDamage() }
|
||||||
|
})
|
||||||
|
pinusClient.request('battle.pvpHandler.pvpEnd', { battleCode, isSuccess: true, myHeroes, oppHeroes }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
expect(res.data.score).to.a('number');
|
||||||
|
expect(res.data.myRank).to.a('number');
|
||||||
|
expect(res.data.winStreakNum).to.a('number');
|
||||||
|
|
||||||
|
expect(res.data.heroScores).to.be.a('array');
|
||||||
|
res.data.heroScores.forEach(heroScore => {
|
||||||
|
expect(heroScore.hid).to.be.a('number');
|
||||||
|
expect(heroScore.addScore).to.be.a('number');
|
||||||
|
expect(heroScore.plusScore).to.be.a('number');
|
||||||
|
expect(heroScore.score).to.be.a('number');
|
||||||
|
});
|
||||||
|
|
||||||
|
checkAttack(res.data.attack);
|
||||||
|
checkOppPlayers(res.data.oppPlayers);
|
||||||
|
oppPlayers = res.data.oppPlayers;
|
||||||
|
expect(res.data.challengeCnt).to.equal(challengeCnt - 1);
|
||||||
|
checkTimeStamp(res.data.challengeRefTime, 10, true);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('获得排行榜', function(done) {
|
it('获得排行榜', function(done) {
|
||||||
@@ -85,81 +293,185 @@ describe('pvp测试', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function debugResetBox(cb) {
|
||||||
|
pinusClient.request('battle.pvpHandler.debugResetBox', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||||
|
receivedBox = [];
|
||||||
|
hisScore = 5000;
|
||||||
|
cb();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
it('领取巅峰之路奖励', function(done) {
|
||||||
|
let id = Math.floor(Math.random() * 10);
|
||||||
|
if(receivedBox.includes(id) || hisScore < 5000) {
|
||||||
|
debugResetBox(() => {
|
||||||
|
receiveBox();
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
receiveBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
function receiveBox() {
|
||||||
|
receiveSingleBox(id, 1, () => {
|
||||||
|
receiveSingleBox(id, 2, () => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function receiveSingleBox(id, count, cb) {
|
||||||
|
pinusClient.request('battle.pvpHandler.receiveBox', { id }, (res) => {
|
||||||
|
if(count == 1) {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkDisplayItems(res.data.goods);
|
||||||
|
expect(res.data.receivedBox).to.be.a('array');
|
||||||
|
res.data.receivedBox.forEach(box => {
|
||||||
|
expect(box).to.be.a('number');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
expect(res.code).to.equal(20804)
|
||||||
|
}
|
||||||
|
cb()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkRank(rank) {
|
function checkRank(rank) {
|
||||||
expect(rank.rank).to.be.a('number');
|
expect(rank.rank).to.be.a('number');
|
||||||
expect(rank.roleId).to.be.a('string');
|
expect(rank.roleId).to.be.a('string');
|
||||||
expect(rank.roleName).to.be.a('string');
|
expect(rank.roleName).to.be.a('string');
|
||||||
expect(rank.head).to.be.a('number');
|
expect(rank.head).to.be.a('number');
|
||||||
expect(rank.frame).to.be.a('number');
|
expect(rank.frame).to.be.a('number');
|
||||||
expect(rank.spine).to.be.a('number');
|
expect(rank.spine).to.be.a('number');
|
||||||
expect(rank.num).to.be.a('number');
|
expect(rank.num).to.be.a('number');
|
||||||
expect(rank.title).to.be.a('number');
|
expect(rank.title).to.be.a('number');
|
||||||
expect(rank.lv).to.be.a('number');
|
expect(rank.lv).to.be.a('number');
|
||||||
|
expect(rank.ce).to.be.a('number');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getData(pinusClient, seasonEnd: boolean, cb) {
|
function getData(pinusClient, seasonEnd: boolean, cb) {
|
||||||
|
|
||||||
pinusClient.request('battle.pvpHandler.getData', {}, (res) => {
|
pinusClient.request('battle.pvpHandler.getData', {}, (res) => {
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
expect(res.data.warId).to.be.a('number');
|
expect(res.data.seasonNum).to.be.a('number');
|
||||||
expect(res.data.seasonNum).to.be.a('number');
|
expect(res.data.seasonEndTime).to.be.a('number');
|
||||||
expect(res.data.seasonEndTime).to.be.a('number');
|
expect(res.data.myRank).to.be.a('number');
|
||||||
expect(res.data.myRank).to.be.a('number');
|
|
||||||
checkOppPlayers(res.data.oppPlayers);
|
checkOppPlayers(res.data.oppPlayers);
|
||||||
expect(res.data.heroes).to.be.a('array');
|
checkDefense(res.data.defense);
|
||||||
res.data.heroes.forEach(hero => {
|
checkAttack(res.data.attack);
|
||||||
expect(hero.actorId).to.be.a('number');
|
|
||||||
expect(hero.dataId).to.be.a('number');
|
expect(res.data.score).to.be.a('number');
|
||||||
expect(hero.order).to.be.a('number');
|
expect(res.data.winStreakNum).to.be.a('number');
|
||||||
});
|
|
||||||
expect(res.data.score).to.be.a('number');
|
expect(res.data.refOppCnt).to.be.a('number');
|
||||||
expect(res.data.pLv).to.be.a('number');
|
expect(res.data.setAttackCnt).to.be.a('number');
|
||||||
expect(res.data.winStreakNum).to.be.a('number');
|
expect(res.data.buyAttackCnt).to.be.a('number');
|
||||||
expect(res.data.challengeCnt).to.be.a('number');
|
expect(res.data.challengeCnt).to.be.a('number');
|
||||||
expect(res.data.challengeRefTime).to.be.a('number');
|
checkTimeStamp(res.data.challengeRefTime, 10, true);
|
||||||
expect(res.data.receivedBox).to.be.a('array');
|
|
||||||
res.data.receivedBox.forEach(box => {
|
expect(res.data.receivedBox).to.be.a('array');
|
||||||
expect(box).to.be.a('number');
|
res.data.receivedBox.forEach(box => {
|
||||||
});
|
expect(box).to.be.a('number');
|
||||||
expect(res.data.hisScore).to.be.a('number');
|
});
|
||||||
expect(res.data.heroScores).to.be.a('array');
|
expect(res.data.hisScore).to.be.a('number');
|
||||||
res.data.heroScores.forEach(heroScore => {
|
expect(res.data.heroScores).to.be.a('array');
|
||||||
expect(heroScore.hid).to.be.a('number');
|
res.data.heroScores.forEach(heroScore => {
|
||||||
expect(heroScore.score).to.be.a('number');
|
expect(heroScore.isDefense).to.be.a('boolean');
|
||||||
});
|
expect(heroScore.hid).to.be.a('number');
|
||||||
expect(res.data.isFirstEntry).to.be.a('boolean');
|
expect(heroScore.score).to.be.a('number');
|
||||||
expect(res.data.isDefaultHero).to.be.a('boolean');
|
});
|
||||||
expect(res.data.refOppCnt).to.be.a('number');
|
expect(res.data.isFirstEntry).to.be.a('boolean');
|
||||||
if(seasonEnd) {
|
if (seasonEnd) {
|
||||||
checkSeasonResult(res.data.seasonResult);
|
checkSeasonResult(res.data.seasonResult);
|
||||||
}
|
}
|
||||||
cb(res.data);
|
cb(res.data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkOppPlayers(oppPlayers) {
|
function checkOppPlayers(oppPlayers) {
|
||||||
expect(oppPlayers).to.be.a('array');
|
expect(oppPlayers).to.be.a('array');
|
||||||
oppPlayers.forEach(player => {
|
oppPlayers.forEach(player => {
|
||||||
expect(player.pos).to.be.a('number');
|
expect(player.pos).to.be.a('number');
|
||||||
expect(player.defCe).to.be.a('number');
|
expect(player.roleId).to.be.a('string');
|
||||||
expect(player.frame).to.be.a('number');
|
expect(player.roleName).to.be.a('string');
|
||||||
expect(player.head).to.be.a('number');
|
expect(player.head).to.be.a('number');
|
||||||
expect(player.lv).to.be.a('number');
|
expect(player.frame).to.be.a('number');
|
||||||
expect(player.oppRoleId).to.be.a('string');
|
expect(player.spine).to.be.a('number');
|
||||||
expect(player.pLv).to.be.a('number');
|
expect(player.lv).to.be.a('number');
|
||||||
expect(player.rankLv).to.be.a('number');
|
expect(player.pLv).to.be.a('number');
|
||||||
expect(player.roleName).to.be.a('string');
|
expect(player.defCe).to.be.a('number');
|
||||||
expect(player.spine).to.be.a('number');
|
expect(player.addScore).to.be.a('number');
|
||||||
expect(player.title).to.be.a('number');
|
expect(player.plusScore).to.be.a('number');
|
||||||
expect(player.roleId).to.be.a('string');
|
expect(player.rankLv).to.be.a('number');
|
||||||
expect(player.addScore).to.be.a('number');
|
});
|
||||||
expect(player.plusScore).to.be.a('number');
|
}
|
||||||
|
|
||||||
|
function checkDefense(defense) {
|
||||||
|
if (!!defense) {
|
||||||
|
expect(defense).to.be.an('object');
|
||||||
|
expect(defense.warId).to.be.a('number');
|
||||||
|
expect(defense.buff).to.be.a('number');
|
||||||
|
expect(defense.heroes).to.be.an('array');
|
||||||
|
defense.heroes.forEach(hero => {
|
||||||
|
expect(hero.actorId).to.be.a('number');
|
||||||
|
expect(hero.ai).to.be.a('number');
|
||||||
|
expect(hero.dataId).to.be.a('number');
|
||||||
|
expect(hero.order).to.be.a('number');
|
||||||
});
|
});
|
||||||
|
expect(defense.score).to.be.a('number');
|
||||||
|
expect(defense.pLv).to.be.a('number');
|
||||||
|
expect(defense.ce).to.be.a('number');
|
||||||
|
if (defense.heroes.length > 0) {
|
||||||
|
expect(defense.ce).not.equal(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkAttack(attack) {
|
||||||
|
if (!!attack) {
|
||||||
|
expect(attack).to.be.an('object');
|
||||||
|
expect(attack.heroes).to.be.an('array');
|
||||||
|
attack.heroes.forEach(hero => {
|
||||||
|
expect(hero.actorId).to.be.a('number');
|
||||||
|
if (!!hero.order) {
|
||||||
|
expect(hero.order).to.be.a('number');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(attack.score).to.be.a('number');
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSeasonResult(resultRecord) {
|
function checkSeasonResult(resultRecord) {
|
||||||
expect(resultRecord).to.be.a('object');
|
expect(resultRecord).to.be.a('object');
|
||||||
|
checkOldSeasonData(resultRecord.oldSeasonData);
|
||||||
|
expect(resultRecord.heroGoods).to.be.an('array');
|
||||||
|
resultRecord.heroGoods.forEach(obj => {
|
||||||
|
expect(obj.hid).to.be.a('number');
|
||||||
|
expect(obj.id).to.be.a('number');
|
||||||
|
expect(obj.count).to.be.a('number');
|
||||||
|
})
|
||||||
|
expect(resultRecord.rankGoods).to.be.an('array');
|
||||||
|
resultRecord.rankGoods.forEach(obj => {
|
||||||
|
expect(obj.id).to.be.a('number');
|
||||||
|
expect(obj.count).to.be.a('number');
|
||||||
|
})
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
function checkOldSeasonData(oldSeasonData) {
|
||||||
|
expect(oldSeasonData).to.be.an('object');
|
||||||
|
expect(oldSeasonData.score).to.be.a('number');
|
||||||
|
expect(oldSeasonData.heroScores).to.be.an('array');
|
||||||
|
oldSeasonData.heroScores.forEach(heroScore => {
|
||||||
|
expect(heroScore.hid).to.be.a('number');
|
||||||
|
expect(heroScore.score).to.be.a('number');
|
||||||
|
});
|
||||||
|
expect(oldSeasonData.seasonNum).to.be.a('number');
|
||||||
|
checkTimeStamp(oldSeasonData.seasonEndTime, 10, true);
|
||||||
|
expect(oldSeasonData.rankLv).to.be.a('number');
|
||||||
|
}
|
||||||
@@ -236,7 +236,7 @@ export class PvpDataReturn {
|
|||||||
buyAttackCnt: number;
|
buyAttackCnt: number;
|
||||||
challengeCnt: number;
|
challengeCnt: number;
|
||||||
challengeRefTime: number;
|
challengeRefTime: number;
|
||||||
receiveBox: number[] = [];
|
receivedBox: number[] = [];
|
||||||
hisScore: number = 0;
|
hisScore: number = 0;
|
||||||
heroScores: HeroScoreReturn[] = [];
|
heroScores: HeroScoreReturn[] = [];
|
||||||
isFirstEntry: boolean = false;
|
isFirstEntry: boolean = false;
|
||||||
@@ -245,7 +245,7 @@ export class PvpDataReturn {
|
|||||||
setPvpDefense(pvpDefense: PvpDefenseType) {
|
setPvpDefense(pvpDefense: PvpDefenseType) {
|
||||||
this.score = pvpDefense.score;
|
this.score = pvpDefense.score;
|
||||||
this.winStreakNum = pvpDefense.winStreakNum;
|
this.winStreakNum = pvpDefense.winStreakNum;
|
||||||
this.receiveBox = pvpDefense.receivedBox;
|
this.receivedBox = pvpDefense.receivedBox;
|
||||||
this.hisScore = pvpDefense.hisScore;
|
this.hisScore = pvpDefense.hisScore;
|
||||||
|
|
||||||
this.refOppCnt = pvpDefense.refOppCnt;
|
this.refOppCnt = pvpDefense.refOppCnt;
|
||||||
|
|||||||
Reference in New Issue
Block a user