/*Copyright (C) 2010-2012 Duncan Deveaux

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/Sound/SoundEngine.hpp"

#include "Engines/Physics/PhysicsObject.hpp"
#include "Animation/AnimationGroup.hpp"

//PhysicsObject's inheriting class representing a player.
//It can move, jump, attack, ...
class Player : public PhysicsObject
{
    public:
        Player();
        Player(const std::string &name, float health, float strength, float speed, float jumpEnergy);
        
        void loadGraphics(TextureManager &textureManager);
        void draw();
        
        void update();
        void updateGraphics(float frameTime);
        
        virtual void act(float frameTime) = 0;
        
        //Engines methods
        void setPhysicsEngine(PhysicsEngine &physicsEngine);
        const PhysicsEngine &getPhysicsEngine() const;
        
        void setSoundEngine(SoundEngine &soundEngine);
        const SoundEngine &getSoundEngine() const;
        
        //Get and set methods
        const std::string &getName() const;
        
        void setHealth(float health);
        float getHealth() const;
        
        void setStrength(float strength);
        float getStrength() const;
        
        void setSpeed(float speed);
        float getSpeed() const;
        
        void setJumpEnergy(float jumpEnergy);
        float getJumpEnergy() const;
        
        //PhysicsObject virtual methods
        void setXPosition(float position);
        float getXPosition() const;
        
        void setYPosition(float position);
        float getYPosition() const;
        
        float getXOrigin() const;
        float getYOrigin() const;
        
        float getWidth() const;
        float getHeight() const;
        
        void takeAHit(float strength, int side);
    
    protected:
        void move(int direction, float frameTime);
        void stop();
        
        void jump();
        void attack();
        
        std::string m_name;
        
        float m_health; //Health in life (/100)
        float m_strength; //Strength in health impact
        float m_speed; //Speed in pixels / second
        float m_jumpEnergy; //Jump energy in pixels / second
        
        Condition m_condition;
        
        AnimationGroup m_animations;
        int m_currentPosition;
        
        PhysicsEngine *m_physicsEngine;
        SoundEngine *m_soundEngine;
};

#endif
