/*Copyright (C) 2010 Deveaux Duncan

This file is part of Hikou no mizu.

Hikou no mizu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Hikou no mizu is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DEF_PLAYER
#define DEF_PLAYER

#include <string>
#include "Condition.hpp"

#include "Engines/Physics/PhysicsEngine.hpp"
#include "Engines/Physics/PhysicsObject.hpp"
#include "Engines/Graphics/GraphicsEngine.hpp"
#include "Animation/AnimationManager.hpp"

//PhysicsObject's inheriting class representing a player.
//It can move, jump, attack, ...
class Player : public PhysicsObject
{
    public:
        Player(const std::string &name, int maxHealth, int maxEnergy, int strength, int speed);
        
        void update(const sf::Input &keys);
        
        void move(int direction);
        void stop();
        
        void jump();
        
        void attack();
        void takeAHit(int strength);
        
        //Graphics methods
        void startRendering(GraphicsEngine &renderEngine);
        void stopRendering(GraphicsEngine &renderEngine);
        
        //Physics methods
        void setPhysicsEngine(PhysicsEngine *physicsEngine);
        PhysicsEngine *getPhysicsEngine() const;
        
        //Get and set methods
        std::string getName() const;
        
        void setMaxHealth(int maxHealth);
        int getMaxHealth() const;
        void setHealth(int health);
        int getHealth() const;
        
        void setMaxEnergy(int maxEnergy);
        int getMaxEnergy() const;
        void setEnergy(int energy);
        int getEnergy() const;
        
        void setStrength(int strength);
        int getStrength() const;
        void setSpeed(int speed);
        int getSpeed() const;
        void setDirection(int direction);
        int getDirection() const;
        
        //Events methods
        bool healthAltered();
        bool energyAltered();
        
        //PhysicsObject virtual methods
        const sf::Vector2f &getOrigin() const;
        
        float getWidth() const;
        float getHeight() const;
        
        void setXPosition(float position);
        float getXPosition() const;
        void setYPosition(float position);
        float getYPosition() const;
    
    private:
        std::string m_name;
        int m_health;
        int m_maxHealth;
        int m_oldHealth; //Used in simplist events system
        
        int m_energy;
        int m_maxEnergy;
        int m_oldEnergy; //Used in simplist events system
        
        int m_basicJumpEnergy;
        int m_jumpEnergy;
        
        int m_strength;
        int m_speed;
        Condition m_condition;
        AnimationManager m_animationsManager;
        PhysicsEngine *m_physicsEngine;
};

#endif