1.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Zombie.java Sun Jun 19 15:10:18 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Zombie.java Sun Jun 19 15:10:41 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 @@ -7,23 +8,42 @@
1.11 public class Zombie implements ICard
1.12 {
1.13 @Override
1.14 - public IValue returnValue(final IValue iVal, Player proponent, Player opponent)
1.15 + public IValue returnValue(final IValue iobj, Player proponent, Player opponent)
1.16 {
1.17 return new ICard()
1.18 {
1.19 @Override
1.20 public IValue returnValue(final IValue x, Player proponent, Player opponent)
1.21 {
1.22 - if (iVal.getClass().equals(Value.class))
1.23 + if (iobj instanceof Value)
1.24 {
1.25 - int i = ((Value)iVal).getValue();
1.26 - if (i >= 0 && i < 256)
1.27 + int i = ((Value)iobj).getValue();
1.28 +
1.29 + if (i >= 0 && i <= 255)
1.30 {
1.31 - opponent.getSlot(i).putValue(x);
1.32 - opponent.getSlot(i).setVitality(-1);
1.33 + int v = opponent.getSlot(255 - i).getVitality();
1.34 +
1.35 + if(v <= 0)
1.36 + {
1.37 + opponent.getSlot(255 - i).putValue(x);
1.38 + opponent.getSlot(255 - i).setVitality(-1);
1.39 +
1.40 + return new I();
1.41 + }
1.42 + else
1.43 + {
1.44 + throw new ICFPCException();
1.45 + }
1.46 + }
1.47 + else
1.48 + {
1.49 + throw new ICFPCException();
1.50 }
1.51 }
1.52 - return new I();
1.53 + else
1.54 + {
1.55 + throw new ICFPCException();
1.56 + }
1.57 }
1.58 };
1.59 }