#pragma once

#include "../Assets/Artisan.h"
#include "../Assets/Item.h"
#include "Human.h"

namespace mechanics {
	class Artisan : public Human {
	public:
		Artisan(Human &generatefrom, const std::string &type, Animator &cloth);

		std::string type() const {
			return mType;
		}

		void type(const std::string &type) {
			mType=type;
		}

		virtual std::string info() {
			std::stringstream out;

			out << "Level " << level() << " " << type() << " XP " << xp() << std::endl
				<< ((gender() == Gender::male) ? "Male" : "Female") << std::endl
				<< stat();

			return out.str();
		}
		virtual void levelUp() {
			if(mLevel + 1 > assets::constants::leveling::artisanLvlCap) {
				return;
			}

			Human::levelUp();
		}

		void setAnimation(Direction direction, std::string animationID, bool isLooping=true, float speed=1) {
			Object::animator.setAnimation(direction, animationID, isLooping, speed);
			Human::animatorHair.setAnimation(direction, animationID, isLooping, speed);
			cloth->setAnimation(direction, animationID, isLooping, speed);
		}

		void setDirection(Direction direction, std::string animationID) {
			Object::animator.setDirection(direction, animationID);
			Human::animatorHair.setDirection(direction, animationID);
			cloth->setDirection(direction, animationID);
		}

		assets::Item *crafting() const {
			return mCrafting;
		}

		unsigned totalCraftTime() const {
			return mTotal;
		}

		unsigned craftProgress() const {
			return mTotal-(mFinish-currentGameTime);
		}

		unsigned lastPaymentCheck() const;

		void lastPaymentCheck(unsigned value);

		void beginCrafting(std::string ID);

		void checkCraft();

		virtual void checkAction();

		virtual void Killed(Attacker *attacker, BaseWeapon *weapon);

		// clothing for artisans
		Animator *cloth;
	protected:
		std::string mType;
	

		assets::Item *mCrafting;
		unsigned mFinish;
		unsigned mTotal;
		unsigned mLastPaymentCheck;
	};
}
