PMU_PIbd32_Kamcharova_K.A/lib/character.dart
2024-11-10 13:42:39 +04:00

44 lines
1.0 KiB
Dart
Raw Permalink 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.

import 'dart:async';
enum CharacterType {
Survivor,
Hunter,
}
abstract class Character {
String name;
CharacterType type;
int level;
Character({required this.name, required this.type, this.level = 1});
Character.empty() : name = '', type = CharacterType.Survivor, level = 1;
String getInfo() {
return "Имя: $name, Тип: ${type.toString().split('.').last}, Уровень: $level";
}
Future<void> levelUp() async {
await Future.delayed(const Duration(seconds: 1));
level++;
print("$name поднял(а) уровень до $level.");
}
}
class Survivor extends Character {
Survivor({required String name}) : super(name: name, type: CharacterType.Survivor);
void useAbility() {
print("$name использовал(а) свою способность.");
}
}
class Hunter extends Character {
Hunter({required String name}) : super(name: name, type: CharacterType.Hunter);
void useAbility() {
print("$name использовал(а) свою способность.");
}
}