Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
//implimentation file for hackPaca
2
3
#include "hackPaca.h"
4
#include "../alpaca.h"
5
#include <cstdlib>
6
#include <iostream>
7
8
using namespace std;
9
10
//virtual functions to override
11
std::string
12
hackPaca::name() {
13
return "hackPaca";
14
}
15
16
void
17
hackPaca::act(Alpaca *opponent) {
18
switch(rand()%5) {
19
case 0:
20
bug(opponent);
21
break;
22
case 1:
23
virus(opponent);
24
break;
25
case 2:
26
reboot();
27
break;
28
case 3:
29
error(opponent);
30
break;
31
case 4:
32
rainbow(opponent);
33
break;
34
}
35
}
36
37
//moveset
38
void
39
hackPaca::bug(Alpaca *opponent) {
40
cout << name() << " installs a bug in its opponent's mainframe!" << endl
41
<< "... It's Super Effective!" << endl;
42
attack(opponent, 6);
43
}
44
45
void
46
hackPaca::virus(Alpaca *opponent) {
47
cout << name() << " installs a lethal virus!!" << endl
48
<< "... It's Super Effective!" << endl;
49
attack(opponent, 10);
50
}
51
52
void
53
hackPaca::reboot() {
54
cout << name() << " reboots and upgrades its attack software!!" << endl;
55
increaseAttack(8);
56
}
57
58
void
59
hackPaca::error(Alpaca *opponent) {
60
cout << name() << " confuses its opponent with thousands of compilor error messages!!" << endl;
61
stun(opponent, 4);
62
}
63
64
void
65
hackPaca::rainbow(Alpaca *opponent) {
66
cout << name() << " renders its opponent useless with the dreaded RAINBOW WHEEL!!!!!" << endl;
67
sleep(opponent, 8);
68
}
69
70