This commit is contained in:
		
							
								
								
									
										18
									
								
								src/Core/Exceptions/CreatureException.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/Core/Exceptions/CreatureException.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
#ifndef CREATURELIB_CREATUREEXCEPTION_HPP
 | 
			
		||||
#define CREATURELIB_CREATUREEXCEPTION_HPP
 | 
			
		||||
 | 
			
		||||
#include <exception>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
class CreatureException : std::exception{
 | 
			
		||||
    std::string _error;
 | 
			
		||||
public:
 | 
			
		||||
    CreatureException(std::string error){}
 | 
			
		||||
 | 
			
		||||
    const char *what() const noexcept override {
 | 
			
		||||
        return _error.c_str();
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif //CREATURELIB_CREATUREEXCEPTION_HPP
 | 
			
		||||
							
								
								
									
										12
									
								
								src/Core/Exceptions/NotImplementedException.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/Core/Exceptions/NotImplementedException.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef CREATURELIB_NOTIMPLEMENTEDEXCEPTION_HPP
 | 
			
		||||
#define CREATURELIB_NOTIMPLEMENTEDEXCEPTION_HPP
 | 
			
		||||
 | 
			
		||||
#include "CreatureException.hpp"
 | 
			
		||||
 | 
			
		||||
class NotImplementedException : CreatureException{
 | 
			
		||||
public:
 | 
			
		||||
    NotImplementedException(std::string error) : CreatureException(error){}
 | 
			
		||||
    NotImplementedException() : CreatureException("Not Implemented"){}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif //CREATURELIB_NOTIMPLEMENTEDEXCEPTION_HPP
 | 
			
		||||
							
								
								
									
										11
									
								
								src/Core/Exceptions/NotReachableException.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/Core/Exceptions/NotReachableException.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
#ifndef CREATURELIB_NOTREACHABLEEXCEPTION_HPP
 | 
			
		||||
#define CREATURELIB_NOTREACHABLEEXCEPTION_HPP
 | 
			
		||||
 | 
			
		||||
#include "CreatureException.hpp"
 | 
			
		||||
 | 
			
		||||
class NotReachableException : CreatureException{
 | 
			
		||||
public:
 | 
			
		||||
    NotReachableException() : CreatureException("Not Reachable"){};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif //CREATURELIB_NOTREACHABLEEXCEPTION_HPP
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
#include <exception>
 | 
			
		||||
#include "Statistic.hpp"
 | 
			
		||||
#include "../GenericTemplates.cpp"
 | 
			
		||||
#include "Exceptions/NotReachableException.hpp"
 | 
			
		||||
 | 
			
		||||
namespace CreatureLib::Core{
 | 
			
		||||
    template <class T>
 | 
			
		||||
@@ -41,7 +42,7 @@ namespace CreatureLib::Core{
 | 
			
		||||
                case MagicalDefense: return _magicalDefense;
 | 
			
		||||
                case Speed: return _speed;
 | 
			
		||||
            }
 | 
			
		||||
            throw std::exception();
 | 
			
		||||
            throw NotReachableException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        inline void SetStat(Statistic stat, T value){
 | 
			
		||||
@@ -53,7 +54,7 @@ namespace CreatureLib::Core{
 | 
			
		||||
                case MagicalDefense: _magicalDefense = value;
 | 
			
		||||
                case Speed: _speed = value;
 | 
			
		||||
            }
 | 
			
		||||
            throw std::exception();
 | 
			
		||||
            throw NotReachableException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        inline void IncreaseStatBy(Statistic stat, T amount){
 | 
			
		||||
@@ -65,7 +66,7 @@ namespace CreatureLib::Core{
 | 
			
		||||
                case MagicalDefense: _magicalDefense += amount;
 | 
			
		||||
                case Speed: _speed += amount;
 | 
			
		||||
            }
 | 
			
		||||
            throw std::exception();
 | 
			
		||||
            throw NotReachableException();
 | 
			
		||||
        }
 | 
			
		||||
        inline void DecreaseStatBy(Statistic stat, T amount){
 | 
			
		||||
            switch (stat){
 | 
			
		||||
@@ -76,7 +77,7 @@ namespace CreatureLib::Core{
 | 
			
		||||
                case MagicalDefense: _magicalDefense -= amount;
 | 
			
		||||
                case Speed: _speed -= amount;
 | 
			
		||||
            }
 | 
			
		||||
            throw std::exception();
 | 
			
		||||
            throw NotReachableException();
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user