src/main/java/ru/alphatech/icfpc/cards/Get.java
author rushan
Sun, 19 Jun 2011 17:32:15 +0400
changeset 88 9555608af847
parent 74 b277f6c31f5f
child 102 cc814352ab43
permissions -rw-r--r--
Merge with 22bad86100ac86a8164a6c6925086cfda905d765
     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 implements ICard
     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 		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 					return proponent.getSlot(i).getValue();
    29 				}
    30 				else
    31 				{
    32 					throw new ICFPCException();
    33 				}
    34 			}
    35 			else
    36 			{
    37 				throw new ICFPCException();
    38 			}
    39 		}
    40 		else
    41 		{
    42 			throw new ICFPCException();
    43 		}
    44 	}
    45 
    46 }