diff --git a/README.md b/README.md index 6a70d4f..7207023 100644 --- a/README.md +++ b/README.md @@ -26,4 +26,41 @@ 等待比赛结束,结算奖励。 -发送`我有多少钱`或者其它查询余额命令来查询当前余额。(可私聊查询) \ No newline at end of file +发送`我有多少钱`或者其它查询余额命令来查询当前余额。(可私聊查询) + +### 道具池 +``` +巧克力 +作用:60%几率使马下一步多走1格 +价格:8$ + +兴奋剂 +作用:60%几率使马下一步多走3格,10%几率使马过于兴奋回到起点 +价格:10$ + +强效兴奋剂 +作用:60%几率使马下一步多走5格,30%几率使马过于兴奋回到起点 +价格:15$ + +冰淇淋 +作用:30%几率使马滑到,下一步走0格 +价格:10$ + +香蕉皮 +作用:50%几率使马滑到,下一步走0格 +价格:5$ + +肥皂 +作用:70%几率使马滑到,下一步走0格 +价格:7$ + +祈祷符 +作用:5%几率使马下一步多走10格 +价格:7$ + +使用指令:物品名称+马的序号 +例:巧克力1(为马1使用巧克力) +注:本商店物品无需买入,在赛马进行中,只要有足够的$,直接用指令发动即可自动使用 +注:如果物品名称后面不跟马的序号,视为对随机一匹马发动,购入价格减半 +注:物品效果可累计 +``` \ No newline at end of file diff --git a/src/main/kotlin/JHorseRacing.kt b/src/main/kotlin/JHorseRacing.kt index c081b8a..c4f3b19 100644 --- a/src/main/kotlin/JHorseRacing.kt +++ b/src/main/kotlin/JHorseRacing.kt @@ -17,6 +17,8 @@ import net.mamoe.mirai.message.data.MessageChainBuilder import net.mamoe.mirai.message.data.MessageSource.Key.quote import net.mamoe.mirai.message.data.PlainText import net.mamoe.mirai.utils.info +import top.jie65535.jhr.game.Bet +import top.jie65535.jhr.game.Horse import java.util.* import kotlin.random.Random @@ -55,8 +57,6 @@ object JHorseRacing : KotlinPlugin( // region 赛马 - private data class Bet(val id: Long, val number: Int, val score: Int) - private data class Horse(val type: Int, var position: Int = 0) private data class Rank(val horses: List, val job: Job) /** @@ -131,11 +131,7 @@ object JHorseRacing : KotlinPlugin( JHRPluginConfig.badEvents[Random.nextInt(JHRPluginConfig.badEvents.size)] } val number = (eventHorseIndex + 1).toString() - subject.sendMessage( - eventMsg - .replace("?", number) - .replace("?", number) - ) + subject.sendMessage(eventMsg.replace("?", number)) // 所有马前进 for ((i, horse) in rank.horses.withIndex()) { @@ -213,7 +209,22 @@ object JHorseRacing : KotlinPlugin( } } } - msg.startsWith("开始赛马") -> launch { startRank(subject) } + msg.startsWith("开始赛马") -> launch { + startRank(subject) + } + msg.startsWith("结束赛马") -> { + if (sender.permission.isOperator()) { + val rank = ranks[subject.id] + if (rank != null) { + rank.job.cancel() + ranks.remove(subject.id) + pools.remove(subject.id) + subject.sendMessage("已结束比赛") + } else { + subject.sendMessage("没有正在进行中的赛马") + } + } + } msg == "关闭赛马" -> { if (sender.permission.isOperator()) { JHRPluginConfig.enabledGroups.remove(subject.id) diff --git a/src/main/kotlin/game/Bet.kt b/src/main/kotlin/game/Bet.kt new file mode 100644 index 0000000..f817036 --- /dev/null +++ b/src/main/kotlin/game/Bet.kt @@ -0,0 +1,10 @@ +package top.jie65535.jhr.game + +/** + * 赌注 + * + * @param id 下注用户 + * @param number 马号 + * @param score 下注点数 + */ +data class Bet(val id: Long, val number: Int, val score: Int) \ No newline at end of file diff --git a/src/main/kotlin/game/Game.kt b/src/main/kotlin/game/Game.kt new file mode 100644 index 0000000..205a1bd --- /dev/null +++ b/src/main/kotlin/game/Game.kt @@ -0,0 +1,5 @@ +package top.jie65535.jhr.game + +//class Game { +// // TODO +//} \ No newline at end of file diff --git a/src/main/kotlin/game/Horse.kt b/src/main/kotlin/game/Horse.kt new file mode 100644 index 0000000..db31d59 --- /dev/null +++ b/src/main/kotlin/game/Horse.kt @@ -0,0 +1,16 @@ +package top.jie65535.jhr.game + +/** + * 赛马 + * + * @param type 赛马类型(样式) + */ +data class Horse(val type: Int) { + /** + * 马的位置 设置为小于0的值时会重置为0 + */ + var position: Int = 0 + set(value) { + field = if (value < 0) 0 else value + } +} diff --git a/src/main/kotlin/game/Item.kt b/src/main/kotlin/game/Item.kt new file mode 100644 index 0000000..a8b6141 --- /dev/null +++ b/src/main/kotlin/game/Item.kt @@ -0,0 +1,29 @@ +package top.jie65535.jhr.game + +// TODO("游戏道具") +//class Item( +// val name: String, +// val price: Int, +// val description: String, +//) { +// fun handle(horse: Horse) { +// when (name) { +// "巧克力" -> { +// +// } +// +// } +// } +// +// companion object { +// val ITEMS = listOf( +// Item("巧克力", 100, "60%几率使马下一步多走1格"), +// Item("兴奋剂", 100, "60%几率使马下一步多走3格,10%几率使马过于兴奋回到起点"), +// Item("强效兴奋剂", 100, "60%几率使马下一步多走5格,30%几率使马过于兴奋回到起点"), +// Item("冰淇淋", 100, "30%几率使马滑到,下一步走0格"), +// Item("香蕉皮", 100, "50%几率使马滑到,下一步走0格"), +// Item("肥皂", 100, "70%几率使马滑到,下一步走0格"), +// Item("祈祷符", 100, "5%几率使马下一步多走10格"), +// ) +// } +//} \ No newline at end of file