1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 14:07:46 +00:00

costcheck refactored to has/consumeResources

This commit is contained in:
NotAdam 2019-04-04 22:16:00 +11:00
parent 89f60df2c8
commit 48870f72b6
2 changed files with 16 additions and 7 deletions

View file

@ -267,7 +267,7 @@ void Sapphire::Action::Action::execute()
assert( m_pSource );
// subtract costs first, if somehow the caster stops meeting those requirements cancel the cast
if( !costCheck( true ) )
if( !consumeResources() )
{
interrupt();
return;
@ -405,7 +405,7 @@ bool Sapphire::Action::Action::playerPrecheck( Entity::Player& player )
// validate range
if( !costCheck() )
if( !hasResources() )
return false;
return true;
@ -433,11 +433,6 @@ bool Sapphire::Action::Action::isComboAction() const
return m_actionData->actionCombo == lastActionId;
}
bool Sapphire::Action::Action::costCheck( bool subtractCosts )
{
return primaryCostCheck( subtractCosts ) && secondaryCostCheck( subtractCosts );
}
bool Sapphire::Action::Action::primaryCostCheck( bool subtractCosts )
{
switch( m_primaryCostType )
@ -485,4 +480,14 @@ bool Sapphire::Action::Action::secondaryCostCheck( bool subtractCosts )
{
// todo: these need to be mapped
return true;
}
bool Sapphire::Action::Action::hasResources()
{
return primaryCostCheck( false ) && secondaryCostCheck( false );
}
bool Sapphire::Action::Action::consumeResources()
{
return primaryCostCheck( true ) && secondaryCostCheck( true );
}

View file

@ -54,6 +54,10 @@ namespace Sapphire::Action
*/
bool costCheck( bool subtractCosts = false );
bool hasResources();
bool consumeResources();
/*!
* @brief Checks if the action *may* target a resident instead of an actor
* @return true if the target *may* be a resident and not an actor, otherwise false.