Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2369 views
1
/*
2
* This is the base class for the attack alapcas. You are not allowed
3
* to modify this class, nor are you allowed to attempt to get at the
4
* private memory of this class.
5
*
6
* The idea of this animal is that it can attack others of its kind.
7
* The alpaca works by the following points scheme:
8
* Power - This is the number of power points the alpaca has.
9
* Performing actions costs alpaca power points.
10
*
11
* Attack - This modifier determines how much damage the alpaca can
12
* do. This can be modified, but doing so costs alpaca
13
* power points.
14
*
15
* Defense - This number decreases the damage the alpaca will
16
* absorb. This number can be increased, which costs
17
* alpaca power points.
18
*
19
* HP - The remaining hitpoints for the alpaca. If this number
20
* falls below zero, the alpaca loses the battle.
21
*
22
* Status - The alpaca can be in the following states: NORMAL,
23
* ASLEEP, STUNNED. Statuses can be modified by
24
* attacks, but doing so costs points.
25
*/
26
#ifndef ALPACA_H
27
#define ALPACA_H
28
#include <string>
29
30
enum alpacaStatus {NONE, ASLEEP, STUNNED};
31
32
class Fracas;
33
34
class Alpaca {
35
public:
36
//the constructor sets the power and the default attack and defense values
37
Alpaca(unsigned int power);
38
39
//pure virtual functions (those which makes each alpaca special)
40
virtual std::string name()=0; //returns the alpaca's name
41
virtual void act(Alpaca *opponent)=0; //do the alpaca's actions in a given round
42
43
//alpaca actions. These are not virtual, and so you cannot override them!
44
//(at least, you cannot override them in a way that will matter.)
45
void attack(Alpaca *opponent, unsigned int p); //attack an alpaca's life. expend p points
46
void sleep(Alpaca *opponent, unsigned int p); //put an alpaca to sleep. expend p points
47
void stun(Alpaca *opponent, unsigned int p); //stun an alpaca to sleep. expend p points
48
void decreaseDefense(Alpaca *opponent, unsigned int p);
49
void decreaseAttack(Alpaca *opponent, unsigned int p);
50
51
//alpaca buffs you can apply to yourself!
52
void increaseAttack(unsigned int p);
53
void increaseDefense(unsigned int p);
54
void increaseHp(unsigned int p);
55
56
57
58
//perform multi-attack moves (Each option multiplies the total point
59
//expendature, so 2 combos cost twice as much as 1 move, 3 cost 3, etc.
60
//put points into each attack category, 0 if you don't want to use that
61
void comboAttack(Alpaca *opponent,
62
unsigned int attackPoints,
63
unsigned int sleepPoints,
64
unsigned int stunPoints,
65
unsigned int decDefensePoints,
66
unsigned int decAttackPoints);
67
68
69
//perform a multi-buf move. (Each option multiplies the total point
70
//expendature, so 2 combos cost twice as much as 1 move, and so on.
71
void comboBuf(unsigned int incAttackPoints,
72
unsigned int incDefensePoints,
73
unsigned int incHpPoints);
74
75
76
//buffs you can apply to allies (or enemies if you are nuts)
77
//this works like the combo buf function
78
void bufAlly(Alpaca *ally,
79
unsigned int incAttackPoints,
80
unsigned int incDefensePoints,
81
unsigned int incHpPoints);
82
83
//checks the remaining Alpaca power
84
unsigned int getPower();
85
86
//checks the attack score of the alpaca
87
double getAttack();
88
89
//checks the defense score of the alpaca
90
double getDefense();
91
92
//checks the hp of the alpaca
93
double getHp();
94
95
//checks the turn status
96
bool isMyTurn();
97
98
//checks the alpaca status
99
alpacaStatus getStatus();
100
101
//checks how long the status will remain in effect
102
unsigned int getStatusCounter();
103
104
//checks to see if alpaca is alive or dead
105
bool isAlive();
106
private:
107
void performRound(Alpaca *opponent); //runs the alpaca attack round
108
friend Fracas;
109
110
unsigned int power; //power points
111
double attackScore; //attack score
112
double defense; //defense score
113
double hp; //hitpoints
114
bool myTurn; //true only during an alpaca's turn
115
alpacaStatus status;
116
unsigned int statusCounter;
117
};
118
#endif
119
120
121
122
123