src/main/java/ru/alphatech/icfpc/cards/Get.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 Get extends AbstractCard
     9 {
    10 	@Override
    11 	public String getName() {
    12 		return "get";
    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 					return proponent.getSlot(i).getValue();
    31 				}
    32 				else
    33 				{
    34 					throw new ICFPCException();
    35 				}
    36 			}
    37 			else
    38 			{
    39 				throw new ICFPCException();
    40 			}
    41 		}
    42 		else
    43 		{
    44 			throw new ICFPCException();
    45 		}
    46 	}
    47 
    48 }