Fleet::Variant::Variant(const DataNode &node) { weight = (node.Size() < 2) ? 1 : static_cast<int>(node.Value(1)); for(const DataNode &child : node) { int n = 1; if(child.Size() > 1 && child.Value(1) >= 1.) n = static_cast<int>(child.Value(1)); ships.insert(ships.end(), n, GameData::Ships().Get(child.Token(0))); } }
void ConditionSet::Add(const DataNode &node) { if(node.Size() == 2) Add(node.Token(0), node.Token(1)); else if(node.Size() == 3) Add(node.Token(0), node.Token(1), node.Value(2)); else if(node.Size() == 1 && node.Token(0) == "never") entries.emplace_back("", "!=", 0); else if(node.Size() == 1 && (node.Token(0) == "and" || node.Token(0) == "or")) { children.emplace_back(); children.back().Load(node); } }
void ConditionSet::Add(const DataNode &node) { if(node.Size() == 2) { if(!Add(node.Token(0), node.Token(1))) node.PrintTrace("Unrecognized condition expression:"); } else if(node.Size() == 3) { if(!Add(node.Token(0), node.Token(1), node.Value(2))) node.PrintTrace("Unrecognized condition expression:"); } else if(node.Size() == 1 && node.Token(0) == "never") entries.emplace_back("", "!=", 0); else if(node.Size() == 1 && (node.Token(0) == "and" || node.Token(0) == "or")) { children.emplace_back(); children.back().Load(node); } else node.PrintTrace("Unrecognized condition expression:"); }