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.stack.phasetype;
23
24 import java.io.IOException;
25 import java.io.InputStream;
26
27 import net.sf.magicproject.clickable.targetable.card.MCard;
28
29 /***
30 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
31 * @since 0.60
32 */
33 public class MiddleResolution extends StackCondition {
34
35 /***
36 * Creates a new instance of MiddleResolution <br>
37 * <ul>
38 * Structure of InputStream : Data[size]
39 * <li>playable idCards for current player [2]</li>
40 * <li>playable idCards for non-current player [2]</li>
41 * </ul>
42 *
43 * @param inputStream
44 * @throws IOException
45 */
46 MiddleResolution(InputStream inputStream) throws IOException {
47 super(inputStream);
48 }
49
50 /***
51 * Tell if a player can cast a card with this idCard.
52 *
53 * @param idCard
54 * id of card we would casting
55 * @param isYou
56 * is the current player waiting for that
57 * @return true if the player can cast a card with this idCard
58 */
59 @Override
60 public boolean canICast(int idCard, boolean isYou) {
61 if (isYou) {
62 return idCardsForYOU != 0
63 && (idCard == 0 || MCard.intersectionIdCard(idCardsForYOU, idCard));
64 }
65 return idCardsForOPPONENT != 0
66 && (idCard == 0 || MCard.intersectionIdCard(idCardsForOPPONENT, idCard));
67 }
68
69 }