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


C++ BitField::getMaxSet方法代码示例

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


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

示例1: attack

std::string BTCombatant::attack(BTCombatant *defender, bool melee, const std::string &cause, const std::string &effect, const BTDice &damageDice, IShort chanceXSpecial, IShort xSpecial, int &numAttacksLeft, int &activeNum, int toHitBonus /*= 0*/)
{
 int hits = 0;
 int totalDamage = 0;
 bool dead = false;
 bool totalDrain = false;
 BitField finalSpecial;
 while ((defender->isAlive()) && (numAttacksLeft > 0))
 {
  int roll = BTDice(1, 20).roll();
  if ((1 != roll) && ((20 == roll) || (roll + toHit + toHitBonus >= defender->ac)))
  {
   ++hits;
   int damage = 0;
   BitField special;
   damage = damageDice.roll();
   for (int i = 0; i < dmgBonus.size(); i++)
    damage += dmgBonus[i]->apply(melee);
   if ((BTEXTRADAMAGE_NONE != xSpecial) && (BTDice(1, 100).roll() <= chanceXSpecial))
    special.set(xSpecial);
   if (damage < 0)
    damage = 0;
   totalDamage += damage;
   if (defender->takeHP(damage))
   {
    dead = true;
    defender->deactivate(activeNum);
   }
   else
   {
    useAutoCombatSkill(melee, special);
    int maxSpecial = special.getMaxSet();
    if (maxSpecial > -1)
    {
     std::string specialText;
     for (int i = 0; i <= maxSpecial; ++i)
     {
      if (!special.isSet(i))
       continue;
      if (defender->savingThrow(BTSAVE_DIFFICULTY))
      {
       special.clear(i);
       continue;
      }
      switch(i)
      {
       case BTEXTRADAMAGE_POISON:
        defender->status.set(BTSTATUS_POISONED);
        break;
       case BTEXTRADAMAGE_LEVELDRAIN:
        if (defender->drainLevel())
        {
         totalDrain = true;
         defender->deactivate(activeNum);
        }
        break;
       case BTEXTRADAMAGE_INSANITY:
        defender->status.set(BTSTATUS_INSANE);
        break;
       case BTEXTRADAMAGE_AGED:
        if (defender->age())
        {
         defender->deactivate(activeNum);
        }
        break;
       case BTEXTRADAMAGE_POSSESSION:
        defender->status.set(BTSTATUS_POSSESSED);
        break;
       case BTEXTRADAMAGE_PARALYSIS:
        defender->status.set(BTSTATUS_PARALYZED);
        break;
       case BTEXTRADAMAGE_STONED:
        defender->status.set(BTSTATUS_STONED);
        defender->deactivate(activeNum);
        break;
       case BTEXTRADAMAGE_CRITICALHIT:
        defender->status.set(BTSTATUS_DEAD);
        defender->deactivate(activeNum);
        break;
       case BTEXTRADAMAGE_ITEMZOT:
        if (!defender->drainItem(5))
        {
         special.clear(BTEXTRADAMAGE_ITEMZOT);
        }
        break;
       case BTEXTRADAMAGE_POINTPHAZE:
        if (!defender->takeSP(5))
        {
         special.clear(BTEXTRADAMAGE_POINTPHAZE);
        }
        break;
       default:
        break;
      }
     }
     finalSpecial |= special;
    }
   }
  }
  --numAttacksLeft;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: specialAttack

std::string BTCombatant::specialAttack(BTCombatant *defender, const BTDice &damageDice, IShort xSpecial, bool farRange, int &activeNum, bool *saved /*= NULL*/)
{
 int totalDamage = 0;
 bool dead = false;
 bool totalDrain = false;
 BitField special;
 totalDamage = damageDice.roll();
 if (farRange)
  totalDamage = totalDamage / 2;
 bool saveResult = false;
 if (saved)
  saveResult = *saved;
 else
  saveResult = defender->savingThrow(BTSAVE_DIFFICULTY);
 if (saveResult)
 {
  totalDamage = totalDamage / 2;
 }
 else if (BTEXTRADAMAGE_NONE != xSpecial)
 {
  special.set(xSpecial);
 }
 if (defender->takeHP(totalDamage))
 {
  dead = true;
  defender->deactivate(activeNum);
 }
 else
 {
  int maxSpecial = special.getMaxSet();
  if (maxSpecial > -1)
  {
   for (int i = 0; i <= maxSpecial; ++i)
   {
    if (!special.isSet(i))
     continue;
    switch(i)
    {
     case BTEXTRADAMAGE_POISON:
      defender->status.set(BTSTATUS_POISONED);
      break;
     case BTEXTRADAMAGE_LEVELDRAIN:
      if (defender->drainLevel())
      {
       totalDrain = true;
       defender->deactivate(activeNum);
      }
      break;
     case BTEXTRADAMAGE_INSANITY:
      defender->status.set(BTSTATUS_INSANE);
      break;
     case BTEXTRADAMAGE_AGED:
      if (defender->age())
      {
       defender->deactivate(activeNum);
      }
      break;
     case BTEXTRADAMAGE_POSSESSION:
      defender->status.set(BTSTATUS_POSSESSED);
      break;
     case BTEXTRADAMAGE_PARALYSIS:
      defender->status.set(BTSTATUS_PARALYZED);
      break;
     case BTEXTRADAMAGE_STONED:
      defender->status.set(BTSTATUS_STONED);
      defender->deactivate(activeNum);
      break;
     case BTEXTRADAMAGE_CRITICALHIT:
      defender->status.set(BTSTATUS_DEAD);
      defender->deactivate(activeNum);
      break;
     case BTEXTRADAMAGE_ITEMZOT:
      if (!defender->drainItem(5))
      {
       special.clear(BTEXTRADAMAGE_ITEMZOT);
      }
      break;
     case BTEXTRADAMAGE_POINTPHAZE:
      if (!defender->takeSP(5))
      {
       special.clear(BTEXTRADAMAGE_POINTPHAZE);
      }
      break;
     default:
      break;
    }
   }
  }
 }
 std::string text;
 std::string defenderName;
 text = defenderName = defender->getName();
 if (saveResult == false)
 {
  if (totalDamage > 0)
  {
   text += " takes ";
   char tmp[20];
   sprintf(tmp, "%d", totalDamage);
   text += tmp;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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