View Javadoc

1   /*
2    * Created on Aug 5, 2004 
3    * Original filename was StackCondition.java
4    * 
5    *   Magic-Project is a turn based strategy simulator
6    *   Copyright (C) 2003-2007 Fabrice Daugan
7    *
8    *   This program is free software; you can redistribute it and/or modify it 
9    * under the terms of the GNU General Public License as published by the Free 
10   * Software Foundation; either version 2 of the License, or (at your option) any
11   * later version.
12   *
13   *   This program is distributed in the hope that it will be useful, but WITHOUT 
14   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
16   * details.
17   *
18   *   You should have received a copy of the GNU General Public License along  
19   * with this program; if not, write to the Free Software Foundation, Inc., 
20   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21   * 
22   */
23  package net.sf.magicproject.stack.phasetype;
24  
25  import java.io.IOException;
26  import java.io.InputStream;
27  
28  import net.sf.magicproject.tools.MToolKit;
29  
30  /***
31   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
32   * @since 0.60
33   */
34  public abstract class StackCondition {
35  
36  	/***
37  	 * Creates a new instance of StackCondition <br>
38  	 * <ul>
39  	 * Structure of InputStream : Data[size]
40  	 * <li>playable idCards for current player [2]</li>
41  	 * <li>playable idCards for non-current player [2]</li>
42  	 * </ul>
43  	 * 
44  	 * @param inputStream
45  	 * @throws IOException
46  	 */
47  	protected StackCondition(InputStream inputStream) throws IOException {
48  		idCardsForYOU = MToolKit.readInt16(inputStream);
49  		idCardsForOPPONENT = MToolKit.readInt16(inputStream);
50  	}
51  
52  	/***
53  	 * Tell if a player can cast a card with this idCard.
54  	 * 
55  	 * @param idCard
56  	 *          id of card we would casting
57  	 * @param isYou
58  	 *          is the current player waiting for that
59  	 * @return true if the player can cast a card with this idCard
60  	 */
61  	public abstract boolean canICast(int idCard, boolean isYou);
62  
63  	/***
64  	 * IdCard that current player can play during this phase
65  	 */
66  	public int idCardsForYOU;
67  
68  	/***
69  	 * IdCard that non-current player can play during this phase
70  	 */
71  	public int idCardsForOPPONENT;
72  
73  }