Skip to content

Commit

Permalink
[Spell/Main] Add IsUsableP / IsUsablePP
Browse files Browse the repository at this point in the history
  • Loading branch information
ghr74 committed Jul 25, 2018
1 parent 59cc639 commit 7837b7a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions HeroLib/Class/Spell/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,32 @@ function Spell:IsUsable()
return IsUsableSpell(self.SpellID)
end

-- Check if the spell is Usable (by resources) in predicted mode
function Spell:IsUsableP(Offset)
local CostInfos = GetSpellPowerCost(self.SpellID)
local Usable = true
if #CostInfos > 0 then
local i = 1
while ( Usable == true ) and ( i <= #CostInfos ) do
local CostInfo = CostInfos[i]
if ( Player.PredictedResourceMap[CostInfo.type]() < ( CostInfo.minCost + ( Offset and Offset or 0 ) ) ) then Usable = false end
i = i + 1
end
end
return Usable
end

-- Only checks IsUsableP against the primary resource for pooling
function Spell:IsUsablePP(Offset)
local CostInfos = GetSpellPowerCost(self.SpellID)
if #CostInfos > 0 then
local CostInfo = CostInfos[1]
return ( Player.PredictedResourceMap[CostInfo.type]() >= ( CostInfo.minCost + ( Offset and Offset or 0 ) ) )
else
return true
end
end

-- Check if the spell is in the Spell Learned Cache.
function Spell:IsLearned()
return Cache.Persistent.SpellLearned[self:Type()][self:ID()] or false
Expand Down

0 comments on commit 7837b7a

Please sign in to comment.