Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void start_combat()
- {
- Entity enemy = Entity("Kosmita");
- bool combatRunning = true;
- int choice, playerDamage, enemyDamage;
- while (combatRunning)
- {
- cout << endl << "Co chcesz zrobić?" << endl;
- cout << "------------------------------------------------" << endl;
- cout << "Twoje życie: " << player.get_health() << " | Życie przeciwnika: " << enemy.get_health() << endl;
- cout << "------------------------------------------------" << endl;
- cout << "[1] Atakuj!" << endl;
- cout << "[2] Uciekaj!" << endl << endl;
- cout << "Wpisz numer: ";
- cin >> choice;
- switch (choice)
- {
- case 1: // Gracz atakuje
- playerDamage = rand() % player.get_damage() + 1;
- cout << player.get_name() << " atakuje! Rani przeciwnika o " << playerDamage << " punkty!" << endl;
- enemy.dealDamage(playerDamage);
- if(enemy.get_health() > 0)
- {
- enemyDamage = rand() % enemy.get_damage() + 1;
- cout << enemy.get_name() << " kontratakuje! Rani bohatera o " << enemyDamage << " punkty!" << endl;
- player.dealDamage(enemyDamage);
- if(player.get_health() <= 0)
- {
- cout << player.get_name() << " przegrywa! Koniec walki!" << endl;
- combatRunning = false;
- }
- }
- else
- {
- cout << enemy.get_name() << " przegrywa! Koniec walki!" << endl;
- cout << player.get_name() << " znajduje 10 metalu!" << endl;
- player.add_metal(10);
- combatRunning = false;
- }
- break;
- case 2: // Gracz ucieka
- cout << player.get_name() << " ucieka tracąc kolejne 5% tlenu! Koniec walki!" << endl;
- player.change_oxygen(-5);
- combatRunning = false;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement