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.ICFPCException; |
4 import ru.alphatech.icfpc.game.IValue; |
4 import ru.alphatech.icfpc.game.IValue; |
5 import ru.alphatech.icfpc.game.Player; |
5 import ru.alphatech.icfpc.game.Player; |
|
6 import ru.alphatech.icfpc.game.Run; |
6 import ru.alphatech.icfpc.game.Value; |
7 import ru.alphatech.icfpc.game.Value; |
7 |
8 |
8 public class Attack implements ICard |
9 public class Attack implements ICard |
9 { |
10 { |
|
11 @Override |
|
12 public String getName() { |
|
13 return "attack"; |
|
14 } |
|
15 |
10 @Override |
16 @Override |
11 public IValue returnValue(final IValue iobj, Player proponent, Player opponent) |
17 public IValue returnValue(final IValue iobj, Player proponent, Player opponent) |
12 { |
18 { |
13 return new ICard() |
19 return new ICard() |
14 { |
20 { |
15 @Override |
21 @Override |
|
22 public String getName() { |
|
23 return ""; |
|
24 } |
|
25 |
|
26 @Override |
16 public IValue returnValue(final IValue jobj, Player proponent, Player opponent) |
27 public IValue returnValue(final IValue jobj, Player proponent, Player opponent) |
17 { |
28 { |
18 return new ICard() |
29 return new ICard() |
19 { |
30 { |
|
31 @Override |
|
32 public String getName() { |
|
33 return ""; |
|
34 } |
20 @Override |
35 @Override |
21 public IValue returnValue(final IValue nobj, Player proponent, Player opponent) |
36 public IValue returnValue(final IValue nobj, Player proponent, Player opponent) |
22 { |
37 { |
23 if(iobj instanceof Value && nobj instanceof Value) |
38 if(iobj instanceof Value && nobj instanceof Value) |
24 { |
39 { |
37 |
52 |
38 if(j >= 0 && j <= 255) |
53 if(j >= 0 && j <= 255) |
39 { |
54 { |
40 int w = opponent.getSlot(255 - j).getVitality(); |
55 int w = opponent.getSlot(255 - j).getVitality(); |
41 |
56 |
42 if (w > 0) |
57 if(Run.getAutoMode()) |
43 { |
58 { |
44 int wdec = (int) Math.floor(9 * n / 10); |
59 if(w > 0) |
45 int resw = w - wdec; |
60 { |
|
61 int wdec = (int) Math.floor(9 * n / 10); |
|
62 int resw = w + wdec; |
46 |
63 |
47 opponent.getSlot(255 - j).setVitality(resw < 0 ? 0 : w); |
64 opponent.getSlot(255 - j).setVitality(resw > 65535 ? 65535 : w); |
|
65 } |
48 } |
66 } |
|
67 else |
|
68 { |
|
69 if (w > 0) |
|
70 { |
|
71 int wdec = (int) Math.floor(9 * n / 10); |
|
72 int resw = w - wdec; |
|
73 |
|
74 opponent.getSlot(255 - j).setVitality(resw < 0 ? 0 : w); |
|
75 } |
|
76 } |
49 |
77 |
50 return new I(); |
78 return new I(); |
51 } |
79 } |
52 else |
80 else |
53 { |
81 { |