CSC112 Spring 2016 Examples
#include <cstdlib>1#include <iostream>2#include "randalpaca.h"34using namespace std;56std::string7Randalpaca::name() {8return nickName;9}101112void13Randalpaca::act(Alpaca *opponent) {14//make a random move. Does Randal feel lucky? Well does he punk?15switch(rand()%8) {16case 0:17kick(opponent);18break;1920case 1:21hypnotize(opponent);22break;2324case 2:25headbutt(opponent);26break;2728case 3:29spit(opponent);30break;3132case 4:33mock(opponent);34break;3536case 5:37concentrate();38break;3940case 6:41dazzle(opponent);42break;4344case 7:45if(pack->packSize()) {46compassionatize((*pack)[0]);47} else {48selfSooth();49}50break;51}52}5354//our moves55void56Randalpaca::kick(Alpaca *opponent) {57cout << name() << " uses kick." << endl;58attack(opponent, 10);59}6061void62Randalpaca::hypnotize(Alpaca *opponent) {63cout << name() << " uses hypnotize." << endl;64sleep(opponent, 10);65}6667void68Randalpaca::headbutt(Alpaca *opponent) {69cout << name() << " uses headbutt." << endl;70stun(opponent, 10);71}727374void75Randalpaca::spit(Alpaca *opponent) {76cout << name() << " spits!" << endl;77decreaseDefense(opponent, 10);78}798081void82Randalpaca::mock(Alpaca *opponent) {83cout << name() << " says mocking things." << endl;84decreaseAttack(opponent, 10);85}868788void89Randalpaca::concentrate() {90cout << name() << " contemplates the art of war." << endl;91increaseAttack(10);92}939495void96Randalpaca::dazzle(Alpaca *opponent)97{98cout << name() << " throws a flashbang hairball." << endl;99comboAttack(opponent, 20, 0, 20, 0, 0);100}101102void103Randalpaca::compassionatize(Alpaca *buddy)104{105cout << name() << " spreads the love." << endl;106bufAlly(buddy, 0, 20, 20);107}108109110void111Randalpaca::selfSooth()112{113cout << name() << " licks his own wounds." << endl;114comboBuf(0, 20, 20);115}116117