#include "item.h"

Item::Item(int id, int x, int y, QCanvasSprite *sprite, int type)
	: Sprite(id, x, y, sprite)
{
	m_type = type;
	m_highlighted = false;
	m_activated = false;
}

void Item::proceed()
{
	if ((!m_activated) && (m_highlighted)) {
		if((m_sprite) && (m_sprite->frameCount() > 2)) {
			if (m_sprite->frame() == 0)
				m_sprite->setFrame(2);
			else
				m_sprite->setFrame(0);
		}
	}
}

int Item::type(void)
{
	return m_type;
}

void Item::setHighlighted(bool val)
{
	m_highlighted = val;
}

bool Item::isHighlighted()
{
	return m_highlighted;
}

void Item::activate(bool value)
{
	m_activated = value;
	if((m_sprite) && (m_sprite->frameCount() > 2))
	{
		if(m_activated) m_sprite->setFrame(1);
		else m_sprite->setFrame(0);
	}
}

bool Item::isActive()
{
	return m_activated;
}

