mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
commit
23dfa4f69d
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,5 +1,16 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 0.29.4
|
||||
|
||||
* `Core`:
|
||||
* `diceResultLimit` now is deprecated, use `commonDiceResultLimit` instead
|
||||
* New extension `slotMachineDiceResultLimit`
|
||||
* `Utils`:
|
||||
* New enum `SlotMachineReelImages`
|
||||
* New extension `Int#asSlotMachineReelImage`
|
||||
* New data class `SlotMachineResult`
|
||||
* New extension `Dice#calculateSlotMachineResult`
|
||||
|
||||
## 0.29.3
|
||||
|
||||
* `Common`:
|
||||
|
@ -15,7 +15,7 @@ ktor_version=1.4.1
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=0.29.3
|
||||
library_version=0.29.4
|
||||
|
||||
gradle_bintray_plugin_version=1.8.5
|
||||
github_release_plugin_version=2.2.12
|
||||
|
@ -52,7 +52,11 @@ val inlineQueryAnswerResultsLimit = 0 .. 50
|
||||
|
||||
val customTitleLength = 0 .. 16
|
||||
|
||||
val diceResultLimit = 1 .. 6
|
||||
val commonDiceResultLimit = 1 .. 6
|
||||
@Deprecated("Renamed", ReplaceWith("commonDiceResultLimit", "dev.inmo.tgbotapi.types.commonDiceResultLimit"))
|
||||
val diceResultLimit
|
||||
get() = commonDiceResultLimit
|
||||
val slotMachineDiceResultLimit = 1 .. 64
|
||||
|
||||
val botCommandLengthLimit = 1 .. 32
|
||||
val botCommandLimit = botCommandLengthLimit
|
||||
|
@ -0,0 +1,43 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils
|
||||
|
||||
import dev.inmo.tgbotapi.types.DiceResult
|
||||
import dev.inmo.tgbotapi.types.dice.Dice
|
||||
import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
|
||||
enum class SlotMachineReelImages {
|
||||
BAR, BERRIES, LEMON, SEVEN
|
||||
}
|
||||
val Int.asSlotMachineReelImage
|
||||
get() = when (this) {
|
||||
0 -> SlotMachineReelImages.BAR
|
||||
1 -> SlotMachineReelImages.BERRIES
|
||||
2 -> SlotMachineReelImages.LEMON
|
||||
else -> SlotMachineReelImages.SEVEN
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class SlotMachineResult(
|
||||
val rawValue: DiceResult
|
||||
) {
|
||||
@Transient
|
||||
val left = rawValue and 3
|
||||
@Transient
|
||||
val center = rawValue shr 2 and 3
|
||||
@Transient
|
||||
val right = rawValue shr 4
|
||||
|
||||
@Transient
|
||||
val leftReel = left.asSlotMachineReelImage
|
||||
@Transient
|
||||
val centerReel = center.asSlotMachineReelImage
|
||||
@Transient
|
||||
val rightReel = right.asSlotMachineReelImage
|
||||
}
|
||||
|
||||
fun Dice.calculateSlotMachineResult() = if (animationType == SlotMachineDiceAnimationType) {
|
||||
SlotMachineResult(value - 1)
|
||||
} else {
|
||||
null
|
||||
}
|
Loading…
Reference in New Issue
Block a user