equal
deleted
inserted
replaced
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 Attack implements ICard |
8 public class Attack implements ICard |
22 if (i.getClass().equals(Value.class) && j.getClass().equals(Value.class) && n.getClass().equals(Value.class)) |
23 if (i.getClass().equals(Value.class) && j.getClass().equals(Value.class) && n.getClass().equals(Value.class)) |
23 { |
24 { |
24 int ival = ((Value)i).getValue(); |
25 int ival = ((Value)i).getValue(); |
25 int jval = ((Value)j).getValue(); |
26 int jval = ((Value)j).getValue(); |
26 int nval = ((Value)n).getValue(); |
27 int nval = ((Value)n).getValue(); |
27 proponent.getSlot(ival).setVitality(proponent.getSlot(ival).getVitality() - nval); |
28 |
28 opponent.getSlot(255 - jval).setVitality(opponent.getSlot(255 - jval).getVitality() - ((9 * nval)/10)); |
29 if (ival >= 0 && ival < 256 && jval >= 0 && jval < 256) |
29 return new ICard() |
|
30 { |
30 { |
31 @Override |
31 int v = proponent.getSlot(ival).getVitality(); |
32 public IValue returnValue(IValue value, Player proponent, Player opponent) |
32 int w = opponent.getSlot(255 - jval).getVitality(); |
|
33 if (v - nval < 1) |
33 { |
34 { |
34 return value; |
35 proponent.getSlot(ival).setVitality(v - nval); |
|
36 if (w > 0) |
|
37 { |
|
38 opponent.getSlot(255 - jval).setVitality(w - ((9 * nval)/10)); |
|
39 } |
35 } |
40 } |
36 }; |
41 else |
|
42 { |
|
43 throw new ICFPCException(); |
|
44 } |
|
45 } |
|
46 else |
|
47 { |
|
48 throw new ICFPCException(); |
|
49 } |
37 } |
50 } |
38 return null; |
51 else |
|
52 { |
|
53 throw new ICFPCException(); |
|
54 } |
|
55 return new I(); |
39 } |
56 } |
40 }; |
57 }; |
41 } |
58 } |
42 }; |
59 }; |
43 } |
60 } |