mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
slotmachine utils
This commit is contained in:
parent
ea6ab8f024
commit
a10d766295
@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
## 0.29.4
|
## 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`:
|
||||||
|
@ -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
|
||||||
|
@ -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