1 package ru.alphatech.icfpc.cards; |
1 package ru.alphatech.icfpc.cards; |
2 |
2 |
|
3 import ru.alphatech.icfpc.game.ICFPCException; |
3 import ru.alphatech.icfpc.game.IValue; |
4 import ru.alphatech.icfpc.game.IValue; |
4 import ru.alphatech.icfpc.game.Player; |
5 import ru.alphatech.icfpc.game.Player; |
5 import ru.alphatech.icfpc.game.Value; |
6 import ru.alphatech.icfpc.game.Value; |
6 |
7 |
7 public class Zombie implements ICard |
8 public class Zombie implements ICard |
8 { |
9 { |
9 @Override |
10 @Override |
10 public IValue returnValue(final IValue iVal, Player proponent, Player opponent) |
11 public IValue returnValue(final IValue iobj, Player proponent, Player opponent) |
11 { |
12 { |
12 return new ICard() |
13 return new ICard() |
13 { |
14 { |
14 @Override |
15 @Override |
15 public IValue returnValue(final IValue x, Player proponent, Player opponent) |
16 public IValue returnValue(final IValue x, Player proponent, Player opponent) |
16 { |
17 { |
17 if (iVal.getClass().equals(Value.class)) |
18 if (iobj instanceof Value) |
18 { |
19 { |
19 int i = ((Value)iVal).getValue(); |
20 int i = ((Value)iobj).getValue(); |
20 if (i >= 0 && i < 256) |
21 |
|
22 if (i >= 0 && i <= 255) |
21 { |
23 { |
22 opponent.getSlot(i).putValue(x); |
24 int v = opponent.getSlot(255 - i).getVitality(); |
23 opponent.getSlot(i).setVitality(-1); |
25 |
|
26 if(v <= 0) |
|
27 { |
|
28 opponent.getSlot(255 - i).putValue(x); |
|
29 opponent.getSlot(255 - i).setVitality(-1); |
|
30 |
|
31 return new I(); |
|
32 } |
|
33 else |
|
34 { |
|
35 throw new ICFPCException(); |
|
36 } |
|
37 } |
|
38 else |
|
39 { |
|
40 throw new ICFPCException(); |
24 } |
41 } |
25 } |
42 } |
26 return new I(); |
43 else |
|
44 { |
|
45 throw new ICFPCException(); |
|
46 } |
27 } |
47 } |
28 }; |
48 }; |
29 } |
49 } |
30 } |
50 } |