Exemplo n.º 1
0
std::vector<ColoredString> Engine::getActorsBenethPlayersFeet()
{
    std::vector< ColoredString > items;
    MapPtr map = getWorld().getCurrentMap();

    if ( map )
    {
        std::function<bool(amarlon::ActorPtr)> filterFun = [&](ActorPtr a) -> bool
        {
            return a != Actor::Player;
        };

        std::vector<ActorPtr> actorsOnTile = map->getActors(Actor::Player->getX(), Actor::Player->getY(), &filterFun);

        for ( ActorPtr actor : actorsOnTile )
        {
            std::string msg = actor->getName();

            PickablePtr pickable = actor->getFeature<Pickable>();
            if ( pickable && pickable->getAmount() > 1 )
            {
                msg = msg + " (" + std::to_string(pickable->getAmount()) + ")";
            }

            items.push_back( ColoredString( msg, TCODColor::darkLime ) );
        }
    }

    return items;
}
Exemplo n.º 2
0
TEST_F(MapTest, addActor)
{
  MapPtr map = mapGateway.fetch(MapId::GameStart);
  ActorPtr actor = Actor::create(ActorType::HealthPotion,1,1);

  map->addActor(actor);
  auto actors = map->getActors(1,1);

  EXPECT_EQ(actors.size(), (size_t)1);
  EXPECT_TRUE( actors.front().get() == actor.get() );
}
Exemplo n.º 3
0
void Engine::updateAis()
{
    MapPtr map = getWorld().getCurrentMap();
    if ( map )
    {
        std::function<bool(ActorPtr)> filter = [](ActorPtr a)->bool{ return a->hasFeature<Ai>();};
        auto ais = map->getActors( &filter );
        for ( ActorPtr actor : ais )
        {
            actor->getFeature<Ai>()->update();
        }
    }
}
Exemplo n.º 4
0
Target SingleNeighbourSelector::select(std::function<bool (amarlon::ActorPtr)>* filterFun)
{
  Engine::instance().gui().setStatusMessage( _selectionMessage );
  TCODConsole::root->flush();
  MapPtr map = Actor::Player->getMap();
  ActorPtr player = Actor::Player;

  int dx(0), dy(0);

  DirectionSelector dSelector;
  dSelector.select(dx, dy);

  Engine::instance().gui().clearStatusMessage();
  Engine::instance().render();

  assert( map != nullptr );

  return Target(map->getActors(player->getX()+dx, player->getY()+dy, filterFun),
                player->getX()+dx,
                player->getY()+dy);
}