From aaeba429ad9ccbdc95ea1aae9512b689fcbc4117 Mon Sep 17 00:00:00 2001 From: zhl Date: Mon, 10 May 2021 11:27:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E7=9B=AE=E9=97=B4=E9=9A=94=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=A2=9E=E5=8A=A0=E7=89=B9=E6=95=88=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E6=97=B6=E9=97=B4,=20=E4=BF=AE=E6=94=B9=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E9=80=89=E5=8F=96=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/GameEnv.ts | 14 +++++++++++++- src/models/content/Puzzle.ts | 2 +- src/services/GameLogic.ts | 5 ++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/config/GameEnv.ts b/src/config/GameEnv.ts index 9de95e1..40bb3d5 100644 --- a/src/config/GameEnv.ts +++ b/src/config/GameEnv.ts @@ -12,10 +12,22 @@ export class GameEnv { // PVP答对基础分 public pvpBaseScore: number + // 特效播放时间 + public effectTimeLong: number + public init(data: Map) { - this.pvpInterval = (+data.get(99018).value) * 1000 + this.pvpInterval = (+data.get(99018).value) this.pvpComboRate = +data.get(99017).value this.pvpTimeRate = +data.get(99016).value this.pvpBaseScore = +data.get(99015).value + this.effectTimeLong = +data.get(99025).value + } + + /** + * pvp模式下每题之间的间隔 + * @return {number} + */ + public get pvpQuestionInterval() { + return (this.pvpInterval + this.effectTimeLong) * 1000 } } diff --git a/src/models/content/Puzzle.ts b/src/models/content/Puzzle.ts index 05cf055..35e4452 100644 --- a/src/models/content/Puzzle.ts +++ b/src/models/content/Puzzle.ts @@ -98,7 +98,7 @@ class PuzzleClass extends BaseModule { return this.findOne({deleted: 0, is_hide: 0, _id: {$gt: id }}).exec() } public static async randomQuestions(this: ReturnModelType, options: any, count: number) { - let filters = {status: 1, is_hide: 0, deleted: 0} + let filters = {status: 1, is_hide: 0, deleted: 0, dp: 1} Object.assign(options) return Puzzle.aggregate([ { $match: filters }, diff --git a/src/services/GameLogic.ts b/src/services/GameLogic.ts index 4f1205a..a7a956b 100644 --- a/src/services/GameLogic.ts +++ b/src/services/GameLogic.ts @@ -1,6 +1,5 @@ import { beginGame, - closeRoom, endGame, sendQuestion, updateRound, @@ -60,7 +59,7 @@ export function checkSubFinish(history: any, qid: string) { */ export async function startGame(roomId: string, sessionId: string) { let history = await PuzzleSession.findById(sessionId) - let records = await Puzzle.randomQuestions({}, history.total) + let records = await Puzzle.randomQuestions({status: 1, is_hide: 0, deleted: 0, dp: 1}, history.total) await beginGame(roomId, {}) history.questions = records.map(o => o._id) await history.save() @@ -89,7 +88,7 @@ export async function sendOneQuestion(history: any) { await sendQuestion(roomId, qdata) history.current++ await history.save() - new Schedule().beginSchedule(new GameEnv().pvpInterval, async function () { + new Schedule().beginSchedule(new GameEnv().pvpQuestionInterval, async function () { let subHistory = await PuzzleSession.findById(history.id) let datas = [] for (let [accountid, data] of subHistory.members) {