mirror of
https://github.com/jie65535/mirai-console-jhr-plugin.git
synced 2025-06-02 17:39:16 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/kotlin/game/PlayerStatistics.kt
This commit is contained in:
commit
549e0b669e
@ -9,6 +9,7 @@ import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
|
|||||||
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
|
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
|
||||||
import net.mamoe.mirai.contact.Group
|
import net.mamoe.mirai.contact.Group
|
||||||
import net.mamoe.mirai.contact.isOperator
|
import net.mamoe.mirai.contact.isOperator
|
||||||
|
import net.mamoe.mirai.contact.nameCardOrNick
|
||||||
import net.mamoe.mirai.event.GlobalEventChannel
|
import net.mamoe.mirai.event.GlobalEventChannel
|
||||||
import net.mamoe.mirai.event.events.GroupMessageEvent
|
import net.mamoe.mirai.event.events.GroupMessageEvent
|
||||||
import net.mamoe.mirai.event.events.MessageEvent
|
import net.mamoe.mirai.event.events.MessageEvent
|
||||||
@ -19,6 +20,7 @@ import net.mamoe.mirai.utils.info
|
|||||||
import top.jie65535.jhr.game.Bet
|
import top.jie65535.jhr.game.Bet
|
||||||
import top.jie65535.jhr.game.Horse
|
import top.jie65535.jhr.game.Horse
|
||||||
import top.jie65535.jhr.game.PlayerStatistics
|
import top.jie65535.jhr.game.PlayerStatistics
|
||||||
|
import java.lang.Integer.min
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ object JHorseRacing : KotlinPlugin(
|
|||||||
for (j in horse.position until lapLength)
|
for (j in horse.position until lapLength)
|
||||||
sb.append("Ξ")
|
sb.append("Ξ")
|
||||||
sb.append(horseTypes[horse.type])
|
sb.append(horseTypes[horse.type])
|
||||||
for (j in 1 until horse.position)
|
for (j in 0 until min(lapLength, horse.position))
|
||||||
sb.append("Ξ")
|
sb.append("Ξ")
|
||||||
sb.appendLine()
|
sb.appendLine()
|
||||||
}
|
}
|
||||||
@ -132,7 +134,13 @@ object JHorseRacing : KotlinPlugin(
|
|||||||
launch(rank.job) {
|
launch(rank.job) {
|
||||||
val winners = mutableListOf<Int>()
|
val winners = mutableListOf<Int>()
|
||||||
while (winners.size == 0) {
|
while (winners.size == 0) {
|
||||||
delay(Random.nextLong(1000) + 2000)
|
delay(Random.nextLong(5000, 7000))
|
||||||
|
|
||||||
|
// 所有马前进
|
||||||
|
for (horse in rank.horses) {
|
||||||
|
++horse.position
|
||||||
|
}
|
||||||
|
|
||||||
// 比赛事件触发
|
// 比赛事件触发
|
||||||
val steps = (1..3).random() //事件触发前进或后退随机大小
|
val steps = (1..3).random() //事件触发前进或后退随机大小
|
||||||
val eventHorseIndex = Random.nextInt(rank.horses.size)
|
val eventHorseIndex = Random.nextInt(rank.horses.size)
|
||||||
@ -144,19 +152,21 @@ object JHorseRacing : KotlinPlugin(
|
|||||||
eventHorse.position -= steps
|
eventHorse.position -= steps
|
||||||
JHRPluginConfig.badEvents[Random.nextInt(JHRPluginConfig.badEvents.size)]
|
JHRPluginConfig.badEvents[Random.nextInt(JHRPluginConfig.badEvents.size)]
|
||||||
}
|
}
|
||||||
val number = (eventHorseIndex + 1).toString()
|
|
||||||
subject.sendMessage(eventMsg.replace("?", number))
|
|
||||||
|
|
||||||
// 所有马前进
|
|
||||||
|
// 计算获胜者
|
||||||
for ((i, horse) in rank.horses.withIndex()) {
|
for ((i, horse) in rank.horses.withIndex()) {
|
||||||
if (++horse.position >= lapLength) {
|
if (horse.position >= lapLength) {
|
||||||
winners.add(i + 1)
|
winners.add(i + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
subject.sendMessage(drawHorse(rank.horses))
|
|
||||||
|
|
||||||
delay(Random.nextLong(1000) + 3000)
|
val number = (eventHorseIndex + 1).toString()
|
||||||
|
subject.sendMessage(eventMsg.replace("?", number))
|
||||||
|
delay(Random.nextLong(100, 200))
|
||||||
|
subject.sendMessage(drawHorse(rank.horses))
|
||||||
}
|
}
|
||||||
|
delay(Random.nextLong(100, 200))
|
||||||
val mb = MessageChainBuilder()
|
val mb = MessageChainBuilder()
|
||||||
for (winner in winners) {
|
for (winner in winners) {
|
||||||
// 增加该赛马胜场
|
// 增加该赛马胜场
|
||||||
@ -171,8 +181,10 @@ object JHorseRacing : KotlinPlugin(
|
|||||||
if (pool != null && pool.size > 0) {
|
if (pool != null && pool.size > 0) {
|
||||||
for (bet in pool) {
|
for (bet in pool) {
|
||||||
val score = JHRPluginData.Scores[bet.id]!!
|
val score = JHRPluginData.Scores[bet.id]!!
|
||||||
|
val stat = getPlayerStat(bet.id)
|
||||||
|
stat.totalBetScore += bet.score
|
||||||
val income = if (winners.indexOf(bet.number) != -1) {
|
val income = if (winners.indexOf(bet.number) != -1) {
|
||||||
getPlayerStat(bet.id).winCount += 1
|
stat.winCount += 1
|
||||||
(bet.score * 1.5).toInt()
|
(bet.score * 1.5).toInt()
|
||||||
} else {
|
} else {
|
||||||
-bet.score
|
-bet.score
|
||||||
@ -435,9 +447,12 @@ object JHorseRacing : KotlinPlugin(
|
|||||||
}
|
}
|
||||||
msg == "排名" || msg == "积分榜" -> {
|
msg == "排名" || msg == "积分榜" -> {
|
||||||
val msgB = MessageChainBuilder(11)
|
val msgB = MessageChainBuilder(11)
|
||||||
msgB.append("积分榜")
|
msgB.append("积分榜\n")
|
||||||
JHRPluginData.Scores.entries.sortedBy { it.value }.take(10).onEach {
|
JHRPluginData.Scores.entries.filter { subject.contains(it.key) }
|
||||||
msgB.append(At(it.key)).append(" ${it.value}")
|
.sortedByDescending { it.value }
|
||||||
|
.take(10)
|
||||||
|
.onEach {
|
||||||
|
msgB.append("| ${it.value} | ${subject[it.key]!!.nameCardOrNick}\n")
|
||||||
}
|
}
|
||||||
subject.sendMessage(msgB.asMessageChain())
|
subject.sendMessage(msgB.asMessageChain())
|
||||||
}
|
}
|
||||||
@ -445,11 +460,8 @@ object JHorseRacing : KotlinPlugin(
|
|||||||
val stat = getPlayerStat(sender.id)
|
val stat = getPlayerStat(sender.id)
|
||||||
val ret = MessageChainBuilder()
|
val ret = MessageChainBuilder()
|
||||||
ret.append(message.quote())
|
ret.append(message.quote())
|
||||||
.append("下注次数:${stat.betCount}\n")
|
.append(getPlayerStat(sender.id).toString())
|
||||||
.append("获胜次数:${stat.winCount}\n")
|
.append("\nヾ(◍°∇°◍)ノ゙继续加油吧!")
|
||||||
.append("贡献次数:${stat.contribution}\n")
|
|
||||||
.append("签到次数:${stat.signCount}\n")
|
|
||||||
.append("ヾ(◍°∇°◍)ノ゙继续加油吧!")
|
|
||||||
subject.sendMessage(ret.asMessageChain())
|
subject.sendMessage(ret.asMessageChain())
|
||||||
}
|
}
|
||||||
msg == "胜率" -> {
|
msg == "胜率" -> {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package top.jie65535.jhr.game
|
package top.jie65535.jhr.game
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家数据统计
|
* 玩家数据统计
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
class PlayerStatistics {
|
class PlayerStatistics {
|
||||||
/**
|
/**
|
||||||
* 下注次数
|
* 下注次数
|
||||||
@ -23,4 +25,17 @@ class PlayerStatistics {
|
|||||||
* 签到次数
|
* 签到次数
|
||||||
*/
|
*/
|
||||||
var signCount = 0
|
var signCount = 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下注积分累计
|
||||||
|
*/
|
||||||
|
var totalBetScore = 0
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "下注次数:${betCount}\n" +
|
||||||
|
"获胜次数:${winCount}\n" +
|
||||||
|
"贡献次数:${contribution}\n" +
|
||||||
|
"签到次数:${signCount}\n" +
|
||||||
|
"下注积分:${totalBetScore}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user