src/main/java/ru/alphatech/icfpc/cards/Dec.java
changeset 35 743564afa994
parent 12 042162c73d0f
child 60 7b2179e85787
     1.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Dec.java	Sun Jun 19 10:50:46 2011 +0400
     1.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Dec.java	Sun Jun 19 12:12:55 2011 +0400
     1.3 @@ -1,5 +1,6 @@
     1.4  package ru.alphatech.icfpc.cards;
     1.5  
     1.6 +import ru.alphatech.icfpc.game.ICFPCException;
     1.7  import ru.alphatech.icfpc.game.IValue;
     1.8  import ru.alphatech.icfpc.game.Player;
     1.9  import ru.alphatech.icfpc.game.Value;
    1.10 @@ -11,18 +12,24 @@
    1.11  	{
    1.12  		if(value.getClass().equals(Value.class))
    1.13  		{
    1.14 -			if (((Value)value).getValue() < 256 && ((Value)value).getValue() > -1)
    1.15 +			int i = ((Value)value).getValue();
    1.16 +
    1.17 +			if (i > 0 && i < 256)
    1.18  			{
    1.19 -				opponent.getSlot(((Value)value).getValue()).setVitality(opponent.getSlot(((Value)value).getValue()).getVitality() - 1);
    1.20 -				return new ICard()
    1.21 +				int v = proponent.getSlot(255 - i).getVitality();
    1.22 +				if (v < 65535 && v > 0)
    1.23  				{
    1.24 -					@Override
    1.25 -					public IValue returnValue(IValue value, Player proponent, Player opponent)
    1.26 -					{
    1.27 -						return value;
    1.28 -					}
    1.29 -				};
    1.30 +					proponent.getSlot(255 - i).setVitality(proponent.getSlot(255 - i).getVitality() - 1);
    1.31 +				}
    1.32  			}
    1.33 +			else
    1.34 +			{
    1.35 +				throw new ICFPCException();
    1.36 +			}
    1.37 +		}
    1.38 +		else
    1.39 +		{
    1.40 +			throw new ICFPCException();
    1.41  		}
    1.42  
    1.43  		return new Value(-100);