Cards done. Only interpretation of zero card is under question mark.
1.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Attack.java Sun Jun 19 14:30:33 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Attack.java Sun Jun 19 15:04:59 2011 +0400
1.3 @@ -24,27 +24,35 @@
1.4 {
1.5 int i = ((Value)iobj).getValue();
1.6 int n = ((Value)nobj).getValue();
1.7 - int v = proponent.getSlot(i).getVitality();
1.8
1.9 - if(i >= 0 && i <= 255 && n <= v)
1.10 + if(i >= 0 && i <= 255)
1.11 {
1.12 - if(jobj instanceof Value)
1.13 + int v = proponent.getSlot(i).getVitality();
1.14 +
1.15 + if(n <= v)
1.16 {
1.17 - int j = ((Value)jobj).getValue();
1.18 -
1.19 - if(j >= 0 && j <= 255)
1.20 + if(jobj instanceof Value)
1.21 {
1.22 - int w = opponent.getSlot(255 - j).getVitality();
1.23 + int j = ((Value)jobj).getValue();
1.24
1.25 - if (w > 0)
1.26 + if(j >= 0 && j <= 255)
1.27 {
1.28 - int wdec = (int) Math.floor(9 * n / 10);
1.29 - int resw = w - wdec;
1.30 + int w = opponent.getSlot(255 - j).getVitality();
1.31 +
1.32 + if (w > 0)
1.33 + {
1.34 + int wdec = (int) Math.floor(9 * n / 10);
1.35 + int resw = w - wdec;
1.36
1.37 - opponent.getSlot(255 - j).setVitality(resw < 0 ? 0 : w);
1.38 + opponent.getSlot(255 - j).setVitality(resw < 0 ? 0 : w);
1.39 + }
1.40 +
1.41 + return new I();
1.42 }
1.43 -
1.44 - return new I();
1.45 + else
1.46 + {
1.47 + throw new ICFPCException();
1.48 + }
1.49 }
1.50 else
1.51 {
2.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Copy.java Sun Jun 19 14:30:33 2011 +0400
2.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Copy.java Sun Jun 19 15:04:59 2011 +0400
2.3 @@ -8,14 +8,15 @@
2.4 public class Copy implements ICard
2.5 {
2.6 @Override
2.7 - public IValue returnValue(IValue i, Player proponent, Player opponent)
2.8 + public IValue returnValue(IValue iobj, Player proponent, Player opponent)
2.9 {
2.10 - if (i.getClass().equals(Value.class))
2.11 + if (iobj instanceof Value)
2.12 {
2.13 - int iVal = ((Value)i).getValue();
2.14 - if (iVal >= 0 && iVal < 256)
2.15 + int i = ((Value)iobj).getValue();
2.16 +
2.17 + if (i >= 0 && i <= 255)
2.18 {
2.19 - return opponent.getSlot(((Value)i).getValue()).getValue();
2.20 + return opponent.getSlot(i).getValue();
2.21 }
2.22 else
2.23 {
3.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Get.java Sun Jun 19 14:30:33 2011 +0400
3.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Get.java Sun Jun 19 15:04:59 2011 +0400
3.3 @@ -13,11 +13,19 @@
3.4 if (iobj instanceof Value)
3.5 {
3.6 int i = ((Value)iobj).getValue();
3.7 - int v = proponent.getSlot(i).getVitality();
3.8
3.9 - if(i >= 0 && i <= 255 && v > 0)
3.10 + if(i >= 0 && i <= 255)
3.11 {
3.12 - return proponent.getSlot(i).getValue();
3.13 + int v = proponent.getSlot(i).getVitality();
3.14 +
3.15 + if(v > 0)
3.16 + {
3.17 + return proponent.getSlot(i).getValue();
3.18 + }
3.19 + else
3.20 + {
3.21 + throw new ICFPCException();
3.22 + }
3.23 }
3.24 else
3.25 {
4.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Help.java Sun Jun 19 14:30:33 2011 +0400
4.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Help.java Sun Jun 19 15:04:59 2011 +0400
4.3 @@ -24,27 +24,35 @@
4.4 {
4.5 int i = ((Value)iobj).getValue();
4.6 int n = ((Value)nobj).getValue();
4.7 - int v = proponent.getSlot(i).getVitality();
4.8
4.9 - if(i >= 0 && i <= 255 && n <= v)
4.10 + if(i >= 0 && i <= 255)
4.11 {
4.12 - if(jobj instanceof Value)
4.13 + int v = proponent.getSlot(i).getVitality();
4.14 +
4.15 + if(n <= v)
4.16 {
4.17 - int j = ((Value)jobj).getValue();
4.18 -
4.19 - if(j >= 0 && j <= 255)
4.20 + if(jobj instanceof Value)
4.21 {
4.22 - int w = proponent.getSlot(j).getVitality();
4.23 + int j = ((Value)jobj).getValue();
4.24
4.25 - if(w > 0)
4.26 + if(j >= 0 && j <= 255)
4.27 {
4.28 - int winc = (int) Math.floor(11 * n / 10);
4.29 - int resw = w + winc;
4.30 + int w = proponent.getSlot(j).getVitality();
4.31
4.32 - proponent.getSlot(j).setVitality(resw > 65535 ? 65535 : resw);
4.33 + if(w > 0)
4.34 + {
4.35 + int winc = (int) Math.floor(11 * n / 10);
4.36 + int resw = w + winc;
4.37 +
4.38 + proponent.getSlot(j).setVitality(resw > 65535 ? 65535 : resw);
4.39 + }
4.40 +
4.41 + return new I();
4.42 }
4.43 -
4.44 - return new I();
4.45 + else
4.46 + {
4.47 + throw new ICFPCException();
4.48 + }
4.49 }
4.50 else
4.51 {
5.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Revive.java Sun Jun 19 14:30:33 2011 +0400
5.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Revive.java Sun Jun 19 15:04:59 2011 +0400
5.3 @@ -8,17 +8,22 @@
5.4 public class Revive implements ICard
5.5 {
5.6 @Override
5.7 - public IValue returnValue(IValue value, Player proponent, Player opponent)
5.8 + public IValue returnValue(IValue iobj, Player proponent, Player opponent)
5.9 {
5.10 - if (value.getClass().equals(Value.class))
5.11 + if (iobj instanceof Value)
5.12 {
5.13 - int i = ((Value)value).getValue();
5.14 - if (i >= 0 && i < 256)
5.15 + int i = ((Value)iobj).getValue();
5.16 +
5.17 + if (i >= 0 && i <= 255)
5.18 {
5.19 - if (proponent.getSlot(i).getVitality() <= 0)
5.20 + int v = proponent.getSlot(i).getVitality();
5.21 +
5.22 + if (v <= 0)
5.23 {
5.24 proponent.getSlot(i).setVitality(1);
5.25 }
5.26 +
5.27 + return new I();
5.28 }
5.29 else
5.30 {
5.31 @@ -29,6 +34,5 @@
5.32 {
5.33 throw new ICFPCException();
5.34 }
5.35 - return new I();
5.36 }
5.37 }
6.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Zombie.java Sun Jun 19 14:30:33 2011 +0400
6.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Zombie.java Sun Jun 19 15:04:59 2011 +0400
6.3 @@ -1,5 +1,6 @@
6.4 package ru.alphatech.icfpc.cards;
6.5
6.6 +import ru.alphatech.icfpc.game.ICFPCException;
6.7 import ru.alphatech.icfpc.game.IValue;
6.8 import ru.alphatech.icfpc.game.Player;
6.9 import ru.alphatech.icfpc.game.Value;
6.10 @@ -7,23 +8,42 @@
6.11 public class Zombie implements ICard
6.12 {
6.13 @Override
6.14 - public IValue returnValue(final IValue iVal, Player proponent, Player opponent)
6.15 + public IValue returnValue(final IValue iobj, Player proponent, Player opponent)
6.16 {
6.17 return new ICard()
6.18 {
6.19 @Override
6.20 public IValue returnValue(final IValue x, Player proponent, Player opponent)
6.21 {
6.22 - if (iVal.getClass().equals(Value.class))
6.23 + if (iobj instanceof Value)
6.24 {
6.25 - int i = ((Value)iVal).getValue();
6.26 - if (i >= 0 && i < 256)
6.27 + int i = ((Value)iobj).getValue();
6.28 +
6.29 + if (i >= 0 && i <= 255)
6.30 {
6.31 - opponent.getSlot(i).putValue(x);
6.32 - opponent.getSlot(i).setVitality(-1);
6.33 + int v = opponent.getSlot(255 - i).getVitality();
6.34 +
6.35 + if(v <= 0)
6.36 + {
6.37 + opponent.getSlot(255 - i).putValue(x);
6.38 + opponent.getSlot(255 - i).setVitality(-1);
6.39 +
6.40 + return new I();
6.41 + }
6.42 + else
6.43 + {
6.44 + throw new ICFPCException();
6.45 + }
6.46 + }
6.47 + else
6.48 + {
6.49 + throw new ICFPCException();
6.50 }
6.51 }
6.52 - return new I();
6.53 + else
6.54 + {
6.55 + throw new ICFPCException();
6.56 + }
6.57 }
6.58 };
6.59 }