From 48a79c8629655ed26d8d2526592f70421ae6d813 Mon Sep 17 00:00:00 2001 From: jie65535 Date: Thu, 17 Mar 2022 21:31:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E4=B8=8B=E6=B3=A8=20#1=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=20=E8=B5=94=E7=8E=87=E5=85=81=E8=AE=B8=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=B5=94=E7=8E=87=E8=AE=A1=E7=AE=97=E5=85=AC=E5=BC=8F=EF=BC=9A?= =?UTF-8?q?=20=E7=8E=B0=E5=9C=A8=E8=8E=B7=E8=83=9C=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=8B=A5=E4=B8=8B=E6=B3=A8=E9=87=91=E9=A2=9D=E7=AD=89=E4=BA=8E?= =?UTF-8?q?=E4=BD=99=E9=A2=9D=EF=BC=8C=E5=88=99=E8=8E=B7=E5=BE=97=E6=A2=AD?= =?UTF-8?q?=E5=93=88=E8=B5=94=E7=8E=87(=E9=BB=98=E8=AE=A45)=20=E5=90=A6?= =?UTF-8?q?=E5=88=99=E8=B5=94=E7=8E=87=E4=B8=BA=E4=B8=8B=E6=B3=A8=E9=87=91?= =?UTF-8?q?=E9=A2=9D/=E4=BD=99=E9=A2=9D=E7=9A=84=E6=AF=94=E4=BE=8B?= =?UTF-8?q?=E4=B9=98=E6=9C=80=E5=A4=A7=E8=B5=94=E7=8E=87(=E9=BB=98?= =?UTF-8?q?=E8=AE=A44)=EF=BC=8C=E5=AD=98=E5=9C=A8=E4=BF=9D=E5=BA=95?= =?UTF-8?q?=E8=B5=94=E7=8E=87(=E9=BB=98=E8=AE=A40.5)=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=8B=E6=B3=A8=E6=8C=87=E4=BB=A4=EF=BC=8C=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=94=AF=E6=8C=81`=E6=A2=AD=E5=93=88`?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E6=98=AF=E6=89=A9=E5=B1=95`=E9=A9=ACn=20cmd`?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=EF=BC=8C`cmd`=E4=B8=BA`=E6=A2=AD=E5=93=88|al?= =?UTF-8?q?lin`=E8=A1=A8=E7=A4=BA=E5=85=A8=E5=8E=8B=EF=BC=8C`cmd`=E4=B8=BA?= =?UTF-8?q?`=E9=9A=8F=E6=9C=BA|random|rand`=E8=A1=A8=E7=A4=BA=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA=E4=B8=8B=E6=B3=A8=EF=BC=8C=E5=90=A6=E5=88=99=E4=BB=85?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E4=B8=BA=E6=95=B0=E5=AD=97=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E4=B8=8B=E6=B3=A8=E7=A7=AF=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/JHRPluginConfig.kt | 9 +++++ src/main/kotlin/JHorseRacing.kt | 63 +++++++++++++++++------------- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/JHRPluginConfig.kt b/src/main/kotlin/JHRPluginConfig.kt index 9e4aa2d..d7f8d44 100644 --- a/src/main/kotlin/JHRPluginConfig.kt +++ b/src/main/kotlin/JHRPluginConfig.kt @@ -86,6 +86,15 @@ object JHRPluginConfig : AutoSavePluginConfig("HorseRacingPluginConfig") { */ @ValueDescription("自动开始时间(s)") var autoStartTime by value(180) + + @ValueDescription("保底赔率") + var minOdds by value(0.5) + + @ValueDescription("最大赔率") + var maxOdds by value(4.0) + + @ValueDescription("梭哈赔率") + var allinOdds by value(5.0) } // @ValueDescription("赛马数量") // val horseCount by value(5) \ No newline at end of file diff --git a/src/main/kotlin/JHorseRacing.kt b/src/main/kotlin/JHorseRacing.kt index b06d3f6..70ce4ec 100644 --- a/src/main/kotlin/JHorseRacing.kt +++ b/src/main/kotlin/JHorseRacing.kt @@ -20,8 +20,8 @@ import net.mamoe.mirai.utils.info import top.jie65535.jhr.game.Bet import top.jie65535.jhr.game.Horse import top.jie65535.jhr.game.PlayerStatistics -import java.lang.Integer.min import java.util.* +import kotlin.math.min import kotlin.random.Random @@ -194,8 +194,16 @@ object JHorseRacing : KotlinPlugin( val income = if (winners.indexOf(bet.number) != -1) { // 胜场计数累积 stat.winCount += 1 - // 收益积分 若梭哈,则奖励翻倍 - (bet.score * (if (bet.score == score) 3 else 1.5)).toInt() + // 收益积分 + (bet.score * if (bet.score == score) + JHRPluginConfig.allinOdds // 若allin,则使用allin赔率 + else + // 否则根据下注金额与余额的比值计算赔率 + min( + JHRPluginConfig.minOdds, + bet.score.toDouble() / score * JHRPluginConfig.maxOdds + ) + ).toInt() } else { // 亏损积分 -bet.score @@ -321,38 +329,39 @@ object JHorseRacing : KotlinPlugin( return@subscribeAlways } val no = p[0].toIntOrNull() - val coin = p[1].toIntOrNull() - if (no == null || no < 1 || no > horseCount) { - subject.sendMessage("没有这个编号的选手") - return@subscribeAlways - } - if (coin == null || coin <= 0) { - subject.sendMessage("胡乱下分不可取") - return@subscribeAlways - } - val score = JHRPluginData.Scores[sender.id] - if (score == null || score - coin < 0) { - subject.sendMessage("没那么多可以下注的分惹") - return@subscribeAlways - } - - // 结算时再计数 - // getPlayerStat(sender.id).betCount += 1 - pool.add(Bet(sender.id, no, coin)) - subject.sendMessage(JHRPluginConfig.betMessage[Random.nextInt(JHRPluginConfig.betMessage.size)].replace("?", no.toString())) - } - msg.startsWith("梭哈") -> { - val no = msg.removePrefix("梭哈").trim().toIntOrNull() if (no == null || no < 1 || no > horseCount) { subject.sendMessage("没有这个编号的选手") return@subscribeAlways } val score = JHRPluginData.Scores[sender.id] if (score == null || score <= 0) { - subject.sendMessage("没分还来捣什么乱,快走开") + subject.sendMessage("你还没有积分哦,请通过签到获取积分再来") return@subscribeAlways } - pool.add(Bet(sender.id, no, score)) + // 根据第二个参数确认动作 + val cmd = p[1] + val coin: Int? + // '梭哈'表示全压 + if (cmd == "梭哈" || cmd == "allin") { + coin = score + } else if (cmd == "随机" || cmd == "random" || cmd == "rand") { + // '随机'则是系统随机选择下注积分 + coin = Random.nextInt(score) + 1 + } else { + // 否则只允许输入数字作为下注积分 + coin = cmd.toIntOrNull() + if (coin == null || coin <= 0) { + subject.sendMessage("胡乱下分不可取") + return@subscribeAlways + } + } + + if (score - coin < 0) { + subject.sendMessage("没那么多可以下注的分惹") + return@subscribeAlways + } + + pool.add(Bet(sender.id, no, coin)) subject.sendMessage(JHRPluginConfig.betMessage[Random.nextInt(JHRPluginConfig.betMessage.size)].replace("?", no.toString())) } msg.startsWith("增加好事") -> {