Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
#include <cstdlib>
2
#include <iostream>
3
#include "jellypaca.h"
4
5
using namespace std;
6
7
std::string
8
Jellypaca::name() {
9
return nickName;
10
}
11
12
13
void
14
Jellypaca::act(Alpaca *opponent) {
15
16
int choice = rand()%6;
17
18
// if(opponent->getStatus() == NONE){
19
// choice = 7;}
20
if(opponent->getStatus() == STUNNED){
21
choice = 0;}
22
else if(opponent->getStatus() == ASLEEP){
23
choice = 0;}
24
25
switch(choice) {
26
case 0:
27
kick(opponent);
28
break;
29
30
case 1:
31
if(pack->packSize()) {
32
compassionatize((*pack)[0]);
33
} else {
34
selfSooth();
35
}
36
break;
37
38
case 2:
39
headbutt(opponent);
40
break;
41
42
case 3:
43
spit(opponent);
44
break;
45
46
case 4:
47
mock(opponent);
48
break;
49
50
case 5:
51
concentrate();
52
break;
53
54
case 6:
55
dazzle(opponent);
56
break;
57
58
case 7:
59
hypnotize(opponent);
60
break;
61
}
62
63
}
64
65
66
//our moves
67
void
68
Jellypaca::kick(Alpaca *opponent) {
69
cout << name() << " uses sting." << endl;
70
attack(opponent, 10);
71
}
72
73
void
74
Jellypaca::hypnotize(Alpaca *opponent) {
75
cout << name() << " uses shock." << endl;
76
sleep(opponent, 10);
77
}
78
79
void
80
Jellypaca::headbutt(Alpaca *opponent) {
81
cout << name() << " uses headbutt." << endl;
82
stun(opponent, 10);
83
}
84
85
86
void
87
Jellypaca::spit(Alpaca *opponent) {
88
cout << name() << " squiggles!" << endl;
89
decreaseDefense(opponent, 10);
90
}
91
92
93
void
94
Jellypaca::mock(Alpaca *opponent) {
95
cout << name() << " says mocking things." << endl;
96
decreaseAttack(opponent, 10);
97
}
98
99
100
void
101
Jellypaca::concentrate() {
102
cout << name() << " floats in idle thought." << endl;
103
increaseAttack(10);
104
}
105
106
107
void
108
Jellypaca::dazzle(Alpaca *opponent)
109
{
110
cout << name() << " changes colors in a brilliant display." << endl;
111
comboAttack(opponent, 20, 0, 20, 0, 0);
112
}
113
114
void
115
Jellypaca::compassionatize(Alpaca *buddy)
116
{
117
cout << name() << " sends hugs from a distance." << endl;
118
bufAlly(buddy, 0, 20, 20);
119
}
120
121
122
void
123
Jellypaca::selfSooth()
124
{
125
cout << name() << " blows bubbles." << endl;
126
comboBuf(0, 20, 20);
127
}
128
129