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