src/main/java/ru/alphatech/icfpc/cards/Dec.java
changeset 35 743564afa994
parent 12 042162c73d0f
child 60 7b2179e85787
equal deleted inserted replaced
27:0e21db22ecec 35:743564afa994
     1 package ru.alphatech.icfpc.cards;
     1 package ru.alphatech.icfpc.cards;
     2 
     2 
       
     3 import ru.alphatech.icfpc.game.ICFPCException;
     3 import ru.alphatech.icfpc.game.IValue;
     4 import ru.alphatech.icfpc.game.IValue;
     4 import ru.alphatech.icfpc.game.Player;
     5 import ru.alphatech.icfpc.game.Player;
     5 import ru.alphatech.icfpc.game.Value;
     6 import ru.alphatech.icfpc.game.Value;
     6 
     7 
     7 public class Dec implements ICard
     8 public class Dec implements ICard
     9 	@Override
    10 	@Override
    10 	public IValue returnValue(IValue value, Player proponent, Player opponent)
    11 	public IValue returnValue(IValue value, Player proponent, Player opponent)
    11 	{
    12 	{
    12 		if(value.getClass().equals(Value.class))
    13 		if(value.getClass().equals(Value.class))
    13 		{
    14 		{
    14 			if (((Value)value).getValue() < 256 && ((Value)value).getValue() > -1)
    15 			int i = ((Value)value).getValue();
       
    16 
       
    17 			if (i > 0 && i < 256)
    15 			{
    18 			{
    16 				opponent.getSlot(((Value)value).getValue()).setVitality(opponent.getSlot(((Value)value).getValue()).getVitality() - 1);
    19 				int v = proponent.getSlot(255 - i).getVitality();
    17 				return new ICard()
    20 				if (v < 65535 && v > 0)
    18 				{
    21 				{
    19 					@Override
    22 					proponent.getSlot(255 - i).setVitality(proponent.getSlot(255 - i).getVitality() - 1);
    20 					public IValue returnValue(IValue value, Player proponent, Player opponent)
    23 				}
    21 					{
       
    22 						return value;
       
    23 					}
       
    24 				};
       
    25 			}
    24 			}
       
    25 			else
       
    26 			{
       
    27 				throw new ICFPCException();
       
    28 			}
       
    29 		}
       
    30 		else
       
    31 		{
       
    32 			throw new ICFPCException();
    26 		}
    33 		}
    27 
    34 
    28 		return new Value(-100);
    35 		return new Value(-100);
    29 	}
    36 	}
    30 }
    37 }