1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.magicproject.modifier;
21
22 import java.util.List;
23
24 import net.sf.magicproject.action.AddModifierFromStaticModifier;
25 import net.sf.magicproject.clickable.ability.Ability;
26 import net.sf.magicproject.clickable.ability.TriggeredStaticModifierAbility;
27 import net.sf.magicproject.clickable.targetable.card.MCard;
28 import net.sf.magicproject.event.MEventListener;
29 import net.sf.magicproject.event.MovedCard;
30 import net.sf.magicproject.test.InZone;
31 import net.sf.magicproject.test.Test;
32 import net.sf.magicproject.test.True;
33 import net.sf.magicproject.test.TestOn;
34 import net.sf.magicproject.token.IdZones;
35
36 /***
37 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
38 * @since 0.86 Any event interferring with the filter-test make this
39 * static-modifier to be re-evaluated for the concerned card.
40 */
41 public class StaticModifier extends Modifier {
42
43 /***
44 * Creates a new instance of StaticModifier <br>
45 *
46 * @param name
47 * the modifier name
48 * @param to
49 * the component to be attached to
50 * @param ability
51 * is the ability owning this test. The card component of this
52 * ability should correspond to the card owning this test too.
53 * @param whileCondition
54 * the test conditionning the activation of this modifier.
55 * @param linkedEvents
56 * the events to be registered. This events would cause this modifier
57 * to be updated.
58 * @param until
59 * this modifier exists while this test is true.
60 * @param linked
61 * is the creator is linked to this modifier.
62 * @param modifiers
63 * are the modifiers attached to this static way to attach globally
64 * card in the looked for zone.
65 * @param filterZone
66 * is the looked for zone where this modifier can be added. Only
67 * components in this zone are affected by this modifier.
68 * @param sourceZone
69 * is the zone where the static-modifier gets to apply. Default is
70 * zone "play".
71 * @param filterTest
72 * is the test applied on components coming into the
73 * <code>filterZone</code>. This modifier is applied only on these
74 * components if they make this test true.
75 */
76 StaticModifier(String name, MCard to, Ability ability, Test whileCondition,
77 List<MEventListener> linkedEvents, List<MEventListener> until,
78 boolean linked, ModifierModel[] modifiers, int filterZone, int sourceZone) {
79 super(name, to, ability, whileCondition, linkedEvents, until, linked, -1);
80
81
82 if (filterZone != IdZones.ANYWHERE) {
83 final TriggeredStaticModifierAbility refreshAbility = new TriggeredStaticModifierAbility(
84 new MovedCard(sourceZone, True.getInstance(), new InZone(
85 filterZone, TestOn.TESTED), ability.getCard()),
86 new AddModifierFromStaticModifier(modifiers), ability.getCard(),
87 modifiers);
88 abilities.add(refreshAbility);
89 refreshAbility.registerToManager();
90 }
91 }
92
93 @Override
94 public void refresh() {
95
96
97
98 }
99
100 }