src/main/java/ru/alphatech/icfpc/cards/Zombie.java
author akhmetovlz
Sun, 19 Jun 2011 16:52:20 +0400
changeset 76 5955cb5e5ef3
parent 68 a84a3c755d93
child 74 b277f6c31f5f
permissions -rw-r--r--
policies
     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 Zombie implements ICard
     9 {
    10 	@Override
    11 	public IValue returnValue(final IValue iobj, Player proponent, Player opponent)
    12 	{
    13 		return new ICard()
    14 		{
    15 			@Override
    16 			public IValue returnValue(final IValue x, Player proponent, Player opponent)
    17 			{
    18 				if (iobj instanceof Value)
    19 				{
    20 					int i = ((Value)iobj).getValue();
    21 
    22 					if (i >= 0 && i <= 255)
    23 					{
    24 						int v = opponent.getSlot(255 - i).getVitality();
    25 
    26 						if(v <= 0)
    27 						{
    28 							opponent.getSlot(255 - i).putValue(x);
    29 							opponent.getSlot(255 - i).setVitality(-1);
    30 
    31 							return new I();
    32 						}
    33 						else
    34 						{
    35 							throw new ICFPCException();
    36 						}
    37 					}
    38 					else
    39 					{
    40 						throw new ICFPCException();
    41 					}
    42 				}
    43 				else
    44 				{
    45 					throw new ICFPCException();
    46 				}
    47 			}
    48 		};
    49 	}
    50 }