package uno.card;
import uno.*;
import java.lang.*;
public class NumberCard extends ColorCard {
	private int n;
	public NumberCard(Color c, int n) throws IllegalArgumentException{
		super(c);
		if(n<0||n>9){
			throw new IllegalArgumentException();
		}else{
			this.n=n;
		}
	}
	public boolean canPlaceOn(Card c){
		return super.c==c.getColor() || c instanceof NumberCard && n==c.orderNum();
	}
	public int orderNum(){
		return n;
	}
	@Override
	public int compareTo(Card c){
		//if(this.equals(that))return 0;
		//System.out.println("NumberCard.compareTo");
		//System.out.println(getColor().ordinal());
		//System.out.println(c.getColor().ordinal());
		if(c==null)return 0;
		else if(getColor().ordinal()==c.getColor().ordinal())return orderNum()>c.orderNum()?1:-1;
		return getColor().ordinal()>c.getColor().ordinal()?1:-1;
	}
	@Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (this.getClass() != obj.getClass())
            return false;
        
        Card other = (Card) obj;
        if (getColor() != other.getColor())
            return false;
        if (orderNum() != other.orderNum())
            return false;
        return true;
    }
	//todo WildCard?
	public void effect(Game g){}
	public String toString(){
		return c+" "+n;
	}
}