-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBattle.cpp
More file actions
54 lines (46 loc) · 1.63 KB
/
Copy pathBattle.cpp
File metadata and controls
54 lines (46 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "../include/Battle.h"
#include <iostream>
using namespace std;
void Battle::startBattle(Player* player, Enemy* enemy) {
cout << "\n=== ENCOUNTER: " << enemy->getName() << " ===\n";
while (player->isAlive() && enemy->isAlive()) {
// Display HUD
cout << "\n[" << player->getName() << " HP: " << player->getHealth() << "]";
cout << " vs [" << enemy->getName() << " HP: " << enemy->getHealth() << "]\n";
cout << "1. Attack\n2. Use Skill\n3. Run\nChoice: ";
int choice;
if (!(cin >> choice)) {
cin.clear();
cin.ignore(1000, '\n');
continue;
}
if (choice == 1) {
player->attackTarget(enemy);
}
else if (choice == 2) {
// Using a skill from your Skill class
cout << "Which skill? (1. Basic Fireball): ";
int skillChoice;
cin >> skillChoice;
if (skillChoice == 1) {
// You can create skill objects here as needed
// Skill(name, damage)
enemy->takeDamage(30);
cout << "Fireball hit for 30 damage!\n";
}
}
else {
cout << "You tried to run, but the " << enemy->getName() << " blocked your path!\n";
}
// Enemy Turn logic
if (enemy->isAlive()) {
enemy->attackTarget(player);
}
}
if (player->isAlive()) {
cout << "\nVictory! You earned 50 XP.\n";
player->gainExp(50);
} else {
cout << "\nYou were defeated...\n";
}
}