src/main/java/ru/alphatech/icfpc/cards/Inc.java
author akhmetovlz
Sun, 19 Jun 2011 14:29:45 +0400
changeset 63 7b60d53f6933
parent 60 7b2179e85787
child 64 8ce8964b584f
permissions -rw-r--r--
Merge with 7b2179e8578703d2b77686e692e8792d8f0df53e
     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 Inc implements ICard
     9 {
    10 	@Override
    11 	public IValue returnValue(IValue value, Player proponent, Player opponent)
    12 	{
    13 		if(value.getClass().equals(Value.class))
    14 		{
    15 			int i = ((Value)value).getValue();
    16 
    17 			if (i >= 0 && i <= 255)
    18 			{
    19 				int v = proponent.getSlot(i).getVitality();
    20 				
    21 				if (v > 0 && v < 65535)
    22 				{
    23 					proponent.getSlot(i).setVitality(v + 1);
    24 				}
    25 				
    26 				return new I();
    27 			}
    28 			else
    29 			{
    30 				throw new ICFPCException();
    31 			}
    32 		}
    33 		else
    34 		{
    35 			throw new ICFPCException();
    36 		}
    37 	}
    38 }