-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlueMen.cpp
More file actions
78 lines (54 loc) · 1.95 KB
/
BlueMen.cpp
File metadata and controls
78 lines (54 loc) · 1.95 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/****************************************************************************************************
* * Program name: CS162 Project3
* * Author: Taekyoung Kim
* * Date: 02/05/2019
* * Description: This is BlueMen.cpp file for CS162 Project3
* * This project demonstrates a fantasy combat game.
* * There are 5 characters that have different ability and power.
* * The real game is done with a dice.
******************************************************************************************************/
#include "BlueMen.h"
#include <iostream>
BlueMen::BlueMen() //= default;
:Character("Blue men", 12, 3)
{
}
BlueMen::~BlueMen() = default ;
int BlueMen::Attack() {
int roll = Character::Dice(2, 10);
std::cout << "Attacker: "<<getName()<<" Attacker's roll: "<<roll<<std::endl;
return roll;
}
void BlueMen::Defense(int at) {
int numOfDef;
int damage;
if (strength > 8){
std::cout<< "Defender Blue men has 3 dices."<<std::endl;
numOfDef = Character::Dice(3, 6);
}
else if ((strength <= 8) && (strength > 4)) {
std::cout << "Defender Blue men has 2 dices now." << std::endl;
numOfDef = Character::Dice(2, 6);
}
else //(strength <=4){
{
std::cout<< "Defender Blue men 1 dice now."<<std::endl;
numOfDef = Character::Dice(1, 6);
}
damage = at -(numOfDef + armor);
std::cout<<"Defender: "<<name;
std::cout<<" Defender's roll: "<<numOfDef<<std::endl;
std::cout<<"Defender's Armor: "<<armor<<" Strength: "<<getStrength()<<std::endl;
if(damage >= getStrength()) {
std::cout << "Total inflicted Damage: " << getStrength() << std::endl;
setStrength(0);
}
else if (damage > 0 && damage < getStrength()) {
std::cout << "Total inflicted Damage: " << damage << std::endl;
setStrength(strength - damage);
}
else if(damage <= 0)
{
std::cout << "Total inflicted Damage: " << 0 << std::endl;
}
}