Exemplo n.º 1
0
bool shgPhases::inactivateEntireSearch(int phaseId) {
   // returns true iff a redraw should take place
   shg &theShg = getByID(phaseId);
   const bool isCurrShg = (getCurrentId() == phaseId);
   const bool anyChanges = theShg.inactivateAll(isCurrShg);

   return isCurrShg && anyChanges;
}
Exemplo n.º 2
0
	size_t ObjectSet::newObjectID() {
		size_t id;

		for (id=LIBGENS_LEVEL_START_ID_GENERATION; id<LIBGENS_LEVEL_END_ID_GENERATION; id++) {
			Object *object=getByID(id);
			if (!object) break;
		}

		return id;
	}
Exemplo n.º 3
0
bool shgPhases::configNode(int phaseId, unsigned nodeId,
			   bool active, shgRootNode::evaluationState es, bool deferred)
{
   // returns true iff a redraw should take place
   shg &theShg = getByID(phaseId);
   const bool isCurrShg = (getCurrentId() == phaseId);

   const shg::configNodeResult changes =
      theShg.configNode(nodeId, active, es, deferred, isCurrShg, true);
         // true --> rethink if needed

   return isCurrShg && (changes != shg::noChanges);
}
Exemplo n.º 4
0
bool shgPhases::addEdge(int phaseId, unsigned fromId, unsigned toId,
			shgRootNode::refinement theRefinement,
			const char *label, // used only for shadow nodes, else NULL
			bool rethinkFlag) {
   // The evaluationState param decides whether to explicitly expand
   // the "to" node.  Rethinks the entire layout of the shg
   // Returns true iff a redraw should take place
   shg &theShg = getByID(phaseId);
   const bool isCurrShg = (getCurrentId() == phaseId);
   theShg.addEdge(fromId, toId, theRefinement, label, isCurrShg, rethinkFlag);

   return isCurrShg;
}
Exemplo n.º 5
0
bool shgPhases::addNode(int phaseId, unsigned nodeId,
			bool active,
			shgRootNode::evaluationState es,
            bool deferred,
			const pdstring &label, const pdstring &fullInfo,
			bool rootNodeFlag) {
   // returns true iff a redraw should take place
   shg &theShg = getByID(phaseId);
   const bool isCurrShg = (getCurrentId() == phaseId);

   theShg.addNode(nodeId, active, es, deferred,
                    label, fullInfo, rootNodeFlag, isCurrShg);

   return isCurrShg;
}
Exemplo n.º 6
0
bool AnimalDatabase::insertData(unsigned int ID, const Animal & data) {

    const auto map = getByID();

    if (ID != 1 && map.count(ID - 1) == 0) {
        return false;
    }

    for (auto & a : m_data) {

        if (a.second.getID() >= ID) a.second.setID(a.second.getID() + 1);

    }

    m_data.emplace(data.getName(), data);

    return true;

}
Exemplo n.º 7
0
	//! Return the matching Pulsar if exists or Q_NULLPTR.
	//! @param id The Pulsar id
	virtual StelObjectP searchByID(const QString &id) const
	{
		return qSharedPointerCast<StelObject>(getByID(id));
	}
Exemplo n.º 8
0
bool AnimalDatabase::save() {

    const auto dataByID = getByID();

    QFile file(k_path);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
        qCritical() << "Could not open" << k_path;
        return false;
    }

    QXmlStreamWriter writer(&file);

    writer.setAutoFormatting(true);
    writer.writeStartDocument();
    writer.writeStartElement("animals");

    for (const auto & p : dataByID) {

        const auto data = p.second;
        writer.writeStartElement(k_name);
        writer.writeAttribute("id", QString::number(p.first));

        writer.writeStartElement("name");
        writer.writeCharacters(data.getName());
        writer.writeEndElement();

        {
            writer.writeStartElement("type");

            writer.writeStartElement("primary");
            writer.writeCharacters(data.primaryType());
            writer.writeEndElement();
            writer.writeStartElement("secondary");
            writer.writeCharacters(data.secondaryType());
            writer.writeEndElement();

            writer.writeEndElement();
        }

        {
            writer.writeStartElement("basestats");

            writer.writeStartElement("hp");
            writer.writeCharacters(QString::number(data.baseHP()));
            writer.writeEndElement();
            writer.writeStartElement("attack");
            writer.writeCharacters(QString::number(data.baseAttack()));
            writer.writeEndElement();
            writer.writeStartElement("defense");
            writer.writeCharacters(QString::number(data.baseDefense()));
            writer.writeEndElement();
            writer.writeStartElement("speed");
            writer.writeCharacters(QString::number(data.baseSpeed()));
            writer.writeEndElement();
            writer.writeStartElement("specialattack");
            writer.writeCharacters(QString::number(data.baseSpecialAttack()));
            writer.writeEndElement();
            writer.writeStartElement("specialdefense");
            writer.writeCharacters(QString::number(data.baseSpecialDefense()));
            writer.writeEndElement();
            writer.writeStartElement("xp");
            writer.writeCharacters(QString::number(data.baseXP()));
            writer.writeEndElement();

            writer.writeEndElement();
        }

        {
            writer.writeStartElement("moves");
            for (const auto & move : data.moves()) {

                writer.writeStartElement("move");

                writer.writeStartElement("name");
                writer.writeCharacters(move.second);
                writer.writeEndElement();
                writer.writeStartElement("level");
                writer.writeCharacters(QString::number(move.first));
                writer.writeEndElement();

                writer.writeEndElement();

            }
            writer.writeEndElement();
        }

        {
            writer.writeStartElement("evolutions");
            for (const auto & evolution : data.evolutions()) {

                writer.writeStartElement("evolution");

                writer.writeStartElement("name");
                writer.writeCharacters(std::get<0>(evolution));
                writer.writeEndElement();
                writer.writeStartElement("method");
                writer.writeCharacters(std::get<1>(evolution));
                writer.writeEndElement();
                writer.writeStartElement("value");
                writer.writeCharacters(QString::number(std::get<2>(evolution)));
                writer.writeEndElement();

                writer.writeEndElement();

            }
            writer.writeEndElement();
        }

        writer.writeEndElement();

    }

    writer.writeEndElement();
    writer.writeEndDocument();

    return true;

}
Exemplo n.º 9
0
void shgPhases::nodeInformation(int phaseId, int nodeId,
				const shg_node_info &theNodeInfo) {
   // in response to a middle-mouse-click...
   shg &theShg = getByID(phaseId);
   theShg.nodeInformation(nodeId, theNodeInfo);
}