当前位置: 首页>>代码示例>>C++>>正文


C++ Armor::getName方法代码示例

本文整理汇总了C++中Armor::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Armor::getName方法的具体用法?C++ Armor::getName怎么用?C++ Armor::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Armor的用法示例。


在下文中一共展示了Armor::getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: equip

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;
	}
}
开发者ID:adhe223,项目名称:Nethack_Clone,代码行数:17,代码来源:Player.cpp

示例2: getViewScreen

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;
//.........这里部分代码省略.........
开发者ID:Yorick666,项目名称:The-Elder-Codes,代码行数:101,代码来源:MenuInventory.cpp


注:本文中的Armor::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。