Пример #1
0
bool SpellHistory::HasCharge(uint32 chargeCategoryId) const
{
    if (!sSpellCategoryStore.LookupEntry(chargeCategoryId))
        return true;

    // Check if the spell is currently using charges (untalented warlock Dark Soul)
    int32 maxCharges = GetMaxCharges(chargeCategoryId);
    if (maxCharges <= 0)
        return true;

    auto itr = _categoryCharges.find(chargeCategoryId);
    return itr == _categoryCharges.end() || int32(itr->second.size()) < maxCharges;
}
Пример #2
0
bool SpellHistory::HasCharge(SpellCategoryEntry const* chargeCategoryEntry) const
{
    if (!chargeCategoryEntry)
        return true;

    // Check if the spell is currently using charges (untalented warlock Dark Soul)
    int32 maxCharges = GetMaxCharges(chargeCategoryEntry);
    if (maxCharges <= 0)
        return true;

    auto itr = _categoryCharges.find(chargeCategoryEntry->ID);
    return itr == _categoryCharges.end() || int32(itr->second.size()) < maxCharges;
}
Пример #3
0
bool SpellHistory::ConsumeCharge(uint32 chargeCategoryId)
{
    if (!sSpellCategoryStore.LookupEntry(chargeCategoryId))
        return false;

    int32 chargeRecovery = GetChargeRecoveryTime(chargeCategoryId);
    if (chargeRecovery > 0 && GetMaxCharges(chargeCategoryId) > 0)
    {
        Clock::time_point recoveryStart;
        std::deque<ChargeEntry>& charges = _categoryCharges[chargeCategoryId];
        if (charges.empty())
            recoveryStart = Clock::now();
        else
            recoveryStart = charges.back().RechargeEnd;

        charges.emplace_back(recoveryStart, std::chrono::milliseconds(chargeRecovery));
        return true;
    }

    return false;
}