Ejemplo n.º 1
0
Equippable::Equippable(Equippable::Category inCat, int pot) {
    this->potency = pot;
    this->category = inCat;
    this->modSTR = 0;
    this->modTOU = 0;
    this->modATT = 0;
    this->modDEF = 0;
    this->modMAG = 0;
    this->modWIL = 0;
    this->modSIGHT = 0;
    this->modMV = 0;
    this->colour = COL_CYAN;
    this->type = Item::EQUIPPABLE;

    switch (inCat) {
        case Equippable::DAGGER:
            this->modSTR = (2 + DICEROLL(pot, 2)) / 4;
            this->modATT = 2 + DICEROLL(pot, 2);
            this->ShiningChance();
            this->location = WEAPON;
            break;
        case Equippable::SHORT_SWORD:
            this->modSTR = (2 + DICEROLL(pot, 2)) / 2;
            this->modATT = 2 + DICEROLL(pot, 2);
            this->ShiningChance();
            this->location = WEAPON;
            break;
        case Equippable::LONGSWORD:
            this->modSTR = 2 + DICEROLL(pot, 2);
            this->modATT = (2 + DICEROLL(pot, 2)) / 2;
            this->ShiningChance();
            this->location = WEAPON;
            break;
        case Equippable::MACE:
        case Equippable::FLAIL:
            this->modSTR = (2 + DICEROLL(pot, 2)) / 2;
            this->modATT = (2 + DICEROLL(pot, 2)) / 2;
            this->ShiningChance();
            this->location = WEAPON;
            break;
        case Equippable::STAFF:
            this->modSTR = (2 + DICEROLL(pot, 2)) / 4;
            this->modATT = (2 + DICEROLL(pot, 2)) / 4;
            this->modMAG = 2 + DICEROLL(pot, 2);
            this->location = WEAPON;
            break;
        case Equippable::TWO_HANDED_SWORD:
        case Equippable::TWO_HANDED_AXE:
            this->modSTR = (2 + DICEROLL(pot, 2)) * 1.5;
            this->modATT = 2 + DICEROLL(pot, 2);
            this->ShiningChance();
            this->location = WEAPON;
            break;
        case Equippable::LIGHT_SHIELD:
            this->modDEF = 2 + DICEROLL(pot, 2);
            this->ShiningChance();
            this->location = SHIELD;
            break;
        case Equippable::HEAVY_SHIELD:
            this->modDEF = 2 + DICEROLL(pot, 2) / 2;
            this->modTOU = 2 + DICEROLL(pot, 2) / 2;
            this->ShiningChance();
            this->location = SHIELD;
            break;
        case Equippable::ROBES:
            this->modMAG = 2 + DICEROLL(pot, 2) / 2;
            this->modWIL = 2 + DICEROLL(pot, 2) / 2;
            this->location = BODY;
            break;
        case Equippable::LEATHER_ARMOUR:
            this->modTOU = 2 + DICEROLL(pot, 2) / 2;
            this->location = BODY;
            this->location = BODY;
            break;
        case Equippable::CHAINMAIL:
            this->modTOU = 2 + DICEROLL(pot, 2);
            this->location = BODY;
            break;
        case Equippable::PLATEMAIL:
            this->modTOU = (2 + DICEROLL(pot, 2)) * 1.5;
            this->modDEF = - (2 + DICEROLL(pot, 2) / 2);
            this->location = BODY;
            break;
        case Equippable::HOLY_SYMBOL:
            this->modWIL = 2 + DICEROLL(pot, 2);
            this->location = NECK;
            break;
        case Equippable::TORCH:
            this->modSIGHT = 3;
            this->location = SHIELD;
            break;
        case Equippable::LAST_CATEGORY:
        default:
            GUI::Alert("Error generating item!");
            break;
    }

    switch (this->location) {
        case HEAD:
            this->symbol = 'h';
            break;
        case BODY:
            this->symbol = 'a';
            break;
        case WEAPON:
            this->symbol = 'w';
            break;
        case SHIELD:
            this->symbol = 's';
            break;
        case GLOVES:
            this->symbol = 'g';
            break;
        case BOOTS:
            this->symbol = 'b';
            break;
        case RING1:
        case RING2:
            this->symbol = 'r';
            break;
        case NECK:
            this->symbol = 'n';
            break;
        case LAST_EQUIP_LOCATION:
        default:
            this->symbol = 'i';
            break;
    }

    //Special case symbols
    if (this->category == Equippable::TORCH) {
        this->symbol = 't';
        this->colour = COL_YELLOW;
    }
}
Ejemplo n.º 2
0
int
DICEROLL(int num, int sz) {
    if (num <= 1)
        return rand() % sz + 1;
    return DICEROLL(num - 1, sz) + rand() % sz + 1;
}