mirror of
https://github.com/jie65535/mirai-console-jhr-plugin.git
synced 2025-06-02 17:39:16 +08:00
增加 随机积分下注 #1
增加 赔率允许配置文件修改 修改赔率计算公式: 现在获胜时,若下注金额等于余额,则获得梭哈赔率(默认5) 否则赔率为下注金额/余额的比例乘最大赔率(默认4),存在保底赔率(默认0.5) 修改下注指令,现在不再支持`梭哈`,而是扩展`马n cmd`命令,`cmd`为`梭哈|allin`表示全压,`cmd`为`随机|random|rand`表示随机下注,否则仅允许为数字表示下注积分
This commit is contained in:
parent
65a31c18a6
commit
48a79c8629
@ -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)
|
@ -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("增加好事") -> {
|
||||
|
Loading…
Reference in New Issue
Block a user