From e0095de5b10c8c088acb67db77ab25e88f79ccd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E5=82=91?= <840465812@qq.com> Date: Tue, 11 Jan 2022 21:43:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=9B=AE=E5=BD=95=E7=BB=93?= =?UTF-8?q?=E6=9E=84=20=E5=A2=9E=E5=8A=A0=20=E7=BB=93=E6=9D=9F=E8=B5=9B?= =?UTF-8?q?=E9=A9=AC=20=E5=9C=A8=E8=BF=9B=E8=A1=8C=E8=BF=87=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E5=8F=AF=E4=BB=A5=E7=BB=93=E6=9D=9F=E8=B5=9B=E9=A9=AC?= =?UTF-8?q?=EF=BC=88=E9=9C=80=E8=A6=81=E7=AE=A1=E7=90=86=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=EF=BC=89=20=E8=B0=83=E6=95=B4=20=E5=8D=A0=E4=BD=8D=E7=AC=A6?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=94=AF=E6=8C=81=E4=B8=AD=E6=96=87=E9=97=AE?= =?UTF-8?q?=E5=8F=B7=EF=BC=88=E5=9B=A0=E4=B8=BA=E4=BA=8B=E4=BB=B6=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=86=85=E5=8C=85=E5=90=AB=E4=B8=AD=E6=96=87=E9=97=AE?= =?UTF-8?q?=E5=8F=B7=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 39 ++++++++++++++++++++++++++++++++- src/main/kotlin/JHorseRacing.kt | 27 ++++++++++++++++------- src/main/kotlin/game/Bet.kt | 10 +++++++++ src/main/kotlin/game/Game.kt | 5 +++++ src/main/kotlin/game/Horse.kt | 16 ++++++++++++++ src/main/kotlin/game/Item.kt | 29 ++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/game/Bet.kt create mode 100644 src/main/kotlin/game/Game.kt create mode 100644 src/main/kotlin/game/Horse.kt create mode 100644 src/main/kotlin/game/Item.kt 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 832a3a0..15f4709 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) /** @@ -117,11 +117,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()) { @@ -199,7 +195,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