Files
ITMO-MAIN/Programming/Labs/Second - OOP/Pokemon/src/main/kotlin/Extensions.kt
T
2022-10-26 14:32:18 +03:00

19 lines
433 B
Kotlin

package pokemon
import ru.ifmo.se.pokemon.Battle
import ru.ifmo.se.pokemon.Pokemon
fun Battle.addAllies(vararg allies: Pokemon) {
allies.forEach { addAlly(it) }
}
fun Battle.addFoes(vararg allies: Pokemon) {
allies.forEach { addFoe(it) }
}
fun chance(percent: Int): Boolean {
return Math.random() < (percent / 100)
}
fun chance(percent: Int, action: () -> Unit): Boolean {
return Math.random() < (percent / 100)
}