1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.firemox.clickable.ability;
24
25 import java.io.IOException;
26 import java.io.InputStream;
27
28 import net.sf.firemox.clickable.target.card.MCard;
29 import net.sf.firemox.event.MEventListener;
30 import net.sf.firemox.event.context.ContextEventListener;
31 import net.sf.firemox.stack.StackManager;
32
33 /***
34 * TODO is it important to keep cost ?
35 *
36 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
37 * @since 0.80
38 */
39 public class ReplacementAbility extends TriggeredAbility {
40
41 /***
42 * Creates a new instance of ReplacementAbility <br>
43 * <ul>
44 * Structure of InputStream : Data[size]
45 * <li>super [ActivatedAbility]</li>
46 * </ul>
47 *
48 * @param input
49 * stream containing this ability
50 * @param card
51 * referenced card owning this ability.
52 * @throws IOException
53 * if error occurred during the reading process from the specified
54 * input stream
55 */
56 public ReplacementAbility(InputStream input, MCard card) throws IOException {
57 super(input, card);
58 }
59
60 /***
61 * Create a fresh instance from another instance of ReplacementAbility
62 *
63 * @param other
64 * the instance to clone.
65 * @param event
66 * The attached activation event.
67 */
68 private ReplacementAbility(ReplacementAbility other, MEventListener event) {
69 super(other, event);
70 }
71
72 @Override
73 public boolean triggerIt(ContextEventListener context) {
74 throw new InternalError("Replacement ability cannot trigger");
75 }
76
77 @Override
78 public void resolveStack() {
79
80
81
82
83
84 if (optimizer == Optimization.action) {
85 StackManager.actionManager.setHop(1);
86 }
87 StackManager.resolveStack();
88 }
89
90 @Override
91 public Ability clone(MCard container) {
92 return new ReplacementAbility(this, eventComing.clone(container));
93 }
94
95 @Override
96 public boolean isMatching() {
97
98
99
100
101 return !StackManager.isPlaying(this);
102 }
103
104 @Override
105 public void removeFromManager() {
106 priority.removeFromManager(this);
107 if (delayedCard != null) {
108
109 StackManager.getSpellController().zoneManager.delayedBuffer
110 .remove(delayedCard);
111
112 delayedCard.removeFromManager();
113 delayedCard = null;
114 }
115 }
116
117 @Override
118 public final boolean isAutoResolve() {
119 return true;
120 }
121
122 @Override
123 public final boolean isHidden() {
124 return true;
125 }
126
127 @Override
128 public final boolean hasHighPriority() {
129 return true;
130 }
131
132 @Override
133 public void registerToManager() {
134 priority.registerToManager(this);
135 }
136 }