src/main/java/ru/alphatech/icfpc/cards/Revive.java
author akhmetovlz
Sun, 19 Jun 2011 19:13:42 +0400
changeset 101 4bb458c3548e
parent 74 b277f6c31f5f
child 102 cc814352ab43
permissions -rw-r--r--
(no commit message)
     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 String getName() {
    12 		return "revive";
    13 	}
    14 	
    15 	@Override
    16 	public IValue returnValue(IValue iobj, 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 = proponent.getSlot(i).getVitality();
    25 
    26 				if (v <= 0)
    27 				{
    28 					proponent.getSlot(i).setVitality(1);
    29 				}
    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 }