예제 #1
0
void DebriefMenu::handleGameEvent(GameEvent evt) {
    if (evt.type_ == GameEvent::GE_SEARCH) {
        // A research has ended
        Research *pRes = static_cast<Research *> (evt.pCtxt_);
        Weapon *pWeap = g_App.weapons().getWeapon(pRes->getSearchWeapon());

        getStatic(txtSearchId_)->setTextFormated("#DEBRIEF_SEARCH", pWeap->getName());
    }
}
예제 #2
0
void Hero::addItem(Weapon weaponIn)
{
    if (weaponIn.getName().compare("none") != 0)
    {
        inventory.push_back(weaponIn);
        if (weaponIn.getType() == WEAPON)
        {
            weapon = weaponIn;
        }
    }
}
예제 #3
0
Weapon Weapon::randomWeapon(){
    Weapon w = Weapon();
    int price = 0;
    w.setPrice(price);
    w.loadRandomType();
    w.addPower();
    for (int i=0; i< w.getPower() ; i++){
        w += w.loadRandomWeaponBuff();
    }
    w.setName(w.getName() + ", " + iTos(w.getDd1()) + "d" + iTos(w.getDd2()));
    w.setName(w.getName() + (w.getRange() != 1 ? + ", " + iTos(w.getRange()) + "m" : "") );
    return w;
}
예제 #4
0
void Player::equip(Equipment * eq)
{
	Armor * pArm = dynamic_cast<Armor*>(eq);
	if (pArm != NULL)
	{
		vInventory.push_back(armor);
		armor = pArm;
		cout << "You have equipped a " << pArm->getName() << "!" << endl;
	}
	Weapon * pWeap = dynamic_cast<Weapon *>(eq);
	if (pWeap != NULL)
	{
		vInventory.push_back(weapon);
		weapon = pWeap;
		cout << "You have equipped a " << pWeap->getName() << "!" << endl;
	}
}
예제 #5
0
void DebriefMenu::handleGameEvent(GameEvent evt) {
    if (evt.type_ == GameEvent::GE_SEARCH) {
        // A research has ended, so check which type
        Research *pRes = static_cast<Research *> (evt.pCtxt_);
         // Is it equipment or mods research?
         if (pRes->getType() == Research::EQUIPS) {
             // Get researched weapon type
             Weapon::WeaponType wt= pRes->getSearchWeapon();
             assert(wt);

             // Get weapon
             Weapon *pWeap = g_App.weapons().getWeapon(wt);
             assert(pWeap);

             // Draw name of it
             getStatic(txtSearchId_)->setTextFormated("#DEBRIEF_SEARCH", pWeap->getName());
         } else {
             // Must be mods research so draw it
             getStatic(txtSearchId_)->setTextFormated("#DEBRIEF_SEARCH", pRes->getName().c_str());
         }
    }
}
예제 #6
0
	string getWeaponName() const
	{// delegation of task to the weapon class
		return weapon.getName();
	}
예제 #7
0
void MenuInventory::getViewScreen() {
    DM::say("Gear:");
    Player *player = _game->getPlayer();
    Weapon *main = player->getMainWeapon();
    if (main) {
        int base = player->getStrength();
        string type = "";
        switch (main->getWeaponType()) {
        case WeaponType::SIMPLE:
            type = "Simple Weapon";
            break;
        case WeaponType::FINESSE:
            if (player->getDexterity() > player->getStrength()) {
                base = player->getDexterity();
            }
            type = "Finesse Weapon";
            break;
        case WeaponType::MARTIAL:
            type = "Martial Weapon";
            break;
        case WeaponType::HEAVY:
            type = "heavy Weapon";
            break;
        case WeaponType::SHIELD:
            type = "Shield";
            break;
        }

        DM::say("\t<Main> Weapon: " + main->getName() + " (" + to_string(main->getDiceAmount()) + "d" +
                to_string(main->getDiceSize()) + "+" + to_string(base) + " " + type + ")");
    } else {
        DM::say("\t<Main> Weapon: None");
    }

    Weapon *off = player->getOffHandWeapon();
    if (off) {
        int base = player->getStrength();
        string type = "";
        switch (off->getWeaponType()) {
        case WeaponType::SIMPLE:
            type = "Simple Weapon";
            break;
        case WeaponType::FINESSE:
            if (player->getDexterity() > player->getStrength()) {
                base = player->getDexterity();
            }
            type = "Finesse Weapon";
            break;
        case WeaponType::MARTIAL:
            type = "Martial Weapon";
            break;
        case WeaponType::HEAVY:
            type = "heavy Weapon";
            break;
        case WeaponType::SHIELD:
            type = "Shield (+2AC)";
            break;
        }

        DM::say("\t<Off>hand Weapon: " + off->getName() + " (" + to_string(off->getDiceAmount()) + "d" +
                to_string(off->getDiceSize()) + "+" + to_string(base) + " " + type + ")");
    } else {
        DM::say("\t<Off>hand Weapon: None");
    }

    Armor *armor = player->getArmor();
    if (armor) {
        string extra = "";
        switch (armor->getArmorType()) {
        case ArmorType::LIGHT:
            extra = " + Dex ";
            break;
        case ArmorType::MEDIUM:
            extra = " + max 2 Dex ";
            break;
        case ArmorType::HEAVY:
            break;
        }

        DM::say("\t<Armor>: " + armor->getName() + " ( AC: " + to_string(armor->getBaseAC()) + extra + ")");
    } else {
        DM::say("\t<Armor>: None");
    }

    DM::say("\nInventory:");
    int i = 1;
    for (map<Item *, int>::iterator item = _inventory->begin(); item != _inventory->end(); ++item) {
        switch (item->first->getItemType()) {
        case ItemType::ARMOR: {
            Armor *armor = (Armor *) item->first;
            string extra = "";
            switch (armor->getArmorType()) {
            case ArmorType::LIGHT:
                extra = " + Dex ";
                break;
            case ArmorType::MEDIUM:
                extra = " + max 2 Dex ";
                break;
            case ArmorType::HEAVY:
                break;
            }
            DM::say("\t[" + to_string(i) + "]: " + item->first->getName() + " - AC: " +
                    to_string(armor->getBaseAC()) +
                    extra + "(" + to_string(item->second) + "x)");
            break;
        }
        case ItemType::WEAPON: {
            Weapon *weapon = (Weapon *) item->first;

            string type = "";
            switch (weapon->getWeaponType()) {
            case WeaponType::SIMPLE:
                type = "Simple Weapon";
                break;
            case WeaponType::FINESSE:
                type = "Finesse Weapon";
                break;
            case WeaponType::MARTIAL:
                type = "Martial Weapon";
                break;
            case WeaponType::HEAVY:
                type = "heavy Weapon";
                break;
            case WeaponType::SHIELD:
                type = "Shield (+2AC)";
                break;
            }

            DM::say("\t[" + to_string(i) + "]: " + item->first->getName() + " - " + type + " - " +
                    to_string(weapon->getDiceAmount()) +
                    "d" + to_string(weapon->getDiceSize()) + " dmg (" + to_string(item->second) + "x)");
            break;
        }
        case ItemType::CONSUMABLE: {
            Consumable *consumable = (Consumable *) item->first;

            string type = "";
            string effect = "";

            switch (consumable->getConsumableType()) {
            case ConsumableType::FOOD:
                type = "Food";
                effect = "hp max per rest";
                break;
            case ConsumableType::HEALING:
                type = "Healing item";
                effect = "hp max on use";
                break;
            case ConsumableType::ILLUMINATION:
                type = "Illumination";
                effect = "room(s) of light";
                break;
            case ConsumableType::BOMB:
                type = "Bomb";
                if (consumable->getDiceAmount() == 0) {
                    effect = "cave-in(s)";
                } else {
                    effect = "probable cave-in(s)";
                }
                break;
            case ConsumableType::TALISMAN:
                type = "Talisman";
                effect = "maximum distance to exit";
                break;
            }

            if (consumable->getDiceAmount() == 0) {
                DM::say("\t[" + to_string(i) + "]: " + consumable->getName() + " - " + type + " - " +
                        to_string(consumable->getBaseValue()) + " " + effect + " (" +
                        to_string(item->second) + "x)");
            } else {
                DM::say("\t[" + to_string(i) + "]: " + consumable->getName() + " - " + type + " - " +
                        to_string(consumable->getDiceAmount()) + "d" + to_string(consumable->getDiceSize()) +
                        "+" +
                        to_string(consumable->getBaseValue()) + " " + effect + " (" +
                        to_string(item->second) + "x)");
            }
            break;
        }
        }
        ++i;
    }
    if (i == 1) {
        DM::say("\tNo items");
    }
}
예제 #8
0
void AttackCommand::Run(list<string>* parameters, Game * game) {
	if (game->getPlayer()->getCurrentRoom()->hasEnemy()) {
		int trueDamage = game->getPlayer()->getMainHand()->getDamage();
		int damage = trueDamage - game->getPlayer()->getCurrentRoom()->getEnemy()->getDefence();

		if (damage < 0) {
			damage = 0;
		}
		std::cout << "You hitted the enemy for " << damage << " damage" << std::endl;

		game->getPlayer()->getCurrentRoom()->getEnemy()->takeDamage(trueDamage);

		if (game->getPlayer()->getCurrentRoom()->getEnemy()->getHealth() == 0) {
			delete game->getPlayer()->getCurrentRoom()->getEnemy();
			game->getPlayer()->getCurrentRoom()->setEnemy(nullptr);

			std::cout << "The enemy has died!" << std::endl;
			std::cout << "You recieved 200xp!" << std::endl;
			game->getPlayer()->setExperience(game->getPlayer()->getExperience() + 200);

			int dropChance = 101;
			int random = RandomInt::generateInt(0, 100);

			if (dropChance >= random) {
				int weaponShield = RandomInt::generateInt(0, 1);
				if (weaponShield) {
					Weapon* weapon = game->getItemFactory()->CreateWeapon(game->getPlayer()->getLevel());

					std::cout << "The enemy dropped his weapon" << endl;
					std::cout << "Weapon: " << weapon->getName() << " L" << weapon->getLevel() << endl;
					std::cout << "Base Attack: " << weapon->getBaseDamage() << endl;
					std::cout << " -- Critical Chance: " << weapon->getCriticalChance() << endl;
					std::cout << " -- Miss Chance: " << weapon->getMissChance() << endl;
					std::cout << "Current Weapon: " << game->getPlayer()->getMainHand()->getName() << " L" << game->getPlayer()->getMainHand()->getLevel() << endl;
					std::cout << " -- Base Attack: " << game->getPlayer()->getMainHand()->getBaseDamage() << endl;
					std::cout << " -- Critical Chance: " << game->getPlayer()->getMainHand()->getCriticalChance() << "%" << endl;
					std::cout << " -- Miss Chance: " << game->getPlayer()->getMainHand()->getMissChance() << "%" << endl;
					bool incorrect = true;

					while (incorrect) {
						std::cout << "Would you like to equip this weapon? (y/n)";

						std::string input;
						getline(cin, input);

						if (input == "y") {
							delete game->getPlayer()->getMainHand();
							game->getPlayer()->setMainHand(weapon);
							incorrect = false;
						}
						else if (input == "n") {
							incorrect = false;
						}
						else {
							std::cout << "Wrong input" << endl;
						}
					}

				}
				else {
					Shield* shield = game->getItemFactory()->CreateShield(game->getPlayer()->getLevel());

					std::cout << "The enemy dropped his shield" << endl;
					std::cout << "Shield: " << shield->getName() << " L" << shield->getLevel() << endl;
					std::cout << " -- Base Defence: " << shield->getBaseDefence() << endl;
					std::cout << " -- Block Chance: " << shield->getBlockChance() << endl;
					std::cout << "Current Shield: " << game->getPlayer()->getOffHand()->getName() << " L" << game->getPlayer()->getOffHand()->getLevel() << endl;
					std::cout << " -- Base Defence: " << game->getPlayer()->getOffHand()->getBaseDefence() << endl;
					std::cout << " -- Block Chance: " << game->getPlayer()->getOffHand()->getBlockChance() << "%" << endl;
					bool incorrect = true;

					while (incorrect) {
						std::cout << "Would you like to equip this shield? (y/n)";

						std::string input;
						getline(cin, input);

						if (input == "y") {
							delete game->getPlayer()->getOffHand();
							game->getPlayer()->setOffHand(shield);
							incorrect = false;
						}
						else if (input == "n") {
							incorrect = false;
						}
						else {
							std::cout << "Wrong input" << endl;
						}
					}
				}
			}
		}
		else {
			std::cout << "The enemy is alive and attacks you back!" << std::endl;
			game->getPlayer()->TakeDamage(game->getPlayer()->getCurrentRoom()->getEnemy()->getDamage());
			std::cout << "Your current health is now " + game->getPlayer()->getCurrentHealth() << endl;
			if (game->getPlayer()->getCurrentHealth() < 0) {
				std::cout << "Your died... GAME OVER!" << endl;
				game->finish();

				cin.get();
			}
		}
	}
}
	string getWeaponName() const { return weapon.getName(); }
예제 #10
0
	bool operator()(Weapon thing)
	{
		return thing.getName() == name;
	}