#pragma once

#include <iostream>

#include "../Assets/Item.h"
#include "../Basic.h"
#include "../Animator.h"

namespace mechanics {
	class Human;
	class Artisan;

	class Item {
	public:
		Item(assets::Item &provider, Animator &given_animator);

		assets::Item &provider() const;

		virtual std::string name() const;

		virtual bool isEquipable();

		virtual bool isActive() const;

		float lastUsedTime() const;

		virtual bool canBeUsed() const;

		virtual void use(float cooldownMod = 0.0f);

		void wielder(Human *human);

		Human *wielder() const;

		virtual bool canParry() const;

		virtual bool canBlock() const;

		virtual float attackDamage() const;

		virtual float attackRange() const;

		virtual float cooldown() const;

		virtual float attackPrecision() const;

		virtual float parryPrecision() const;

		virtual float blockPrecision() const;

		virtual float armorPiercing() const;

		virtual float criticalChance() const;

		virtual float damageReduction() const;

		virtual Stat statModification() const;

		virtual float movementSpeed() const;

		virtual float sightRange() const;

		virtual float attackSpeed() const;

		virtual float parrySpeed() const;

		virtual float staminaDrain() const;

		virtual float stagger() const;

		virtual float staggerReduction() const;

		virtual float overshootRange() const;

		virtual float overshootMinRange() const;

		virtual float projectileSpeed() const;

		virtual float projectileSpeedCap() const;

		virtual void setAnimation(Direction direction, std::string animationID, bool isLooping = true, float speed = 1);

		virtual void setDirection(Direction direction, std::string animationID);

		assets::Item::Type type() const {
			return mProvider.type;
		}

		std::string animationType() const
		{
			if(type() == assets::Item::Melee)
				return "Slash";
			else if(type() == assets::Item::Ranged)
				return "Bow";
			else if(type() == assets::Item::Thrust)
				return "Thrust";
			else if(type() == assets::Item::Cast)
				return "Cast";
			else
				return "";
		}

		bool melee() const 
		{
			return type() == assets::Item::Melee || type() == assets::Item::Thrust;
		}

		bool ranged() const
		{
			return type() == assets::Item::Ranged || type() == assets::Item::Cast;
		}

		Animator &animator;
		assets::Item &mProvider;
	protected:
		bool mIsActive;
		float mLastUsedTime;
		Human *mWielder;
	};
}