1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

Merge pull request #162 from InsanusMokrassar/0.29.4

0.29.4
This commit is contained in:
InsanusMokrassar 2020-11-02 21:51:23 +06:00 committed by GitHub
commit 23dfa4f69d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 2 deletions

View File

@ -1,5 +1,16 @@
# TelegramBotAPI changelog # 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 ## 0.29.3
* `Common`: * `Common`:

View File

@ -15,7 +15,7 @@ ktor_version=1.4.1
javax_activation_version=1.1.1 javax_activation_version=1.1.1
library_group=dev.inmo library_group=dev.inmo
library_version=0.29.3 library_version=0.29.4
gradle_bintray_plugin_version=1.8.5 gradle_bintray_plugin_version=1.8.5
github_release_plugin_version=2.2.12 github_release_plugin_version=2.2.12

View File

@ -52,7 +52,11 @@ val inlineQueryAnswerResultsLimit = 0 .. 50
val customTitleLength = 0 .. 16 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 botCommandLengthLimit = 1 .. 32
val botCommandLimit = botCommandLengthLimit val botCommandLimit = botCommandLengthLimit

View File

@ -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
}