//
//  World.hpp
//  Game
//
//  Created by Darvydas on 24/01/2019.
//

#ifndef STATISTIC_BAR_H
#define STATISTIC_BAR_H

#include "Utils/json/Manager.hpp"
#include "Game/GameScene/World/Objects/Base.hpp"
#include "cocos2d.h"

using namespace cocos2d;

namespace Game
{
    class CStatisticBar: public Objects::CBase {

	public:
		enum Type
		{
			MORE_THEN, // need to increase progress
			LESS_THEN, // need to reduce progress
			DONT_CARE
		};
        
    public:
        
        static CStatisticBar* create(const rapidjson::Value& statsBar);

		void setInitialProgress(Type type, float greenProgress, float redProgress);
		void setProgress(float progress);
		void addValue(int value);
		void update(float deltaTime);
		void setInitialValue(int value);
		void calcInitialProgress(int value, bool forceDontCare);
        
    private:
		void createVisualElements(const rapidjson::Value& statsBar);

	public:
		Type m_Type;
		std::string m_Name;

		ProgressTimer* m_ProgressTimerRed;
		ProgressTimer* m_ProgressTimerGreen;

		Sprite* m_BarFrame;
		Sprite* m_BarRed;
		Sprite* m_BarGreen;
		Sprite* m_Seperator;

		Sprite* m_StatsHigher;
		Sprite* m_StatsLower;

		float m_InitialProgress;
		float m_TargetProgress;
		int m_CurrentValue;
    };
}

#endif /* STATISTIC_BAR_H */
