From 462fb4d3ba4b26051c74da2963f11246e7a5e0ef Mon Sep 17 00:00:00 2001 From: jie65535 Date: Mon, 17 Jan 2022 13:51:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E8=8E=B7=E8=83=9C?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E9=A1=BA=E5=BA=8F=E9=94=99=E8=AF=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/JHorseRacing.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/JHorseRacing.kt b/src/main/kotlin/JHorseRacing.kt index 355508c..99650bb 100644 --- a/src/main/kotlin/JHorseRacing.kt +++ b/src/main/kotlin/JHorseRacing.kt @@ -136,10 +136,8 @@ object JHorseRacing : KotlinPlugin( delay(Random.nextLong(5000, 7000)) // 所有马前进 - for ((i, horse) in rank.horses.withIndex()) { - if (++horse.position >= lapLength) { - winners.add(i + 1) - } + for (horse in rank.horses) { + ++horse.position } // 比赛事件触发 @@ -154,6 +152,14 @@ object JHorseRacing : KotlinPlugin( JHRPluginConfig.badEvents[Random.nextInt(JHRPluginConfig.badEvents.size)] } + + // 计算获胜者 + for ((i, horse) in rank.horses.withIndex()) { + if (horse.position >= lapLength) { + winners.add(i + 1) + } + } + val number = (eventHorseIndex + 1).toString() subject.sendMessage(eventMsg.replace("?", number)) delay(Random.nextLong(100, 200))