void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender) { mAlchemy->setPotionName(mNameEdit->getCaption()); int count = mAlchemy->countPotionsToBrew(); count = std::min(count, mBrewCountEdit->getValue()); createPotions(count); }
vector<Item*> ItemFactory::createItems(const int itemLevel, const int dungeonSize) { vector<Item*> _items; // Create all seperate item types vector<Item*> _lights = createLights(Random::getRandomNumber(static_cast<int>(ceil(dungeonSize / MIN_LIGHT_ROLL_MODIFIER)), static_cast<int>(ceil(dungeonSize / MAX_LIGHT_ROLL_MODIFIER)))); vector<Item*> _potions = createPotions(Random::getRandomNumber(static_cast<int>(ceil(dungeonSize / MIN_POTION_ROLL_MODIFIER)), static_cast<int>(ceil(dungeonSize / MAX_POTION_ROLL_MODIFIER)))); vector<Item*> _specialItems = createSpecialItems(); vector<Item*> _armours = createArmours(itemLevel, Random::getRandomNumber(static_cast<int>(ceil(dungeonSize / MIN_ARMOUR_ROLL_MODIFIER)), static_cast<int>(ceil(dungeonSize / MAX_ARMOUR_ROLL_MODIFIER)))); vector<Item*> _weapons = createWeapons(itemLevel, Random::getRandomNumber(static_cast<int>(ceil(dungeonSize / MIN_WEAPON_ROLL_MODIFIER)), static_cast<int>(ceil(dungeonSize / MAX_WEAPON_ROLL_MODIFIER)))); // Reserve enough space for the parent container and move all item container elements to parent container _items.reserve(_items.size() + _lights.size() + _potions.size() + _specialItems.size() + _armours.size() +_weapons.size()); move(_lights.begin(), _lights.end(), back_inserter(_items)); move(_potions.begin(), _potions.end(), back_inserter(_items)); move(_specialItems.begin(), _specialItems.end(), back_inserter(_items)); move(_armours.begin(), _armours.end(), back_inserter(_items)); move(_weapons.begin(), _weapons.end(), back_inserter(_items)); // Shuffle the parent container so the container is truly random shuffle(_items.begin(), _items.end(), Random::getRandomEngine()); return _items; }