generated from admin/template
Обновить works/lab-01/Readme.md
This commit is contained in:
+107
-7
@@ -1,15 +1,115 @@
|
|||||||
# Лабораторная работа №1
|
# Лабораторная работа №1
|
||||||
|
|
||||||
* **Студент:** [ФИО]
|
* **Студент:** Жукаускайте Елизавета
|
||||||
* **Вариант / Карточка:** [Например: #025 Pikachu]
|
* **Вариант / Карточка:** [Например: #025 Pikachu]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Ключевой код
|
## Ключевой код
|
||||||
```csharp
|
|
||||||
// Самая важная часть реализации (методы, структуры, логика)
|
fun main() {
|
||||||
public class Card
|
var deckSize = 60
|
||||||
{
|
var cardsInHand = 0
|
||||||
public string Name { get; set; }
|
print("How much cards to draw?")
|
||||||
public int Hp { get; set; }
|
val targetDrawInput = readln().toIntOrNull() ?: 0
|
||||||
|
var currentDraw = 0
|
||||||
|
while (currentDraw < targetDrawInput && deckSize > 0) {
|
||||||
|
currentDraw++
|
||||||
|
cardsInHand++
|
||||||
|
deckSize--
|
||||||
|
println("Took the cards № $currentDraw IN hand: $cardsInHand, in deck: $deckSize")
|
||||||
|
|
||||||
|
}
|
||||||
|
println("Your HP is?")
|
||||||
|
val currentHpInput = readln().toInt()
|
||||||
|
if (currentHpInput <= 0) {
|
||||||
|
println("K.O!")
|
||||||
|
} else {
|
||||||
|
println("Pokemon ready!")
|
||||||
|
}
|
||||||
|
print("Your energy is?")
|
||||||
|
val energyAttachedInput = readln().toInt()
|
||||||
|
do {
|
||||||
|
print("How much energy the attack costs?? ")
|
||||||
|
val energyCost = readln().toIntOrNull() ?: 0
|
||||||
|
|
||||||
|
if (energyCost < 0) {
|
||||||
|
println("[ERROR] Attack cost can't be negative!")
|
||||||
|
}
|
||||||
|
} while (energyCost < 0)
|
||||||
|
println("Determine attack cost")
|
||||||
|
val energyCost = readln().toIntOrNull() ?: 0
|
||||||
|
println("[Success!] Attack cost is $energyCost")
|
||||||
|
|
||||||
|
val attackStatus = if (energyAttachedInput >= 3) {
|
||||||
|
"Ready to attack!!"
|
||||||
|
} else {
|
||||||
|
"Not enough to attack!"
|
||||||
|
}
|
||||||
|
println("Your trainer cards is?")
|
||||||
|
val trainerCardInput = readln()
|
||||||
|
when (trainerCardInput) {
|
||||||
|
"Potion" -> println("Healing +30 HP")
|
||||||
|
"Professor's Research" -> println("Take 7 cards!")
|
||||||
|
"Switch" -> println("Switch active Pokemon")
|
||||||
|
else -> println("Invalid Trainer")
|
||||||
|
}
|
||||||
|
println("What is your element?")
|
||||||
|
val elementInput = readln()
|
||||||
|
val weaknessMultiplier = when (elementInput) {
|
||||||
|
"Water" -> {
|
||||||
|
println("Electric weakness")
|
||||||
|
2.0
|
||||||
|
}
|
||||||
|
|
||||||
|
"Fire" -> {
|
||||||
|
println("Water weakness")
|
||||||
|
1.5
|
||||||
|
}
|
||||||
|
|
||||||
|
"Grass" -> {
|
||||||
|
println("Fire weakness")
|
||||||
|
1.2
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
println("Basic multiplier")
|
||||||
|
1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println("What is your HP percent?")
|
||||||
|
val hpPercent = readln().toInt()
|
||||||
|
val healthState = when (hpPercent) {
|
||||||
|
0 -> "K.O"
|
||||||
|
in 1..20 -> "Critical Health"
|
||||||
|
in 21..70 -> "Good condition"
|
||||||
|
else -> "Perfect!"
|
||||||
|
}
|
||||||
|
println("Attack availability: $attackStatus")
|
||||||
|
println("Weakness multiplies: $weaknessMultiplier")
|
||||||
|
println("Current condition $healthState")
|
||||||
|
|
||||||
|
print("Enemy HP: ")
|
||||||
|
var enemyHp =readln().toInt()
|
||||||
|
var round = 1
|
||||||
|
while (true) {
|
||||||
|
if (round % 2 != 0) {
|
||||||
|
enemyHp -= 25
|
||||||
|
println("Dealt 25 dmg.")
|
||||||
|
|
||||||
|
if (enemyHp <= 0) {
|
||||||
|
println("Enemy Pokemon fell. Battle terminated.")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("Round $round: [Defense] Round skipped.")
|
||||||
|
}
|
||||||
|
round++
|
||||||
|
}
|
||||||
|
var damageCounters = 0
|
||||||
|
val maxCounters = 5
|
||||||
|
while (damageCounters < maxCounters) {
|
||||||
|
damageCounters++
|
||||||
|
println("Damage counter accepted #$damageCounters.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user