//goes through list of bunnies and kills those over 10 and not radioactive or over 50 if radioactive void BunnyWorld::killOldBunnies() { //point tracker to first 'dummy' bunny Bunny* tracker = m_first; //point next bunny to first 'real' bunny Bunny* nextBunny = tracker->m_next; /* The program keeps bunnies in age order so only goes through the bunnies that are aged 10 or over to decide whether to kill it or not */ while (nextBunny->getAge() >= 10) { //if bunny is 50, always dies. If not radioactive, is 10 by the while condition so kill if (nextBunny->getAge() == 50 || !nextBunny->getRadioactive()){ tracker->m_next = nextBunny->m_next; killBunny(nextBunny); } else tracker = tracker->m_next; nextBunny = tracker->m_next; /* if we've reached the end of the list (no bunnies under 10) break out of while loop. It's implemented like this because the while loop requires a getAge call which doesn't work for the nullptr pointer. */ if (nextBunny==nullptr){ break; } } }
//Constructor BunnyWorld::BunnyWorld(): m_population(0), m_radioactivePopulation(0), m_first(new Bunny) { //clears output.txt when world created. std::ofstream outputFile("output.txt"); outputFile.close(); std::ofstream populationFile("population.txt"); populationFile.close(); //Set up an empty first bunny to start the program m_first->m_next = nullptr; Bunny* tracker = m_first; //create first 5 bunnies for (int i = 0; i < 5; i++) { int color = getRandomColor(); Bunny* newBunny = new Bunny(color); newBunny->m_next = nullptr; tracker->m_next = newBunny; tracker = newBunny; m_population++; if (newBunny->getRadioactive()){ m_radioactivePopulation++; } } printBunnies(); }
bool PluginEars::OnEarsMove(Bunny * b, int l, int r) { /* Get Setting */ QByteArray Friend = b->GetPluginSetting(GetName(), "Friend", "").toByteArray(); QString FName(Friend); /* If setting set */ if(!Friend.isEmpty()) { Bunny *f = BunnyManager::GetBunny(this, Friend); /* If aFriend is found */ if(f) { /* If this bunny is the Friend's friend */ if(f->GetPluginSetting(GetName(), "Friend", "").toByteArray() == b->GetID()) { /* If the friend is connected and not sleeping */ if(f->IsConnected() && !f->IsSleeping()) { /* Debug LogDebug(QString("Friend: %1 Ears to: %2 - %3").arg(FName).arg(l).arg(r)); */ /* Send A packet to move the ears */ AmbientPacket p; p.SetEarsPosition(l, r); f->SendPacket(p); } } } } return true; }
int main(int argc, char** argv) { glutInit(&argc, argv); //h.getMatrix().identity(); cam.sete(0, 0, 20); cam.setd(0, 0, 0); cam.setup(0, 1, 0); cam.constructMatrix(); cam.inverse(); hop.parseFile("bunny.xyz"); hop.moveToOrigin(); hop.fitToWindow(); draco.parseFile("dragon.xyz"); draco.moveToOrigin(); draco.fitToWindow(); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutInitWindowSize(window_width, window_height); glutCreateWindow("Rasterizer"); loadData(); glutReshapeFunc(reshapeCallback); glutDisplayFunc(displayCallback); glutKeyboardFunc(keyboardCallback); glutSpecialFunc(processSpecialKeys); glutMainLoop(); }
//go through each bunny and increase age by 1 void BunnyWorld::increaseAge() const { Bunny* tracker = m_first->m_next; while (tracker != nullptr) { tracker->increaseAge(); tracker = tracker->m_next; } }
int main(){ setup(); for(int i = 0; i < bunnyList.getSize(); i++){ Bunny *currentBunny = bunnyList.get(i); std::cout << currentBunny->toString() << "\n"; } system("Pause"); return 0; }
//Check to see if there is a Bunny with age >=2 and not radioactive in the population bool BunnyWorld::isEligibleMale() const { Bunny* tracker = m_first->m_next; while(tracker!=nullptr){ if (tracker->getAge() >= 2 && tracker->getSex() == bny::male && !tracker->getRadioactive()){ return true; } tracker = tracker->m_next; } return false; }
//one female rabbit can create another rabbit from father //better to have reference because it must be initialize //pointer to created object to avoid shallow copy Bunny* Bunny::CreateNew(const Bunny& Father){ //use new to allocate object in heap Bunny *tmp = new Bunny; tmp->m_pMother = this; if(&Father!=nullptr) tmp->m_pFather = const_cast<Bunny*>(&Father); //not uni- one rabbit can has many children //but every one has a mother and father tmp->setFeatures(); m_vDescendants.push_back(tmp); return tmp; }
void PluginWizzflux::analyse(QNetworkReply* networkReply) { if (!networkReply->error()) { Bunny * bunny = BunnyManager::GetBunny(this, networkReply->parent()->property("BunnyID").toByteArray()); if(bunny) { QString message = QString::fromUtf8(networkReply->readAll()); if(message != "" && bunny->IsIdle()) { message = "ST "+message.toAscii()+"\nPL "+QString::number(qrand() % 8).toAscii()+"\nMW\n"; bunny->SendPacket(MessagePacket(message.toAscii())); } } } networkReply->deleteLater(); networkReply->parent()->deleteLater(); }
/* For every female aged 2 or older and not radioactive, give birth to a new bunny of the same color and place it at the end of the list */ void BunnyWorld::giveBirth() { Bunny* tracker = m_first->m_next; //find last bunny in list. Bunny* findEnd = tracker; while (findEnd->m_next != nullptr){ findEnd = findEnd->m_next; } //go through whole list while (tracker != nullptr){ if (tracker->getSex() == bny::female && tracker->getAge() >=2 && !tracker->getRadioactive()){ int color = tracker->getColor(); Bunny* newBunny = new Bunny(color); //put new bunny at end of list newBunny->m_next = nullptr; findEnd->m_next = newBunny; findEnd = newBunny; m_population++; if (newBunny->getRadioactive()){ m_radioactivePopulation++; } } tracker = tracker->m_next; } }
ApiManager::ApiAnswer * ApiManager::ProcessBunnyVioletApiCall(QString const& request, HTTPRequest const& hRequest) { QStringList list = QString(request).split('/', QString::SkipEmptyParts); if(list.size() < 3) return new ApiManager::ApiError(QString("Malformed Bunny Api Call : %1").arg(hRequest.toString())); QString serial = hRequest.GetArg("sn"); Bunny * b = BunnyManager::GetBunny(serial.toAscii()); if(list.size() == 3) { return b->ProcessVioletApiCall(hRequest); } else return new ApiManager::ApiError(QString("Malformed Plugin Api Call : %1").arg(hRequest.toString())); }
void PluginClock::OnCron(Bunny *, QVariant) { QMapIterator<Bunny *, QString> i(bunnyList); while (i.hasNext()) { i.next(); Bunny * b = i.key(); QString voice = i.value(); if(b->IsIdle()) { QString hour = QDateTime::currentDateTime().toString("h"); QByteArray file; if(voice == "tts") // if(voice == "French") // file = TTSManager::CreateNewSound("Il est " + hour + " heure", "julie"); // if(voice == "English") file = TTSManager::CreateNewSound("It is " + hour + " O'Clock", "heather"); else { // Fetch available files QDir * dir = GetLocalHTTPFolder(); if(dir) { dir->cd(voice); dir->cd(hour); QStringList list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot); if(list.count()) { file = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, hour, list.at(qrand()%list.count()))); } delete dir; } else LogError("Invalid GetLocalHTTPFolder()"); } if(!file.isNull()) { QByteArray message = "MU "+file+"\nPL 3\nMW\n"; b->SendPacket(MessagePacket(message)); } } } }
bool PluginRFID::HttpRequestHandle(HTTPRequest & request) { QString uri = request.GetURI(); if (uri.startsWith("/vl/rfid.jsp")) { QString serialnumber = request.GetArg("sn"); QString tagId = request.GetArg("t"); SetSettings("global/LastTag", tagId); Ztamp * z = ZtampManager::GetZtamp(this, tagId.toAscii()); Bunny * b = BunnyManager::GetBunny(this, serialnumber.toAscii()); b->SetPluginSetting(GetName(), "LastTag", tagId); if (z->OnRFID(b)) return true; if (b->OnRFID(QByteArray::fromHex(tagId.toAscii()))) return true; } return false; }
bool PluginAuth::ProxyAuth(XmppHandler * xmpp, QByteArray const& data, Bunny ** pBunny, QByteArray &) { QRegExp rx("<response[^>]*>(.*)</response>"); if (rx.indexIn(data) != -1) { // Response message contains username, catch it to create the Bunny QByteArray authString = QByteArray::fromBase64(rx.cap(1).toAscii()); rx.setPattern("username=[\'\"]([^\'\"]*)[\'\"]"); if (rx.indexIn(authString) != -1) { QByteArray bunnyID = rx.cap(1).toAscii(); Bunny * bunny = BunnyManager::GetBunny(bunnyID); bunny->Authenticated(); bunny->SetXmppHandler(xmpp); *pBunny = bunny; } else LogWarning(QString("Unable to parse response message : %1").arg(QString(authString))); } return true; }
void PluginGmail::readData(const QHttpResponseHeader &resp) { Bunny * bunny = BunnyManager::GetBunny(this, http.property("BunnyID").toByteArray()); if (resp.statusCode() != 200) { http.abort(); LogWarning("Connection error"); } else { xml.addData(http.readAll()); while (!xml.atEnd()) { xml.readNext(); if (xml.isStartElement()) { currentTag = xml.name().toString(); } else if (xml.isCharacters() && !xml.isWhitespace()) { if (currentTag == "fullcount") { bool ok; emailsCount = xml.text().toString().toInt(&ok); if (emailsCount > 0) { bunny->SendPacket(AmbientPacket(AmbientPacket::Service_Nose, 1)); } else { bunny->SendPacket(AmbientPacket(AmbientPacket::Service_Nose, 0)); } } } } } }
/* Converts x new bunnies to be radioactive mutant vampire bunnies at randomwhere x is the current number of radioactive mutant vampire bunnies. */ void BunnyWorld::infectBunnies() { //sets the number of bunnies to infect int numberToInfect = m_radioactivePopulation; Bunny* tracker = m_first->m_next; //if every bunny is radioactive, break out of the while loop while (numberToInfect > 0 && m_radioactivePopulation != m_population){ //if you've reached the end of the list, go back to the start if(tracker == nullptr){ tracker = m_first->m_next; } /*if the bunny isn't already radioactive, decide whether it should be infected at random with a probability equal to radioactivepopulation/totalpopulation */ if (!tracker->getRadioactive() && shouldInfect()){ tracker->setRadioactive(true); m_radioactivePopulation++; numberToInfect --; } tracker = tracker->m_next; } }
ApiManager::ApiAnswer * ApiManager::ProcessBunnyApiCall(Account const& account, QString const& request, HTTPRequest const& hRequest) { QStringList list = QString(request).split('/', QString::SkipEmptyParts); if(list.size() < 2) return new ApiManager::ApiError(QString("Malformed Bunny Api Call : %1").arg(hRequest.toString())); QByteArray const& bunnyID = list.at(0).toAscii(); if(!account.HasBunnyAccess(bunnyID)) return new ApiManager::ApiError("Access denied to this bunny"); Bunny * b = BunnyManager::GetBunny(bunnyID); if(list.size() == 2) { QByteArray const& functionName = list.at(1).toAscii(); return b->ProcessApiCall(account, functionName, hRequest); } else if(list.size() == 3) { PluginInterface * plugin = PluginManager::Instance().GetPluginByName(list.at(1).toAscii()); if(!plugin) return new ApiManager::ApiError(QString("Unknown Plugin : '%1'").arg(list.at(1))); if(b->HasPlugin(plugin)) { QByteArray const& functionName = list.at(2).toAscii(); return plugin->ProcessBunnyApiCall(b, account, functionName, hRequest); } else return new ApiManager::ApiError("This plugin is not enabled for this bunny"); } else return new ApiManager::ApiError(QString("Malformed Plugin Api Call : %1").arg(hRequest.toString())); }
int BunnySociety::StartBunnySociety() { /// Starting the society printing. BunnySocietyPrint(); //do { { ///If a bunny becomes older than 10 years old, it dies. ///Radioactive vampire bunnies do not die until they reach age 50. /// First step increase everybody's age. cout << "------------------------------------------------------" << endl; Bunny bunny = bunnyDatastructure.GetBunnyONIndex(0); do { int bunnyAge = bunny.GetAge(); if (bunny.GetBunnyMutant()) { if (bunnyAge >= 50) { cout << "Mutant Bunny Killed :::" + bunny.GetBunnyName() << endl; bunnyDatastructure.DeleteBunny(bunny); } } else { if (bunnyAge >= 10) { cout << "Bunny Killed :::" + bunny.GetBunnyName() << endl; bunnyDatastructure.DeleteBunny(bunny); } } } while ( (bunnyDatastructure.GetNextBunny() != null)); { } cout << "------------------------------------------------------" << endl; } { ///Each turn afterwards the bunnies age 1 year. for (int i = 0; i < bunnyDatastructure.GetCount(); i++) { Bunny bunny = bunnyDatastructure.GetBunnyONIndex(i); bunny.PrintBunnyObject(); } } //thread(100); } //while (bunnyDatastructure.GetCount() > 0); return 0; }
void PluginAuth::HttpRequestAfter(HTTPRequest & request) { QString uri = request.GetURI(); if (uri.startsWith("/vl/bc.jsp")) { QString version = request.GetArg("v"); QString serialnumber = request.GetArg("m").remove(':'); Bunny * b = BunnyManager::GetBunny(this, serialnumber.toAscii()); if(b->GetBunnyPassword() == "" && GetSettings("global/authMethod", QString()).toString() == "patched") { LogDebug("Analyzing firmware for patch application"); long address1 = 0x00011A4A; long address2 = 0x00011A91; long address3 = 0x00011AC9; long address4 = 0x00011AEB; int size1 = 3; int size2 = 6; int size3 = 6; int size4 = 1; QByteArray origin1; QByteArray origin2; QByteArray origin3; QByteArray origin4; QByteArray patch1; QByteArray patch2; QByteArray patch3; QByteArray patch4; origin1.append((char)0x02).append((char)0x3D).append((char)0x00); origin2.append((char)0x02).append((char)0x3D).append((char)0x00).append((char)0x02).append((char)0x3E).append((char)0x00); origin3.append((char)0x02).append((char)0x3D).append((char)0x00).append((char)0x02).append((char)0x3E).append((char)0x00); origin4.append((char)0x02); patch1.append((char)0x07).append((char)0x00).append((char)0x05); patch2.append((char)0x04).append((char)0x05).append((char)0x04).append((char)0x05).append((char)0x04).append((char)0x05); patch3.append((char)0x04).append((char)0x05).append((char)0x04).append((char)0x05).append((char)0x04).append((char)0x05); patch4.append((char)0x01); bool patch = true; if(request.reply.indexOf(origin1, address1) != address1) { LogDebug("Part 1 : KO"); patch = false; } else LogDebug("Part 1 : OK"); if(request.reply.indexOf(origin2, address2) != address2) { LogDebug("Part 2 : KO"); patch = false; } else LogDebug("Part 2 : OK"); if(request.reply.indexOf(origin3, address3) != address3) { LogDebug("Part 3 : KO"); patch = false; } else LogDebug("Part 3 : OK"); if(request.reply.indexOf(origin4, address4) != address4) { LogDebug("Part 4 : KO"); patch = false; } else LogDebug("Part 4 : OK"); if(patch) { LogDebug("Patching firmware"); request.reply.replace(address1, size1, patch1); request.reply.replace(address2, size2, patch2); request.reply.replace(address3, size3, patch3); request.reply.replace(address4, size4, patch4); } } } }
bool PluginAuth::FullAuth(XmppHandler * xmpp, QByteArray const& data, Bunny ** pBunny, QByteArray & answer) { switch(xmpp->currentAuthStep) { case 0: // We should receive <?xml version='1.0' encoding='UTF-8'?><stream:stream to='ojn.soete.org' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>" if(data.startsWith("<?xml version='1.0' encoding='UTF-8'?>")) { // Send an auth Request answer.append("<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='2173750751' from='xmpp.nabaztag.com' version='1.0' xml:lang='en'>"); answer.append("<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><register xmlns='http://violet.net/features/violet-register'/></stream:features>"); xmpp->currentAuthStep = 1; return true; } LogError("Bad Auth Step 0, disconnect"); return false; case 1: { // Bunny request a register <iq type='get' id='1'><query xmlns='violet:iq:register'/></iq> IQ iq(data); if(iq.IsValid() && iq.Type() == IQ::Iq_Get && iq.Content() == "<query xmlns='violet:iq:register'/>") { // Send the request answer = iq.Reply(IQ::Iq_Result, "from='" + xmpp->GetXmppDomain() + "' %1 %4", "<query xmlns='violet:iq:register'><instructions>Choose a username and password to register with this server</instructions><username/><password/></query>"); xmpp->currentAuthStep = 100; return true; } // Bunny request an auth <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/> if(data.startsWith("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/>")) { // Send a challenge // <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>...</challenge> // <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>nonce="random_number",qop="auth",charset=utf-8,algorithm=md5-sess</challenge> QByteArray nonce = QByteArray::number((unsigned int)qrand()); QByteArray challenge = "nonce=\"" + nonce + "\",qop=\"auth\",charset=utf-8,algorithm=md5-sess"; answer.append("<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" + challenge.toBase64() + "</challenge>"); xmpp->currentAuthStep = 2; return true; } LogError("Bad Auth Step 1, disconnect"); return false; } case 2: { // We should receive <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>...</response> QRegExp rx("<response[^>]*>(.*)</response>"); if (rx.indexIn(data) != -1) { QByteArray authString = QByteArray::fromBase64(rx.cap(1).toAscii()).replace((char)0, ""); // authString is like : username="",nonce="",cnonce="",nc=,qop=auth,digest-uri="",response=,charset=utf-8 // Parse values rx.setPattern("username=\"([^\"]*)\",nonce=\"([^\"]*)\",cnonce=\"([^\"]*)\",nc=([^,]*),qop=auth,digest-uri=\"([^\"]*)\",response=([^,]*),charset=utf-8"); if(rx.indexIn(authString) != -1) { QByteArray const username = rx.cap(1).toAscii(); Bunny * bunny = BunnyManager::GetBunny(username); // Check if we want to bypass auth for this bunny if((GlobalSettings::Get("Config/StandAloneAuthBypass", false)) == true && (username == GlobalSettings::GetString("Config/StandAloneAuthBypassBunny"))) { // Send success LogInfo("Sending success instead of password verification"); answer.append("<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"); bunny->Authenticating(); *pBunny = bunny; // Auth OK, set current bunny xmpp->currentAuthStep = 4; return true; } QByteArray const password = bunny->GetBunnyPassword(); QByteArray const nonce = rx.cap(2).toAscii(); QByteArray const cnonce = rx.cap(3).toAscii().append((char)0); // cnonce have a dummy \0 at his end :( QByteArray const nc = rx.cap(4).toAscii(); QByteArray const digest_uri = rx.cap(5).toAscii(); QByteArray const bunnyResponse = rx.cap(6).toAscii(); if(bunnyResponse == ComputeResponse(username, password, nonce, cnonce, nc, digest_uri, "AUTHENTICATE")) { // Send challenge back // <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>...</challenge> // rspauth=... QByteArray const rspAuth = "rspauth=" + ComputeResponse(username, password, nonce, cnonce, nc, digest_uri, ""); answer.append("<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" + rspAuth.toBase64() + "</challenge>"); bunny->Authenticating(); *pBunny = bunny; // Auth OK, set current bunny xmpp->currentAuthStep = 3; return true; } LogError("Authentication failure for bunny"); // Bad password, send failure and restart auth answer.append("<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>"); xmpp->currentAuthStep = 0; return true; } } LogError("Bad Auth Step 2, disconnect"); return false; } case 3: // We should receive <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/> if(data.startsWith("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>")) { // Send success answer.append("<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"); xmpp->currentAuthStep = 4; return true; } LogError("Bad Auth Step 3, disconnect"); return false; case 4: // We should receive <?xml version='1.0' encoding='UTF-8'?> if(data.startsWith("<?xml version='1.0' encoding='UTF-8'?>")) { // Send success answer.append("<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1331400675' from='xmpp.nabaztag.com' version='1.0' xml:lang='en'>"); answer.append("<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><required/></bind><unbind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></stream:features>"); xmpp->currentAuthStep = 0; (*pBunny)->Authenticated(); (*pBunny)->SetXmppHandler(xmpp); // Bunny is now authenticated return true; } LogError("Bad Auth Step 4, disconnect"); return false; case 100: // Register Bunny { // We should receive <iq to='xmpp.nabaztag.com' type='set' id='2'><query xmlns="violet:iq:register"><username>0019db01dbd7</username><password>208e6d83bfb2</password></query></iq> IQ iqAuth(data); if(iqAuth.IsValid() && iqAuth.Type() == IQ::Iq_Set) { QByteArray content = iqAuth.Content(); QRegExp rx("<query xmlns=\"violet:iq:register\"><username>([0-9a-f]*)</username><password>([0-9a-f]*)</password></query>"); if(rx.indexIn(content) != -1) { QByteArray user = rx.cap(1).toAscii(); QByteArray password = rx.cap(2).toAscii(); Bunny * bunny = BunnyManager::GetBunny(user); if(bunny->SetBunnyPassword(ComputeXor(user,password))) { answer.append(iqAuth.Reply(IQ::Iq_Result, "%1 %2 %3 %4", content)); xmpp->currentAuthStep = 1; return true; } LogError(QString("Password already set for bunny : ").append(QString(user))); return false; } } LogError("Bad Register, disconnect"); return false; } default: LogError("Unknown Auth Step, disconnect"); return false; } }
Bunny* Bunny::Init(){ Bunny *tmp = new Bunny; tmp->setFeatures(); return tmp; }
void PluginClock::OnCron(Bunny *, QVariant) { QMapIterator<Bunny *, QString> i(bunnyList); while (i.hasNext()) { i.next(); Bunny * b = i.key(); QString voice = i.value(); if(b->IsIdle()) { QString hour = QDateTime::currentDateTime().toString("h"); QByteArray file; QDir * dir = GetLocalHTTPFolder(); QStringList list; if(voice == "tts") file = TTSManager::CreateNewSound("Sono le ore " + hour, "chiara"); else { // Fetch available files if(dir) { dir->cd(voice); dir->cd(hour); list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot); if(list.count()) { file = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, hour, list.at(qrand()%list.count()))); } delete dir; } else LogError("Invalid GetLocalHTTPFolder()"); } if(!file.isNull()) { QByteArray fileR; dir = GetLocalHTTPFolder(); if (voice == "tts") voice = "violet"; // Directory default respiration TTS QString respiration = "respiration"; // Directory respiration if (dir->cd(voice) && dir->cd(respiration)) { list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot); if(list.count()) { fileR = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, respiration, list.at(qrand()%list.count()))); } } QByteArray message; if(!fileR.isNull()) message = "MU "+fileR+"\nPL 3\nMW\nMU "+file+"\nPL 3\nMW\nMU "+fileR+"\nPL 3\nMW\n"; else message = "MU "+file+"\nPL 3\nMW\n"; b->SendPacket(MessagePacket(message)); } } } }
bool FemaleBunny::CanBreedWith(const Bunny& other) const { return this->age >= 2 && other.GetGender() == BunnyGender::Male && other.GetAge() >= 2; }