Entity.cpp 3.34 KB
Newer Older
Noah Olsen's avatar
Noah Olsen committed
1
// "Copyright [year] <Copyright Owner>"
Noah Olsen's avatar
commit  
Noah Olsen committed
2 3 4 5 6
#include "Entity.h"
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
Noah Olsen's avatar
Noah Olsen committed
7 8
#include "Grid.h"
#include "Moves.h"
Noah Olsen's avatar
commit  
Noah Olsen committed
9 10 11 12 13 14 15

using namespace std;

class MoveSet;

// void Entity::action() {}

Noah Olsen's avatar
Noah Olsen committed
16 17
void Entity::move() {
}
Noah Olsen's avatar
commit  
Noah Olsen committed
18 19

void Entity::setPos() {
Noah Olsen's avatar
Noah Olsen committed
20 21 22
    // Random Positioning
    this->colPos = rand() % 4;
    this->rowPos = rand() % 4;
Noah Olsen's avatar
commit  
Noah Olsen committed
23 24
}

Noah Olsen's avatar
Noah Olsen committed
25 26 27
bool Entity::checkHealth() {
    return (con > 0);
}
Noah Olsen's avatar
commit  
Noah Olsen committed
28 29

Player::Player() {
Noah Olsen's avatar
Noah Olsen committed
30 31 32 33 34
    setPos();
    this->con = 10;
    this->str = 10;
    this->dex = 10;
    // setClass('a');
Noah Olsen's avatar
commit  
Noah Olsen committed
35 36 37
}

void Player::action() {
Noah Olsen's avatar
Noah Olsen committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    char act;
    do {
        cout << "What will you do?" << endl;
        cout << " a. Light Attack" << endl;
        cout << " b. Heavy Attack" << endl;
        cout << " c. Defend" << endl;
        cout << " d. Counter" << endl;
        cout << " e. Flee" << endl;
        cout << " Enter Action Here: ";
        cin >> act;

        switch (act) {
            case 'a':
                // callLightAttack();
                break;
            case 'b':
                // callHeavyAttack();
                break;
            case 'c':
                // callDefend();
                break;
            case 'd':
                break;
            case 'e':
                break;
            default:
                cout << "Please enter a valid option." << endl;
                break;
        }
    } while (act != 'a' && act != 'b' && act != 'c' && act != 'd' &&
             act != 'e' && act != 'f');
Noah Olsen's avatar
commit  
Noah Olsen committed
69 70 71
}

void Player::setClass(char Class) {
Noah Olsen's avatar
Noah Olsen committed
72 73 74 75 76 77 78 79 80
    switch (Class) {
        case 'a':  // Warrior
            this->str = 14;
            this->con = 12;
            this->dex = 8;
            break;
        case 'b':  // Rogue
            break;
    }
Noah Olsen's avatar
commit  
Noah Olsen committed
81 82 83
}

void Enemy::action() {
Noah Olsen's avatar
Noah Olsen committed
84 85 86 87 88 89 90 91 92 93 94 95 96
    int act = rand() % 10;
    if (con <= 2) {
        // Attempt flee
    } else {
        if (act <= 2) {
            // Heavy Attack
        } else if (act >= 3 && act <= 5) {
            // Light Attack
        } else if (act >= 6 && act <= 8) {
            // Defend
        } else if (act >= 9) {
            // Counter
        }
Noah Olsen's avatar
commit  
Noah Olsen committed
97 98 99 100
    }
}

void Enemy::setBossClassByChoice(int boss) {
Noah Olsen's avatar
Noah Olsen committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
    switch (boss) {
        case 1:  // Minotaur
            this->str = 16;
            this->con = 14;
            this->dex = 8;
            break;
        case 2:  // Dragonoid
            this->str = 14;
            this->con = 16;
            this->dex = 12;
            break;
        case 3:  // Cyclops
            this->str = 18;
            this->con = 16;
            this->dex = 6;
            break;
    }
Noah Olsen's avatar
commit  
Noah Olsen committed
118 119 120
}

void Enemy::setBossClassByRand() {
Noah Olsen's avatar
Noah Olsen committed
121
    int monster = rand() % 3;  // Boss Monster Randomization
Noah Olsen's avatar
commit  
Noah Olsen committed
122

Noah Olsen's avatar
Noah Olsen committed
123
    setBossClassByChoice(monster);
Noah Olsen's avatar
commit  
Noah Olsen committed
124 125 126
}

void Enemy::setClassByChoice(int monster) {
Noah Olsen's avatar
Noah Olsen committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    switch (monster) {
        case 1:  // Goblin
            this->str = 6;
            this->con = 6;
            this->dex = 12;
            break;
        case 2:  // Orc
            this->str = 14;
            this->con = 10;
            this->dex = 8;
            break;
        case 3:  // Skeleton
            this->str = 8;
            this->con = 10;
            this->dex = 10;
            break;
    }
Noah Olsen's avatar
commit  
Noah Olsen committed
144 145 146
}

void Enemy::setClassByRand() {
Noah Olsen's avatar
Noah Olsen committed
147
    int monster = rand() % 3;  // Monster Randomization
Noah Olsen's avatar
commit  
Noah Olsen committed
148

Noah Olsen's avatar
Noah Olsen committed
149
    setClassByChoice(monster);
Noah Olsen's avatar
commit  
Noah Olsen committed
150 151 152
}

Enemy::Enemy(bool boss) {
Noah Olsen's avatar
Noah Olsen committed
153 154 155 156 157 158 159
    setPos();
    if (boss) {
        setBossClassByRand();
    } else {
        setClassByRand();
    }
}