src/main/java/ru/alphatech/icfpc/cards/Revive.java
author akhmetovlz
Sun, 19 Jun 2011 14:34:54 +0400
changeset 66 8c820ab3cd8a
parent 35 743564afa994
child 68 a84a3c755d93
permissions -rw-r--r--
Композиция
     1 package ru.alphatech.icfpc.cards;
     2 
     3 import ru.alphatech.icfpc.game.ICFPCException;
     4 import ru.alphatech.icfpc.game.IValue;
     5 import ru.alphatech.icfpc.game.Player;
     6 import ru.alphatech.icfpc.game.Value;
     7 
     8 public class Revive implements ICard
     9 {
    10 	@Override
    11 	public IValue returnValue(IValue value, Player proponent, Player opponent)
    12 	{
    13 		if (value.getClass().equals(Value.class))
    14 		{
    15 			int i = ((Value)value).getValue();
    16 			if (i >= 0 && i < 256)
    17 			{
    18 				if (proponent.getSlot(i).getVitality() <= 0)
    19 				{
    20 					proponent.getSlot(i).setVitality(1);
    21 				}
    22 			}
    23 			else
    24 			{
    25 				throw new ICFPCException();
    26 			}
    27 		}
    28 		else
    29 		{
    30 			throw new ICFPCException();
    31 		}
    32 		return new I();
    33 	}
    34 }