src/main/java/ru/alphatech/icfpc/cards/Revive.java
author Azamat S. Kalimoulline <turtle@bazon.ru>
Sun, 19 Jun 2011 19:13:07 +0400
changeset 102 cc814352ab43
parent 74 b277f6c31f5f
permissions -rw-r--r--
Call Count.
     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 extends AbstractCard
     9 {
    10 	@Override
    11 	public String getName() {
    12 		return "revive";
    13 	}
    14 	
    15 	@Override
    16 	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
    17 	{
    18 		incAndTest();
    19 		
    20 		if (iobj instanceof Value)
    21 		{
    22 			int i = ((Value)iobj).getValue();
    23 
    24 			if (i >= 0 && i <= 255)
    25 			{
    26 				int v = proponent.getSlot(i).getVitality();
    27 
    28 				if (v <= 0)
    29 				{
    30 					proponent.getSlot(i).setVitality(1);
    31 				}
    32 				
    33 				return new I();
    34 			}
    35 			else
    36 			{
    37 				throw new ICFPCException();
    38 			}
    39 		}
    40 		else
    41 		{
    42 			throw new ICFPCException();
    43 		}
    44 	}
    45 }