1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package net.sf.magicproject.action;
23
24 import net.sf.magicproject.action.handler.StandardAction;
25 import net.sf.magicproject.clickable.ability.Ability;
26 import net.sf.magicproject.clickable.targetable.card.MCard;
27 import net.sf.magicproject.event.context.ContextEventListener;
28 import net.sf.magicproject.event.context.MContextMtargetable;
29 import net.sf.magicproject.modifier.ModifierModel;
30
31 /***
32 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
33 */
34 public class AddModifierFromStaticModifier extends MAction implements
35 StandardAction {
36
37 /***
38 * Creates a new instance of AddModifierFromStaticModifier <br>
39 *
40 * @param modifiers
41 */
42 public AddModifierFromStaticModifier(ModifierModel... modifiers) {
43 this.modifiers = modifiers;
44 }
45
46 /***
47 * Return the index of this action. As default, this is a zero id
48 *
49 * @return the index of this action.
50 * @see Actiontype
51 */
52 @Override
53 public final Actiontype getIdAction() {
54 return Actiontype.REFRESH_STATIC_MODIFIER;
55 }
56
57 public boolean play(ContextEventListener context, Ability ability) {
58
59
60
61
62 final MContextMtargetable context2 = (MContextMtargetable) context;
63 for (ModifierModel modifierModel : modifiers) {
64 modifierModel.addModifierFromModel(ability, context2.getOriginalCard());
65 }
66 return true;
67 }
68
69 /***
70 * return the string representation of this action
71 *
72 * @param ability
73 * is the ability owning this test. The card component of this
74 * ability should correspond to the card owning this test too.
75 * @return the string representation of this action
76 * @see Object#toString()
77 */
78 @Override
79 public String toString(Ability ability) {
80 return "refresh static modifier : " + trigger;
81 }
82
83 /***
84 * List of static modifiers to add
85 */
86 private ModifierModel[] modifiers;
87
88 /***
89 * The card controlling the modifier
90 */
91 private MCard trigger;
92
93 }