コード例 #1
0
QSharedPointer<Plant>                         PlantMgr::addPlant(const QString& theKind, const QString& theID, SysError& theErr){
    if(getPlant(theID).isNull())   {
        QSharedPointer<Plant> thePlantRef = createPlant(theKind, theErr);
        thePlantRef->setID(theID);
        m_plantList.insert(theID, thePlantRef);
        return(thePlantRef);
    }
    else    {
        qWarning()<<"Error attempt to add a plant with an already present ID: "<< theID;
        return(QSharedPointer<Plant>());
    }

}
コード例 #2
0
ファイル: BaseAI.cpp プロジェクト: siggame/MegaMinerAI-5
bool BaseAI::startTurn()
{
  static bool initialized = false;
  int count = 0;
  count = getPlantCount();
  plants.clear();
  plants.resize(count);
  for(int i = 0; i < count; i++)
  {
    plants[i] = Plant(getPlant(i));
  }
  if(!initialized)
  {
    initialized = true;
    init();
  }
  return run();
}
コード例 #3
0
void                            PlantMgr::deletePlant(const QString& theId) {
    if( !(getPlant(theId).isNull()) )
        m_plantList.remove(theId);
}