generated from admin/template
61 lines
1.8 KiB
Kotlin
61 lines
1.8 KiB
Kotlin
fun main() {
|
|
showTask()
|
|
val currentHp: Short = getString("Set the current Hp.", "Current Hp").toShort(); br(2)
|
|
val energyAttached: Short = getString("Set the number of attached energy cards.", "Number of").toShort(); br(2)
|
|
|
|
if(currentHp < 1) println("Knockout!")
|
|
else println("Pokemon ready to battle!")
|
|
|
|
val attackStatus: String = if (energyAttached >= 3) "Ready!" else "Not ready!"
|
|
|
|
|
|
showTask(2)
|
|
val trainerCard: String = getString("Set the trainer card.", "Trainer card"); br(2)
|
|
|
|
when (trainerCard){
|
|
"Potion" -> println("+30 HP!")
|
|
"Professor's Research" -> println("Добор 7 карт из колоды!")
|
|
"Switch" -> println("Замена активного Покемона!")
|
|
else -> println("Unknown card.")
|
|
}
|
|
|
|
val element: String = getString("Set the number of elements.", "Element"); br(2)
|
|
|
|
val weaknessMultiplier: Float = when(element){
|
|
"Fire" -> 1.5
|
|
"Water" -> 2.0
|
|
"Grass" -> 1.2
|
|
"Electric" -> 1.6
|
|
else -> 1.0
|
|
}.toFloat()
|
|
|
|
|
|
showTask(3)
|
|
val maxHp: Short = 2500
|
|
val hpPercent: Float = currentHp.toFloat() / maxHp * 100
|
|
|
|
val healthState: String = when{
|
|
currentHp < 1 -> "Knockout!"
|
|
currentHp in 1..50 -> "Critical!"
|
|
currentHp in 51..150 -> "Wounded!"
|
|
else -> "Full Hp!"
|
|
}
|
|
|
|
println("Hp percent: $hpPercent%\nState : $healthState")
|
|
}
|
|
|
|
//============= System fun
|
|
//==========================
|
|
fun br(iterations: Byte = 1){
|
|
for (i in 1..<iterations)
|
|
println()
|
|
}
|
|
fun showTask(number: Byte = 1){
|
|
if (number != 1.toByte())
|
|
br(3)
|
|
println("=== Task № $number ===")
|
|
}
|
|
fun getString(question: String, variable: String): String{
|
|
print("$question\n$variable: ")
|
|
return readlnOrNull() ?: "null"
|
|
} |