src/main/java/ru/alphatech/icfpc/cards/Dec.java
author Azamat S. Kalimoulline <turtle@bazon.ru>
Sun, 19 Jun 2011 13:41:13 +0400
changeset 57 4a82118416bd
parent 35 743564afa994
child 60 7b2179e85787
permissions -rw-r--r--
cards K and S.
     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 Dec 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 < 256)
    18 			{
    19 				int v = proponent.getSlot(255 - i).getVitality();
    20 				if (v < 65535 && v > 0)
    21 				{
    22 					proponent.getSlot(255 - i).setVitality(proponent.getSlot(255 - i).getVitality() - 1);
    23 				}
    24 			}
    25 			else
    26 			{
    27 				throw new ICFPCException();
    28 			}
    29 		}
    30 		else
    31 		{
    32 			throw new ICFPCException();
    33 		}
    34 
    35 		return new Value(-100);
    36 	}
    37 }