Пример #1
0
void MenuInventory::applyItemSetBonuses(ItemStack *equipped) {
	// calculate bonuses. added by item sets
	std::vector<int> set;
	std::vector<int> quantity;
	std::vector<int>::iterator it;

	for (int i=0; i<MAX_EQUIPPED; i++) {
		int item_id = equipped[i].item;
		it = std::find(set.begin(), set.end(), items->items[item_id].set);
		if (items->items[item_id].set > 0 && it != set.end()) {
			quantity[std::distance(set.begin(), it)] += 1;
		}
		else if (items->items[item_id].set > 0) {
			set.push_back(items->items[item_id].set);
			quantity.push_back(1);
		}
	}
	// apply item set bonuses
	ItemSet temp_set;
	for (unsigned k=0; k<set.size(); k++) {
		temp_set = items->item_sets[set[k]];
		unsigned bonus_counter = 0;
		for (bonus_counter=0; bonus_counter<temp_set.bonus.size(); bonus_counter++) {
			if (temp_set.bonus[bonus_counter].requirement > quantity[k]) continue;
			applyBonus(&temp_set.bonus[bonus_counter]);
		}
	}
}
Пример #2
0
void ClassicBonus::deleteBonus(Hero* hero)
{
	if (m_canBeRemoved)
	{
		m_value *= -1;
		applyBonus(hero);
	}
}
Пример #3
0
void BonusManager::tryToApplyBonus(int bonus)
{
	if(bonuses_[bonus]->canApply(GameManager::get()->currentPlayer())){
		applyBonus(GameManager::get()->currentPlayer(),bonuses_[bonus]->type(), bonuses_[bonus]->tier());
// 		qDebug() <<"applied " << bonus;
		
	}
	emit bonusesUpdated();
}
Пример #4
0
void MenuInventory::applyItemStats(ItemStack *equipped) {
	const std::vector<Item> &pc_items = items->items;

	// reset additional values
	stats->dmg_melee_min_add = stats->dmg_melee_max_add = 0;
	stats->dmg_ment_min_add = stats->dmg_ment_max_add = 0;
	stats->dmg_ranged_min_add = stats->dmg_ranged_max_add = 0;
	stats->absorb_min_add = stats->absorb_max_add = 0;

	// apply stats from all items
	for (int i=0; i<MAX_EQUIPPED; i++) {
		int item_id = equipped[i].item;
		const Item &item = pc_items[item_id];

		// apply base stats
		stats->dmg_melee_min_add += item.dmg_melee_min;
		stats->dmg_melee_max_add += item.dmg_melee_max;
		stats->dmg_ranged_min_add += item.dmg_ranged_min;
		stats->dmg_ranged_max_add += item.dmg_ranged_max;
		stats->dmg_ment_min_add += item.dmg_ment_min;
		stats->dmg_ment_max_add += item.dmg_ment_max;

		// set equip flags
		for (unsigned j=0; j<item.equip_flags.size(); ++j) {
			stats->equip_flags.insert(item.equip_flags[j]);
		}

		// apply absorb bonus
		stats->absorb_min_add += item.abs_min;
		stats->absorb_max_add += item.abs_max;

		// apply various bonuses
		unsigned bonus_counter = 0;
		while (bonus_counter < item.bonus.size()) {
			applyBonus(&item.bonus[bonus_counter]);
			bonus_counter++;
		}

		// add item powers
		if (item.power > 0) {
			stats->powers_list_items.push_back(item.power);
			if (stats->effects.triggered_others)
				powers->activateSinglePassive(stats,item.power);
		}

	}
}
Пример #5
0
void MenuInventory::applyItemStats() {
	if (items->items.empty())
		return;

	// reset additional values
	for (size_t i = 0; i < DAMAGE_TYPES.size(); ++i) {
		stats->dmg_min_add[i] = stats->dmg_max_add[i] = 0;
	}
	stats->absorb_min_add = stats->absorb_max_add = 0;

	// apply stats from all items
	for (int i=0; i<MAX_EQUIPPED; i++) {
		int item_id = inventory[EQUIPMENT].storage[i].item;
		const Item &item = items->items[item_id];

		// apply base stats
		for (size_t j = 0; j < DAMAGE_TYPES.size(); ++j) {
			stats->dmg_min_add[j] += item.dmg_min[j];
			stats->dmg_max_add[j] += item.dmg_max[j];
		}

		// set equip flags
		for (unsigned j=0; j<item.equip_flags.size(); ++j) {
			stats->equip_flags.insert(item.equip_flags[j]);
		}

		// apply absorb bonus
		stats->absorb_min_add += item.abs_min;
		stats->absorb_max_add += item.abs_max;

		// apply various bonuses
		unsigned bonus_counter = 0;
		while (bonus_counter < item.bonus.size()) {
			applyBonus(&item.bonus[bonus_counter]);
			bonus_counter++;
		}

		// add item powers
		if (item.power > 0) {
			stats->powers_list_items.push_back(item.power);
			if (stats->effects.triggered_others)
				powers->activateSinglePassive(stats,item.power);
		}

	}
}