src/main/java/ru/alphatech/icfpc/cards/Help.java
changeset 35 743564afa994
parent 12 042162c73d0f
child 64 8ce8964b584f
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 Help implements ICard
     8 public class Help implements ICard
    22 						if (i.getClass().equals(Value.class) && j.getClass().equals(Value.class) && n.getClass().equals(Value.class))
    23 						if (i.getClass().equals(Value.class) && j.getClass().equals(Value.class) && n.getClass().equals(Value.class))
    23 						{
    24 						{
    24 							int ival = ((Value)i).getValue();
    25 							int ival = ((Value)i).getValue();
    25 							int jval = ((Value)j).getValue();
    26 							int jval = ((Value)j).getValue();
    26 							int nval = ((Value)n).getValue();
    27 							int nval = ((Value)n).getValue();
    27 							proponent.getSlot(ival).setVitality(proponent.getSlot(ival).getVitality() - nval);
    28 							if (ival >= 0 && ival < 256 && jval >= 0 && jval < 256)
    28 							proponent.getSlot(jval).setVitality(proponent.getSlot(jval).getVitality() + ((11 * nval)/10));
       
    29 							return new ICard()
       
    30 							{
    29 							{
    31 								@Override
    30 								int v = proponent.getSlot(ival).getVitality();
    32 								public IValue returnValue(IValue value, Player proponent, Player opponent)
    31 								int w = proponent.getSlot(jval).getVitality();
       
    32 
       
    33 								if (v > nval)
    33 								{
    34 								{
    34 									return value;
    35 									proponent.getSlot(ival).setVitality(v - nval);
       
    36 									if (w > 0)
       
    37 									{
       
    38 										if (w >= 65535)
       
    39 										{
       
    40 											proponent.getSlot(jval).setVitality(65535);
       
    41 										}
       
    42 										else
       
    43 										{
       
    44 											proponent.getSlot(jval).setVitality(w + ((11 * nval)/10));
       
    45 										}
       
    46 									}
    35 								}
    47 								}
    36 							};
    48 								else
       
    49 								{
       
    50 									throw new ICFPCException();
       
    51 								}
       
    52 							}
       
    53 							else
       
    54 							{
       
    55 								throw new ICFPCException();
       
    56 							}
       
    57 
       
    58 							return new I();
    37 						}
    59 						}
    38 						return null;
    60 						return null;
    39 					}
    61 					}
    40 				};
    62 				};
    41 			}
    63 			}