Files
labada/lab4.3
T

76 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
fun main() {
println("=== ЗАДАНИЕ 1: ВЫБОР ПОКЕМОНА ===")
var pokemonChoice: Int
do {
print("Выберите Покемона (1 - Пикачу, 2 - Чармандер, 3 - Бульбазавр): ")
pokemonChoice = readln().toInt()
if (pokemonChoice !in 1..3) {
println("[ОШИБКА] Неверный номер! Попробуйте снова.")
}
} while (pokemonChoice !in 1..3) // Крутимся, пока номер НЕ входит в диапазон от 1 до 3
println("[БОЙ] Вы выбрали Покемона №$pokemonChoice")
println()
println("=== ЗАДАНИЕ 2: ПОЛУЧЕНИЕ УРОНА ===")
var hp = 100
do {
print("Введите урон по Покемону: ")
val damage = readln().toInt()
hp -= damage
println("[УРОН] Нанесено: $damage | Осталось HP: $hp")
} while (hp > 0)
println("[НОКАУТ] Покемон потерял сознание и выбывает из боя!")
println()
println("=== ЗАДАНИЕ 3: АТАКА С МОНЕТКОЙ ===")
print("Введите лимит энергии: ")
var energyLimit = readln().toInt()
var flipCount = 0
do {
flipCount++
energyLimit--
print("Бросок №$flipCount (1-орел, 0-решка): ")
val coinResult = readln().toInt()
if (coinResult == 1) {
println("Бросок №$flipCount: Орёл! Урон нанесен. Осталось энергии: $energyLimit")
} else {
println("Бросок №$flipCount: Решка! Атака сорвалась.")
break
}
} while (energyLimit > 0)
println()
println("=== ЗАДАНИЕ 4: ВЗАИМНЫЙ ПЕРЕВОД ===")
println("--- Часть А ---")
print("Введите начальное кол-во карт в руке: ")
var cardsInHand = readln().toInt()
do {
cardsInHand++
println("Взята карта из колоды. Карт в руке: $cardsInHand")
} while (cardsInHand < 7)
println("Набор карт завершен!")
println("\n========================================")
println("СИМУЛЯЦИЯ ЗАВЕРШЕНА УСПЕШНО!")
println("========================================")
}