diff -r 7b2179e85787 -r 8ce8964b584f src/main/java/ru/alphatech/icfpc/cards/Help.java --- a/src/main/java/ru/alphatech/icfpc/cards/Help.java Sun Jun 19 13:50:35 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/cards/Help.java Sun Jun 19 14:29:38 2011 +0400 @@ -8,41 +8,47 @@ public class Help implements ICard { @Override - public IValue returnValue(final IValue i, Player proponent, Player opponent) + public IValue returnValue(final IValue iobj, Player proponent, Player opponent) { return new ICard() { @Override - public IValue returnValue(final IValue j, Player proponent, Player opponent) + public IValue returnValue(final IValue jobj, Player proponent, Player opponent) { return new ICard() { @Override - public IValue returnValue(final IValue n, Player proponent, Player opponent) + public IValue returnValue(final IValue nobj, Player proponent, Player opponent) { - if (i.getClass().equals(Value.class) && j.getClass().equals(Value.class) && n.getClass().equals(Value.class)) + if(iobj instanceof Value && nobj instanceof Value) { - int ival = ((Value)i).getValue(); - int jval = ((Value)j).getValue(); - int nval = ((Value)n).getValue(); - if (ival >= 0 && ival < 256 && jval >= 0 && jval < 256) + int i = ((Value)iobj).getValue(); + int n = ((Value)nobj).getValue(); + int v = proponent.getSlot(i).getVitality(); + + if(i >= 0 && i <= 255 && n <= v) { - int v = proponent.getSlot(ival).getVitality(); - int w = proponent.getSlot(jval).getVitality(); - - if (v > nval) + if(jobj instanceof Value) { - proponent.getSlot(ival).setVitality(v - nval); - if (w > 0) + int j = ((Value)jobj).getValue(); + + if(j >= 0 && j <= 255) { - if (w >= 65535) + int w = proponent.getSlot(j).getVitality(); + + if(w > 0) { - proponent.getSlot(jval).setVitality(65535); + int winc = (int) Math.floor(11 * n / 10); + int resw = w + winc; + + proponent.getSlot(j).setVitality(resw > 65535 ? 65535 : resw); } - else - { - proponent.getSlot(jval).setVitality(w + ((11 * nval)/10)); - } + + return new I(); + } + else + { + throw new ICFPCException(); } } else @@ -54,10 +60,11 @@ { throw new ICFPCException(); } - - return new I(); } - return null; + else + { + throw new ICFPCException(); + } } }; }