1.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Attack.java Sun Jun 19 10:50:46 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Attack.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 @@ -24,18 +25,34 @@
1.11 int ival = ((Value)i).getValue();
1.12 int jval = ((Value)j).getValue();
1.13 int nval = ((Value)n).getValue();
1.14 - proponent.getSlot(ival).setVitality(proponent.getSlot(ival).getVitality() - nval);
1.15 - opponent.getSlot(255 - jval).setVitality(opponent.getSlot(255 - jval).getVitality() - ((9 * nval)/10));
1.16 - return new ICard()
1.17 +
1.18 + if (ival >= 0 && ival < 256 && jval >= 0 && jval < 256)
1.19 {
1.20 - @Override
1.21 - public IValue returnValue(IValue value, Player proponent, Player opponent)
1.22 + int v = proponent.getSlot(ival).getVitality();
1.23 + int w = opponent.getSlot(255 - jval).getVitality();
1.24 + if (v - nval < 1)
1.25 {
1.26 - return value;
1.27 + proponent.getSlot(ival).setVitality(v - nval);
1.28 + if (w > 0)
1.29 + {
1.30 + opponent.getSlot(255 - jval).setVitality(w - ((9 * nval)/10));
1.31 + }
1.32 }
1.33 - };
1.34 + else
1.35 + {
1.36 + throw new ICFPCException();
1.37 + }
1.38 + }
1.39 + else
1.40 + {
1.41 + throw new ICFPCException();
1.42 + }
1.43 }
1.44 - return null;
1.45 + else
1.46 + {
1.47 + throw new ICFPCException();
1.48 + }
1.49 + return new I();
1.50 }
1.51 };
1.52 }