Fix changing stat falling through enum and throwing exception.
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		@@ -7,8 +7,7 @@
 | 
			
		||||
#include "Statistic.hpp"
 | 
			
		||||
 | 
			
		||||
namespace CreatureLib::Core {
 | 
			
		||||
    template <class T>
 | 
			
		||||
    class StatisticSet {
 | 
			
		||||
    template <class T> class StatisticSet {
 | 
			
		||||
    protected:
 | 
			
		||||
        T _health;
 | 
			
		||||
        T _physicalAttack;
 | 
			
		||||
@@ -39,8 +38,8 @@ namespace CreatureLib::Core {
 | 
			
		||||
                case MagicalAttack: return _magicalAttack;
 | 
			
		||||
                case MagicalDefense: return _magicalDefense;
 | 
			
		||||
                case Speed: return _speed;
 | 
			
		||||
                default: throw NotReachableException();
 | 
			
		||||
            }
 | 
			
		||||
            throw NotReachableException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        inline void SetStat(Statistic stat, T value) {
 | 
			
		||||
@@ -51,8 +50,8 @@ namespace CreatureLib::Core {
 | 
			
		||||
                case MagicalAttack: _magicalAttack = value;
 | 
			
		||||
                case MagicalDefense: _magicalDefense = value;
 | 
			
		||||
                case Speed: _speed = value;
 | 
			
		||||
                default: throw NotReachableException();
 | 
			
		||||
            }
 | 
			
		||||
            throw NotReachableException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        inline void IncreaseStatBy(Statistic stat, T amount) {
 | 
			
		||||
@@ -63,8 +62,8 @@ namespace CreatureLib::Core {
 | 
			
		||||
                case MagicalAttack: _magicalAttack += amount;
 | 
			
		||||
                case MagicalDefense: _magicalDefense += amount;
 | 
			
		||||
                case Speed: _speed += amount;
 | 
			
		||||
                default: throw NotReachableException();
 | 
			
		||||
            }
 | 
			
		||||
            throw NotReachableException();
 | 
			
		||||
        }
 | 
			
		||||
        inline void DecreaseStatBy(Statistic stat, T amount) {
 | 
			
		||||
            switch (stat) {
 | 
			
		||||
@@ -74,10 +73,10 @@ namespace CreatureLib::Core {
 | 
			
		||||
                case MagicalAttack: _magicalAttack -= amount;
 | 
			
		||||
                case MagicalDefense: _magicalDefense -= amount;
 | 
			
		||||
                case Speed: _speed -= amount;
 | 
			
		||||
                default: throw NotReachableException();
 | 
			
		||||
            }
 | 
			
		||||
            throw NotReachableException();
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif //CREATURELIB_STATISTICSET_HPP
 | 
			
		||||
#endif // CREATURELIB_STATISTICSET_HPP
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user