1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.magicproject.test;
21
22 import java.io.InputStream;
23 import java.util.List;
24 import java.util.Map;
25
26 import net.sf.magicproject.clickable.ability.Ability;
27 import net.sf.magicproject.clickable.targetable.Targetable;
28 import net.sf.magicproject.clickable.targetable.card.MCard;
29 import net.sf.magicproject.clickable.targetable.player.Player;
30 import net.sf.magicproject.event.MEventListener;
31 import net.sf.magicproject.event.context.ContextEventListener;
32 import net.sf.magicproject.expression.Expression;
33
34 /***
35 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
36 * @since 0.54
37 */
38 public abstract class Test {
39
40 /***
41 * <ul>
42 * Structure of InputStream : Data[size]
43 * <li>tested on (idTestedOn) [1]</li>
44 * </ul>
45 *
46 * @param inputFile
47 * is the file containing this test
48 */
49 protected Test(InputStream inputFile) {
50
51 }
52
53 /***
54 * Creates a new instance of Test <br>
55 */
56 protected Test() {
57 super();
58 }
59
60 /***
61 * Return this test where values depending on values of this action have been
62 * replaced.
63 *
64 * @param values
65 * are referencable values.
66 * @return a parsed test.
67 * @since 0.85
68 */
69 public Test getConstraintTest(Map<String, Expression> values) {
70 return this;
71 }
72
73 /***
74 * Indicates if the specified card matches with the test to do
75 *
76 * @param ability
77 * is the ability owning this test. The card component of this
78 * ability should correspond to the card owning this test too.
79 * @param tested
80 * the tested card
81 * @return true if the specified card matches with the test to do
82 */
83 public abstract boolean test(Ability ability, Targetable tested);
84
85 /***
86 * Add to the specified list, the events modifying the result of this test.
87 *
88 * @param res
89 * is the list of events to fill
90 * @param source
91 * is the card source of event
92 * @param globalTest
93 * the optional global test to include in the event test.
94 */
95 public void extractTriggeredEvents(List<MEventListener> res, MCard source,
96 Test globalTest) {
97
98 }
99
100 /***
101 * Return the controller making true this test. If several players or no
102 * player can make this test true, the <code>null</code> value is returned.
103 *
104 * @param ability
105 * is the ability owning this test. The card component of this
106 * ability should correspond to the card owning this test too.
107 * @param context
108 * is the context of current ability
109 * @return the controller making true this test. If several player or no
110 * player can make this test true, the <code>null</code> value is
111 * returned.
112 */
113 public Player getOptimizedController(Ability ability,
114 ContextEventListener context) {
115 return null;
116 }
117
118 /***
119 * Indicates if the specified card matches with the test to do.
120 *
121 * @param ability
122 * is the ability owning this test. The card component of this
123 * ability should correspond to the card owning this test too.
124 * @param tested
125 * the tested card
126 * @return true if the specified card matches with the test to do
127 */
128 public boolean testPreemption(Ability ability, Targetable tested) {
129 return test(ability, tested);
130 }
131
132 }