-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.cpp
More file actions
31 lines (25 loc) · 746 Bytes
/
Copy pathgame.cpp
File metadata and controls
31 lines (25 loc) · 746 Bytes
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
#include "game.h"
#include <iostream>
Game::Game() : playerHealth(15), playerAttack(3), goblinHealth(10), treasureFound(false) {}
std::string Game::startGame() {
return "Welcome to Monk Adventure!";
}
std::string Game::movePlayer(std::string direction) {
return "You moved " + direction;
}
std::string Game::attack() {
if (rand() % 2 == 0) {
goblinHealth -= playerAttack;
return "You attacked! Goblin HP: " + std::to_string(goblinHealth);
} else {
return "You missed!";
}
}
std::string Game::meditate() {
playerHealth = 15;
return "You meditated. Health restored!";
}
std::string Game::upgrade() {
playerAttack += 2;
return "Attack increased to " + std::to_string(playerAttack);
}