Example #1
0
  void sresource_manager::_assign_deck(Puppet& inPuppet, string inName, string inSpells, int inUseCount) {
    Deck* lDeck = 0;
    // does the puppet already have this deck? are we updating?
    inPuppet.removeDeck(inName);

    lDeck = new Deck(&inPuppet);
    lDeck->setName(inName);
    lDeck->setUseCount(inUseCount);

    // parse the spells
    // expected format: {"Spell1 Name","...","Spell16 Name"}
    inSpells = inSpells.erase(0,1).erase(inSpells.size()-2,1); // strip out the {}
    vector<string> elements = Utility::split(inSpells, ',');
    assert(elements.size() == 16);
    vector<string>::iterator itr;
    for (itr = elements.begin(); itr != elements.end(); ++itr) {
      //~ std::cout << "assigning spell to deck " << (*itr) << "\n";
      // strip out the quotes
      std::string spellname = (*itr).erase(0,1).erase((*itr).size()-2,1);
      //(*itr).pop_front();
      lDeck->_assignSpell(getSpell(spellname));
    }

    inPuppet.addDeck(lDeck);
    lDeck = 0;
  }