diff --git a/game-server/app/servers/battle/handler/auctionHandler.ts b/game-server/app/servers/battle/handler/auctionHandler.ts index 95e84b0a5..15c3851a9 100644 --- a/game-server/app/servers/battle/handler/auctionHandler.ts +++ b/game-server/app/servers/battle/handler/auctionHandler.ts @@ -53,11 +53,11 @@ export class AuctionHandler { const serverId: number = session.get('serverId'); if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND) - const result = await genAuction(guildCode, sourceType, sourceCode, serverId, rewards); - if (!result) { + const lots = await genAuction(guildCode, sourceType, sourceCode, serverId, rewards); + if (!lots) { return resResult(STATUS.WRONG_PARMS); } - return resResult(STATUS.SUCCESS, { result }); + return resResult(STATUS.SUCCESS, { lots }); } } diff --git a/game-server/app/services/auctionService.ts b/game-server/app/services/auctionService.ts index 25ffd707a..8faba9742 100644 --- a/game-server/app/services/auctionService.ts +++ b/game-server/app/services/auctionService.ts @@ -1,8 +1,21 @@ -import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_SOURCE, AUCTION_TIME } from './../consts'; +import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME } from './../consts'; import { ItemReward } from "../domain/dbGeneral"; import { genCode } from '../pubUtils/util'; import { LotModel, LotParam } from '../db/Lot'; import { getNextTime } from '../pubUtils/timeUtil'; +import { getGoodById } from '../pubUtils/data'; + +// ! 获取底价,假数据 +function getBasePrice(gid: number, count: number) { + const good = getGoodById(gid); + return (good ? good.quality * 100 : 100) * count; +} + +// ! 获取一口价,假数据 +function getMaxPrice(gid: number, count: number) { + const good = getGoodById(gid); + return (good ? good.quality * 200 : 200) * count; +} /** * @description 生成拍卖数据 @@ -22,7 +35,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo return { auctionStage: AUCTION_STAGE.DEFAULT, sourceType, sourceCode, serverId, guildCode, code, gid: id, count, begin, end, - maxPrice: 100, curPrice: 10, // ! 此行为临时数据 + maxPrice: getMaxPrice(id, count), curPrice: getBasePrice(id, count), } }); const result = await LotModel.createRecs(lots); @@ -30,6 +43,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo } /** + * ! 目前返回假数据 * @description 获取活动参加者 * @export * @param {string} guildCode @@ -37,5 +51,11 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo * @param {string} sourceCode */ export async function participants(guildCode: string, sourceType: number, sourceCode: string) { - + return [{ + roleId: 'rM8NZtlfzD', + position: 1, + }, { + roleId: 'EjX79SEddK', + position: 2, + }]; } diff --git a/game-server/test/auction.test.ts b/game-server/test/auction.test.ts index 1f02d0426..e0784987c 100644 --- a/game-server/test/auction.test.ts +++ b/game-server/test/auction.test.ts @@ -1,10 +1,25 @@ -import { AUCTION_SOURCE } from './../app/consts/constModules/auctionConst'; -import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_PRIVATE_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS, HERO_GROW_MAX, ABI_STAGE } from './../app/consts'; import { Client } from './Client'; import 'mocha'; import { PinusWSClient } from 'pinus-robot-plugin'; import { expect } from 'chai'; import { checkSuccessResponse } from './CheckPatten'; +import { DEBUG_MAGIC_WORD, AUCTION_SOURCE } from '../app/consts'; + +function checkLot(lot) { + expect(lot.auctionStage).to.be.a('number'); + expect(lot.sourceType).to.be.a('number'); + expect(lot.sourceCode).to.be.a('string'); + expect(lot.serverId).to.be.a('number'); + expect(lot.guildCode).to.be.a('string'); + expect(lot.code).to.be.a('string'); + expect(lot.gid).to.be.a('number'); + expect(lot.count).to.be.a('number'); + expect(lot.maxPrice).to.be.a('number'); + expect(lot.curPrice).to.be.a('number'); + expect(lot.bidRoles).to.be.a('array'); + expect(Date.parse(lot.begin)).to.be.a('number'); + expect(Date.parse(lot.end)).to.be.a('number'); +} describe('拍卖行测试', function() { let pinusClient: PinusWSClient; @@ -40,6 +55,10 @@ describe('拍卖行测试', function() { const sourceCode = Math.random().toString(36).slice(-8); pinusClient.request('battle.auctionHandler.debugAddLots', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE, sourceCode, rewards: [{ id: 1, count: 1 }, { id: 2, count: 2 }] }, (res) => { checkSuccessResponse(res); + expect(res.data.lots).to.be.an('array'); + for (let lot of res.data.lots) { + checkLot(lot); + } done(); }); }); diff --git a/game-server/test/timeUtils.test.ts b/game-server/test/timeUtils.test.ts index 28953e28f..dacf5783d 100644 --- a/game-server/test/timeUtils.test.ts +++ b/game-server/test/timeUtils.test.ts @@ -10,7 +10,7 @@ function checkTime(date: Date, h: number, m: number, s: number) { expect(date.getSeconds()).to.be.equal(s); } -describe('测试时间相关工具方法', function () { +describe('测试时间工具方法', function () { it('获取某个时间后的某点,返回当天', function () { const baseDate = new Date(); const newHour = 9, newMin = 9, newSec = 9;