package poker.domain

object Naipe {
  val PAUS = 1
  val COPAS = 2
  val ESPADAS = 3
  val OUROS = 4
  
  def str(naipe:Int): String = {
    naipe match {
      case PAUS => "Paus"
      case COPAS => "Copas"
      case ESPADAS => "Espadas"
      case OUROS => "Ouros"
      case _ => "ops"
    }
  }
}

object Valor {
  val J = 11
	val Q = 12
	val K = 13
  val AS = 14
  
  def str(valor:Int): String = {
    valor match {
      case J => "J"
      case Q => "Q"
      case K => "K"
      case AS => "AS"
      case _ => valor.toString()
    }
  }
}

class Carta(val valor:Int, val naipe:Int) extends Ordered[Carta] {
  require(valor >= 2 && valor <= Valor.AS)
  require(naipe >= Naipe.PAUS && naipe <= Naipe.OUROS)
  
  override def toString = "[" + Valor.str(valor) + " " + Naipe.str(naipe) + "]"

  override def equals(that: Any) = that match {
    case other:Carta => 
      other.getClass == getClass && other.valor == valor && other.naipe == naipe
    case _ => false
  }
  
  override def hashCode(): Int = {
    valor.hashCode() + naipe.hashCode()
  }

  override def compare(that:Carta):Int = this.valor compare that.valor
  
}

//object Naipes {
//	sealed abstract class Suit
//	case class Paus extends Suit
//	case class Copas extends Suit
//	case class Espada extends Suit
//	case class Ouros extends Suit
// 
//}
//		override def toString() = getClass().getSimpleName()
