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>()); } }
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(); }
void PlantMgr::deletePlant(const QString& theId) { if( !(getPlant(theId).isNull()) ) m_plantList.remove(theId); }