#ifndef WEAPON_ITEM_H
#define WEAPON_ITEM_H

#include <string>
#include <QtGui>
#include "softProj\clientServer\structs.h"
#include "softProj\commonTypes.h"

enum EWeaponClass {
	WEAPON_CLASS1, WEAPON_CLASS2, WEAPON_CLASS3
};

class WeaponItem  {
private:
	int id_; 
	std::wstring name_;
	
	int currentCharge_;
	int maximumCharge_;
	
	int chargeToFire_;
	
	EWeaponClass weaponClass_;
public:
	int getCurrentCharge() const {
		return currentCharge_;
	} /**< Returns current weapon charge value. */

	int getMaximumCharge() const {
		return maximumCharge_;
	} /**< Returns weapon maximum charge limit. */ 

	int getChargeToFire() const {
		return chargeToFire_;
	} /**< Returns weapon charge value. */

	int getId() const {
		return id_;
	} /**< Returns weapon id. */

	EWeaponClass getWeaponClass() const {
		return weaponClass_;
	} /**< Returns type of weapon. */

	const std::wstring & getName() const {
		return name_;
	} /**< Returns name of the weapon. */

	void setCurrentCharge(int value) {
		currentCharge_ = value;
	} /**< Sets current weapon charge value. */ 

	void setMaximumCharge(int value) {
		maximumCharge_ = value;
	} /**< Sets weapon maximum charge limit. */ 

	void setChargeToFire(int value) {
		chargeToFire_ = value;
	} /**< Returns weapon charge value. */

	void setWeaponClass(EWeaponClass value) {
		weaponClass_ = value;
	} /**<Sets type of the weapon. */

	void setName(const std::wstring & name) {
		name_ = name;
	} /**< Sets name of the weapon. */

	void setId(int value) {
		this->id_ = value;
	} /**< Sets id of the weapon. */
public:
	WeaponItem() {
		currentCharge_ = 0;
		maximumCharge_ = 100;
		chargeToFire_ = 0;
		id_ = 0;
	}

	WeaponItem(const std::wstring & name) {
		currentCharge_ = 0;
		maximumCharge_ = 100;
		chargeToFire_ = 0;
		id_ = 0;
		name_ = name;
	}

	WeaponItem(const WeaponItem & other) {
		currentCharge_ = other.currentCharge_;
		maximumCharge_ = other.maximumCharge_;
		chargeToFire_ = other.chargeToFire_;
		name_ = other.name_;
		id_ = other.id_;
	}
};

///Pure virtual class used as base class for all weapon widgets.
class BasicWeaponWidget : public QWidget {
	Q_OBJECT
protected:
	bool isActive_;
	unsigned long long index_;
	QWidget * parent_;
	QString energyUnit_;
public:
	virtual void refreshDesignByActivity() = 0;
	virtual void setDeviceName(const std::wstring & name) = 0;

	virtual void setChargeToFire(unsigned long long value) = 0; /**< Returns weapon charge value. */
	virtual void setCurrentCharge(unsigned long long value) = 0; /**< Sets current weapon charge value. */ 
	virtual void setMaximumCharge( unsigned long long value) = 0; /**< Sets weapon maximum charge limit. */ 
	virtual unsigned long long getChargeToFire() = 0; /**< Returns weapon charge value. */

	void setIndex(unsigned long long index) {
		this->index_ = index;
	} //TODO, FIXME, COMMENTME

	virtual void activateDevice() {} /**<Activates weapon widget. */
	virtual void deactivateDevice() {} /**<Deactivates weapon widget. */

	BasicWeaponWidget(QWidget * parent) : QWidget(parent) {
		this->parent_ = parent;
	}

	virtual std::pair<id_t, unsigned long long> getState() = 0;

	virtual void setEnergyUnit(const std::wstring & unit) = 0;
	virtual void setAsSmall() = 0;
	virtual void setAsBig() = 0;
	virtual void setAsMounted(bool mounted) = 0;
	virtual void notifyUpdate(double difference) = 0;
};

#endif