src/main/java/ru/alphatech/icfpc/cards/Revive.java
changeset 68 a84a3c755d93
parent 35 743564afa994
child 74 b277f6c31f5f
equal deleted inserted replaced
65:2c8b98d4efb8 68:a84a3c755d93
     6 import ru.alphatech.icfpc.game.Value;
     6 import ru.alphatech.icfpc.game.Value;
     7 
     7 
     8 public class Revive implements ICard
     8 public class Revive implements ICard
     9 {
     9 {
    10 	@Override
    10 	@Override
    11 	public IValue returnValue(IValue value, Player proponent, Player opponent)
    11 	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
    12 	{
    12 	{
    13 		if (value.getClass().equals(Value.class))
    13 		if (iobj instanceof Value)
    14 		{
    14 		{
    15 			int i = ((Value)value).getValue();
    15 			int i = ((Value)iobj).getValue();
    16 			if (i >= 0 && i < 256)
    16 
       
    17 			if (i >= 0 && i <= 255)
    17 			{
    18 			{
    18 				if (proponent.getSlot(i).getVitality() <= 0)
    19 				int v = proponent.getSlot(i).getVitality();
       
    20 
       
    21 				if (v <= 0)
    19 				{
    22 				{
    20 					proponent.getSlot(i).setVitality(1);
    23 					proponent.getSlot(i).setVitality(1);
    21 				}
    24 				}
       
    25 				
       
    26 				return new I();
    22 			}
    27 			}
    23 			else
    28 			else
    24 			{
    29 			{
    25 				throw new ICFPCException();
    30 				throw new ICFPCException();
    26 			}
    31 			}
    27 		}
    32 		}
    28 		else
    33 		else
    29 		{
    34 		{
    30 			throw new ICFPCException();
    35 			throw new ICFPCException();
    31 		}
    36 		}
    32 		return new I();
       
    33 	}
    37 	}
    34 }
    38 }