src/main/java/ru/alphatech/icfpc/cards/Dec.java
author indvdum
Sun, 19 Jun 2011 17:47:28 +0400
changeset 95 598cbc609683
parent 79 0bfd181c663e
child 102 cc814352ab43
permissions -rw-r--r--
* merge
     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.Run;
     7 import ru.alphatech.icfpc.game.Value;
     8 
     9 public class Dec implements ICard
    10 {
    11 	@Override
    12 	public String getName() {
    13 		return "dec";
    14 	}
    15 	
    16 	@Override
    17 	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
    18 	{
    19 		if(iobj instanceof Value)
    20 		{
    21 			int i = ((Value)iobj).getValue();
    22 
    23 			if (i >= 0 && i <= 255)
    24 			{
    25 				int v = proponent.getSlot(255 - i).getVitality();
    26 				
    27 				if(Run.getAutoMode())
    28 				{
    29 					if(v > 0 && v < 65535)
    30 					{
    31 						proponent.getSlot(255 - i).setVitality(v + 1);
    32 					}
    33 				}
    34 				else
    35 				{
    36 					if (v > 0)
    37 					{
    38 						proponent.getSlot(255 - i).setVitality(v - 1);
    39 					}
    40 				}
    41 
    42 				return new I();
    43 			}
    44 			else
    45 			{
    46 				throw new ICFPCException();
    47 			}
    48 		}
    49 		else
    50 		{
    51 			throw new ICFPCException();
    52 		}
    53 	}
    54 }