generated from admin/template
Обновить works/lab-04.3/lab4.3.kt
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
fun main() {
|
||||
println("\n=== ЗАДАНИЕ 1: ВЫБОР ПОКЕМОНА ===" )
|
||||
var userChoicePokemon: Int
|
||||
var isValidChoice = false
|
||||
var inputDamage: Int
|
||||
var pokemonHp = 100
|
||||
var pokemonName = " "
|
||||
var energyLimit: Int
|
||||
var throwCount = 1
|
||||
var throwRes: Int
|
||||
var cardsMax = 7
|
||||
var cardsStart: Int
|
||||
|
||||
do {
|
||||
print("\nВыберите Покемона (1 - Пикачу, 2 - Чармандер, 3 - Бульбазавр): ")
|
||||
userChoicePokemon = readln().toInt()
|
||||
isValidChoice = userChoicePokemon in 1..3
|
||||
if (!isValidChoice) println("[ОШИБКА] Неверный номер! Попробуйте снова.")
|
||||
} while (!isValidChoice)
|
||||
when (userChoicePokemon)
|
||||
{
|
||||
1 -> pokemonName = "Пикачу"
|
||||
2 -> pokemonName = "Чармандер"
|
||||
3 -> pokemonName = "Бульбазавр"
|
||||
}
|
||||
println("[БОЙ] Вы выбрали Покемона №$userChoicePokemon [$pokemonName]" )
|
||||
|
||||
println("\n=== ЗАДАНИЕ 2: ПОЛУЧЕНИЕ УРОНА ===" )
|
||||
println("[БОЙ] HP покемона" )
|
||||
do {
|
||||
print("Введите урон по Покемону: " )
|
||||
inputDamage = readln().toInt()
|
||||
pokemonHp -= inputDamage
|
||||
if (pokemonHp < 0) {
|
||||
pokemonHp = 0
|
||||
println("[НОКАУТ] Покемон потерял сознание и выбывает из боя!")
|
||||
}
|
||||
println("[УРОН] Нанесено: $inputDamage | Осталось HP: $pokemonHp" )
|
||||
}while (pokemonHp !=0)
|
||||
|
||||
println("\n=== ЗАДАНИЕ 3: АТАКА С МОНЕТКОЙ ===" )
|
||||
|
||||
print("Введите лимит энергии: " )
|
||||
energyLimit = readln().toInt()
|
||||
do {
|
||||
print("Бросок №$throwCount (1-орел, 0-решка): " )
|
||||
throwRes = readln().toInt()
|
||||
if (throwRes == 0)
|
||||
{
|
||||
println("Бросок №$throwCount: Решка! Атака сорвалась." )
|
||||
energyLimit--
|
||||
throwCount++
|
||||
}
|
||||
else if (throwRes == 1)
|
||||
{
|
||||
println("Бросок №$throwCount: Орёл! Урон нанесен. Осталось энергии: 2" )
|
||||
energyLimit--
|
||||
throwCount++
|
||||
}
|
||||
else
|
||||
{
|
||||
println("[ОШИБКА] Неверное число! Попробуйте снова.")
|
||||
}
|
||||
} while (energyLimit > 0)
|
||||
|
||||
println("\n=== ЗАДАНИЕ 4: ВЗАИМНЫЙ ПЕРЕВОД ===" )
|
||||
println("--- Часть А ---" )
|
||||
print("Введите начальное кол-во карт в руке: ")
|
||||
cardsStart = readln().toInt()
|
||||
do {
|
||||
cardsStart++
|
||||
println("Взята карта из колоды. Карт в руке: $cardsStart" )
|
||||
} while (cardsStart < cardsMax)
|
||||
println("Набор карт завершен!" )
|
||||
println("========================================" )
|
||||
println("СИМУЛЯЦИЯ ЗАВЕРШЕНА УСПЕШНО!" )
|
||||
println("========================================")
|
||||
}
|
||||
Reference in New Issue
Block a user