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


C++ Plan::hasAttack方法代码示例

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


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

示例1: Action

lionheart::Action lionheart::MathewWarenski::wait(Plan p)
{
  if (p.hasAttack())
  {
    return p.attackEnemy();
  }
  return Action();
}
开发者ID:ksundberg,项目名称:CS1400,代码行数:8,代码来源:MathewWarenski.cpp

示例2: turn

lionheart::Action lionheart::MathewWarenski::playInFortDefend(
    Unit const &u, SituationReport report, Plan p)
{
  auto dir = setdefdir(u, report);
  if (dir != u.getFacing())
    return turn(dir);
  if (p.hasAttack())
  {
    return p.attackEnemy();
  }
  return Action();
}
开发者ID:ksundberg,项目名称:CS1400,代码行数:12,代码来源:MathewWarenski.cpp

示例3: turn

// function for game play
lionheart::Action lionheart::BrandonSmith::recommendAction(
  Unit const& u, SituationReport report, Plan p)
{
  ++numberofturns;
  auto loc = u.getLocation();
  find_kings(report);
  if (akingloc.col < 15) west = true;
  if (akingloc.col > 15) west = false;
  defpos(u, report);
  setdefdir(u, report);
  auto row = loc.row;
  auto col = loc.col;
  auto drow = defloc.row;
  auto dcol = defloc.col;

  if (u.getId() ==
      44) // give king bodyguard and prevents draw with non attacking armies
  {
    if (p.hasAttack()) return p.attackEnemy();
    if ((p.movesToAllyCrown() > 2) && (p.movesToEnemy() < 2))
      return p.moveToEnemy();
    if (p.movesToAllyCrown() > 2) return p.moveToAllyCrown();
  }

  if (u.getType() == CROWN) // rules for the king
  {
    if (p.hasAttack())
    {
      return p.attackEnemy();
    }
    if (mykingstupid(report))
    {
      if (west)
      {
        defloc.row = 14;
        defloc.col = 4;
        if ((row != 14) || (col != 4))
        {
          return p.moveToLocation(14, 4);
        }
      }
      if (!west)
      {
        defloc.row = 14;
        defloc.col = 25;
        if ((row != 14) || (col != 25))
        {
          return p.moveToLocation(14, 25);
        }
      }
    }

    if ((safe(row, col, report)) && (numberofturns < 300))
    {
      return turn(defdir);
    }

    if ((!safe(row, col, report)) || (enemyinthebox(report)))
    {
      ++whattodo;
      switch (whattodo)
      {
      case 0:
      case 1:
      case 2:
      case 3:
        if ((west) &&
            (report.things[19][3].type == lionheart::SituationReport::ALLY))
        {
          return p.moveToLocation(19, 2);
        }
        if ((west) &&
            (report.things[10][3].type == lionheart::SituationReport::ALLY))
        {
          return p.moveToLocation(10, 2);
        }
        if ((west))
        {
          return p.moveToLocation(19, 2);
        }
        if ((!west) &&
            (report.things[19][26].type == lionheart::SituationReport::ALLY))
        {
          return p.moveToLocation(19, 27);
        }
        if ((!west) &&
            (report.things[10][26].type == lionheart::SituationReport::ALLY))
        {
          return p.moveToLocation(10, 27);
        }
        if (!west)
        {
          return p.moveToLocation(19, 27);
        }
        break;
      case 4:
        if (akingloc.row > 15)
        {
          if (p.hasAttack())
//.........这里部分代码省略.........
开发者ID:Gnomehax,项目名称:CS1400,代码行数:101,代码来源:BrandonSmith.cpp


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