Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
#include <cstdlib>
2
#include <iostream>
3
#include "soraalpaca.h"
4
5
using namespace std;
6
7
std::string
8
Soraalpaca::name() {
9
return nickName;
10
}
11
12
13
void
14
Soraalpaca::act(Alpaca *opponent) {
15
16
if(opponent->getStatus()!=STUNNED) {
17
headbutt(opponent);
18
} else {
19
if(getPower()>45) {
20
valorForm();
21
} else {
22
if(getHp()<15) {
23
cure();
24
} else {
25
keyblade(opponent);
26
}
27
}
28
}
29
}
30
31
32
/*current best strategy
33
if(opponent->getStatus()!=STUNNED) {
34
headbutt(opponent);
35
} else {
36
if(getHp()>65) {
37
valorForm();
38
} else {
39
if(getHp()<30) {
40
cure();
41
} else {
42
keyblade(opponent);
43
}
44
}
45
}
46
*/
47
48
49
/* second strategy LOST
50
if(opponent->getStatus()!=STUNNED) {
51
headbutt(opponent);
52
} else {
53
if(getHp()<=30 and getPower()>30) {
54
cure();
55
} else {
56
if(getPower()>55) {
57
valorForm();
58
} else {
59
dazzle(opponent);
60
}
61
}
62
}
63
}
64
*/
65
66
/* //first strategy LOST
67
if(opponent->getStatus()!=ASLEEP) {
68
hypnotize(opponent);
69
} else {
70
if(getPower()>70) {
71
valorForm();
72
} else {
73
if(getPower()<=65) {
74
keyblade(opponent);
75
} else {
76
if(getHp()<=30) {
77
cure();
78
}
79
80
81
}
82
83
}
84
}
85
}
86
87
*/
88
89
90
//our moves
91
void
92
Soraalpaca::keyblade(Alpaca *opponent) {
93
cout << name() << " attacks with its keyblade." << endl;
94
attack(opponent, 10);
95
}
96
97
void
98
Soraalpaca::hypnotize(Alpaca *opponent) {
99
cout << name() << " uses hypnotize." << endl;
100
sleep(opponent, 10);
101
}
102
103
void
104
Soraalpaca::headbutt(Alpaca *opponent) {
105
cout << name() << " uses headbutt." << endl;
106
stun(opponent, 10);
107
}
108
109
110
void
111
Soraalpaca::breakArmor(Alpaca *opponent) {
112
cout << name() << " spits!" << endl;
113
decreaseDefense(opponent, 10);
114
}
115
116
117
void
118
Soraalpaca::mock(Alpaca *opponent) {
119
cout << name() << " says mocking things that can't be said here." << endl;
120
decreaseAttack(opponent, 10);
121
}
122
123
124
void
125
Soraalpaca::valorForm() {
126
cout << name() << " contemplates the art of war." << endl;
127
increaseAttack(10);
128
}
129
130
131
void
132
Soraalpaca::dazzle(Alpaca *opponent)
133
{
134
cout << name() << " throws a flashbang hairball." << endl;
135
comboAttack(opponent, 20, 0, 20, 0, 0);
136
}
137
138
void
139
Soraalpaca::compassionatize(Alpaca *buddy)
140
{
141
cout << name() << " spreads the love." << endl;
142
bufAlly(buddy, 0, 20, 20);
143
}
144
145
146
void
147
Soraalpaca::cure()
148
{
149
cout << name() << " licks his own wounds. Awkward. Let's say anti-sora." << endl;
150
increaseHp(10);
151
}
152
153