1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.magicproject.clickable.ability;
20
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.util.Collection;
24
25 import net.sf.magicproject.action.MAction;
26 import net.sf.magicproject.clickable.targetable.card.MCard;
27 import net.sf.magicproject.clickable.targetable.player.Player;
28 import net.sf.magicproject.event.MEventListener;
29 import net.sf.magicproject.test.TestOn;
30 import net.sf.magicproject.token.TrueFalseAuto;
31
32 /***
33 * An activited ability associated to a player.
34 *
35 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
36 * @since 0.90
37 */
38 public class ActivatedAbilityPlayer extends ActivatedAbility {
39
40 /***
41 * Creates a new instance of ActivatedAbility <br>
42 * <ul>
43 * Structure of InputStream : Data[size]
44 * <li>ability type [1]</li>
45 * <li>name name [String]</li>
46 * <li>ability tags [1]</li>
47 * <li>event [...]</li>
48 * <li>nb of actions for cost part [1]</li>
49 * <li>pay action i [...]</li>
50 * <li>nb of actions for effect part [1]</li>
51 * <li>pay action i [...]</li>
52 * <li>controller [TestOn]</li>
53 * </ul>
54 *
55 * @param inputFile
56 * @param card
57 * @throws IOException
58 */
59 public ActivatedAbilityPlayer(InputStream inputFile, MCard card)
60 throws IOException {
61 super(inputFile, card);
62 controller = TestOn.deserialize(inputFile);
63 }
64
65 @Override
66 public Ability clone(MCard container) {
67 return new ActivatedAbilityPlayer(getName(), actionList, effectList,
68 optimizer, priority, eventComing.clone(container), pictureName,
69 controller, linkedAbilities, playAsSpell);
70 }
71
72 /***
73 * Create an instance of ActivatedAbility
74 *
75 * @param name
76 * Name of card used to display this ability in a stack
77 * @param actionList
78 * list of actions to do for activate this ability
79 * @param effectList
80 * list of effects of this ability
81 * @param optimizer
82 * the optimizer to use.
83 * @param priority
84 * the resolution type.
85 * @param eventComing
86 * event condition of this ability
87 * @param pictureName
88 * the picture name of this ability. If <code>null</code> the card
89 * picture will be used instead.
90 * @param controller
91 * the controller of this ability.
92 * @param linkedAbilities
93 * the linked abilities. May be null.
94 * @param playAsSpell
95 * play-as-spell.
96 */
97 protected ActivatedAbilityPlayer(String name, MAction[] actionList,
98 MAction[] effectList, Optimization optimizer, Priority priority,
99 MEventListener eventComing, String pictureName, TestOn controller,
100 Collection<Ability> linkedAbilities, TrueFalseAuto playAsSpell) {
101 super(name, actionList, effectList, optimizer, priority, eventComing,
102 pictureName, linkedAbilities, playAsSpell);
103 this.controller = controller;
104 }
105
106 @Override
107 public Player getController() {
108 return controller.getPlayer(this, null);
109 }
110
111 /***
112 * The player controlling this ability.
113 */
114 private TestOn controller;
115 }