package ocelot.desktop.inventory.item

import ocelot.desktop.graphics.IconSource
import ocelot.desktop.inventory.traits.{CardItem, ComponentItem, PersistableItem}
import ocelot.desktop.inventory.{Item, ItemFactory, ItemRecoverer}
import totoro.ocelot.brain.entity.SelfDestructingCard
import totoro.ocelot.brain.entity.traits.{Entity, Environment}
import totoro.ocelot.brain.util.Tier
import totoro.ocelot.brain.util.Tier.Tier

class SelfDestructingCardItem(val card: SelfDestructingCard)
  extends Item
    with ComponentItem
    with PersistableItem
    with CardItem {

  override def component: Entity with Environment = card

  override def factory: ItemFactory = SelfDestructingCardItem.Factory
}

object SelfDestructingCardItem {
  object Factory extends ItemFactory {
    override type I = SelfDestructingCardItem

    override def itemClass: Class[I] = classOf

    override def name: String = "Self-Destructing Card"

    override def tier: Option[Tier] = Some(Tier.Two)

    override def icon: IconSource = IconSource.Items.SelfDestructingCard

    override def build(): SelfDestructingCardItem = new SelfDestructingCardItem(new SelfDestructingCard)

    override def recoverers: Iterable[ItemRecoverer[_, _]] = Some(ItemRecoverer(new SelfDestructingCardItem(_)))
  }
}
