From 6b1f7e7a45ebc04f39bb54edc85fbe9c9d0659e7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 31 Jul 2014 18:15:39 +0200 Subject: Renamed "select..." methods to "set..." and better IsValidEffect() function. --- src/BlockEntities/BeaconEntity.cpp | 58 ++++++++------------------------------ src/BlockEntities/BeaconEntity.h | 8 +++--- 2 files changed, 15 insertions(+), 51 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index c94783ba8..55c5ccb7f 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -64,54 +64,18 @@ char cBeaconEntity::CalculatePyramidLevel(void) bool cBeaconEntity::IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLevel) { - if (a_Effect == cEntityEffect::effNoEffect) + switch (a_Effect) { - return true; + case cEntityEffect::effRegeneration: return (a_BeaconLevel >= 4); + case cEntityEffect::effStrength: return (a_BeaconLevel >= 3); + case cEntityEffect::effResistance: return (a_BeaconLevel >= 2); + case cEntityEffect::effJumpBoost: return (a_BeaconLevel >= 2); + case cEntityEffect::effSpeed: return (a_BeaconLevel >= 1); + case cEntityEffect::effHaste: return (a_BeaconLevel >= 1); + case cEntityEffect::effNoEffect: return true; } - switch (a_BeaconLevel) - { - case 4: - { - // Beacon level 4 - if (a_Effect == cEntityEffect::effRegeneration) - { - return true; - } - } - case 3: - { - // Beacon level 3 - if (a_Effect == cEntityEffect::effStrength) - { - return true; - } - } - case 2: - { - // Beacon level 2 - switch (a_Effect) - { - case cEntityEffect::effResistance: - case cEntityEffect::effJumpBoost: - { - return true; - } - } - } - case 1: - { - // Beacon level 1 - switch (a_Effect) - { - case cEntityEffect::effSpeed: - case cEntityEffect::effHaste: - { - return true; - } - } - } - } + LOGD("%s: Invalid beacon effect: %d", __FUNCTION__, (int)a_Effect); return false; } @@ -119,7 +83,7 @@ bool cBeaconEntity::IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLe -bool cBeaconEntity::SelectPrimaryEffect(cEntityEffect::eType a_Effect) +bool cBeaconEntity::SetPrimaryEffect(cEntityEffect::eType a_Effect) { if (!IsValidEffect(a_Effect, m_BeaconLevel)) { @@ -140,7 +104,7 @@ bool cBeaconEntity::SelectPrimaryEffect(cEntityEffect::eType a_Effect) -bool cBeaconEntity::SelectSecondaryEffect(cEntityEffect::eType a_Effect) +bool cBeaconEntity::SetSecondaryEffect(cEntityEffect::eType a_Effect) { if (!IsValidEffect(a_Effect, m_BeaconLevel)) { diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h index cc8ee8ad2..0d7150aef 100644 --- a/src/BlockEntities/BeaconEntity.h +++ b/src/BlockEntities/BeaconEntity.h @@ -55,11 +55,11 @@ public: cEntityEffect::eType GetPrimaryEffect(void) const { return m_PrimaryEffect; } cEntityEffect::eType GetSecondaryEffect(void) const { return m_SecondaryEffect; } - /** Select the primary effect. Returns false when the effect is invalid.*/ - bool SelectPrimaryEffect(cEntityEffect::eType a_Effect); + /** Sets the primary effect. Returns false when the effect is invalid. */ + bool SetPrimaryEffect(cEntityEffect::eType a_Effect); - /** Select the secondary effect. Returns false when the effect is invalid. */ - bool SelectSecondaryEffect(cEntityEffect::eType a_Effect); + /** Sets the secondary effect. Returns false when the effect is invalid. */ + bool SetSecondaryEffect(cEntityEffect::eType a_Effect); /** Calculate the amount of layers the pyramid below the beacon has. */ char CalculatePyramidLevel(void); -- cgit v1.2.3