diff -r 0e21db22ecec -r 743564afa994 src/main/java/ru/alphatech/icfpc/cards/Attack.java --- a/src/main/java/ru/alphatech/icfpc/cards/Attack.java Sun Jun 19 10:50:46 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/cards/Attack.java Sun Jun 19 12:12:55 2011 +0400 @@ -1,5 +1,6 @@ package ru.alphatech.icfpc.cards; +import ru.alphatech.icfpc.game.ICFPCException; import ru.alphatech.icfpc.game.IValue; import ru.alphatech.icfpc.game.Player; import ru.alphatech.icfpc.game.Value; @@ -24,18 +25,34 @@ int ival = ((Value)i).getValue(); int jval = ((Value)j).getValue(); int nval = ((Value)n).getValue(); - proponent.getSlot(ival).setVitality(proponent.getSlot(ival).getVitality() - nval); - opponent.getSlot(255 - jval).setVitality(opponent.getSlot(255 - jval).getVitality() - ((9 * nval)/10)); - return new ICard() + + if (ival >= 0 && ival < 256 && jval >= 0 && jval < 256) { - @Override - public IValue returnValue(IValue value, Player proponent, Player opponent) + int v = proponent.getSlot(ival).getVitality(); + int w = opponent.getSlot(255 - jval).getVitality(); + if (v - nval < 1) { - return value; + proponent.getSlot(ival).setVitality(v - nval); + if (w > 0) + { + opponent.getSlot(255 - jval).setVitality(w - ((9 * nval)/10)); + } } - }; + else + { + throw new ICFPCException(); + } + } + else + { + throw new ICFPCException(); + } } - return null; + else + { + throw new ICFPCException(); + } + return new I(); } }; }