package ru.alphatech.icfpc.cards;

import ru.alphatech.icfpc.game.ICFPCException;
import ru.alphatech.icfpc.game.IValue;
import ru.alphatech.icfpc.game.Player;
import ru.alphatech.icfpc.game.Value;

public class Get implements ICard
{
	@Override
	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
	{
		if (iobj instanceof Value)
		{
			int i =  ((Value)iobj).getValue();
			int v = proponent.getSlot(i).getVitality();
			
			if(i >= 0 && i <= 255 && v > 0)
			{
				return proponent.getSlot(i).getValue();
			}
			else
			{
				throw new ICFPCException();
			}
		}
		else
		{
			throw new ICFPCException();
		}
	}

}
