View Javadoc

1   /*
2    * Created on 25 feb. 2004
3    * 
4    *   Magic-Project is a turn based strategy simulator
5    *   Copyright (C) 2003-2007 Fabrice Daugan
6    *
7    *   This program is free software; you can redistribute it and/or modify it 
8    * under the terms of the GNU General Public License as published by the Free 
9    * Software Foundation; either version 2 of the License, or (at your option) any
10   * later version.
11   *
12   *   This program is distributed in the hope that it will be useful, but WITHOUT 
13   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
15   * details.
16   *
17   *   You should have received a copy of the GNU General Public License along  
18   * with this program; if not, write to the Free Software Foundation, Inc., 
19   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   */
21  package net.sf.magicproject.test;
22  
23  import java.io.IOException;
24  import java.io.InputStream;
25  import java.util.List;
26  
27  import net.sf.magicproject.annotation.XmlTestElement;
28  import net.sf.magicproject.clickable.ability.Ability;
29  import net.sf.magicproject.clickable.targetable.card.MCard;
30  import net.sf.magicproject.event.FacedDown;
31  import net.sf.magicproject.event.FacedUp;
32  import net.sf.magicproject.event.MEventListener;
33  import net.sf.magicproject.token.IdZones;
34  
35  /***
36   * @author <a href="mailto:hoani.cross@gmail.com">Hoani CROSS</a>
37   * @since 0.90
38   */
39  @XmlTestElement(id = IdTest.IS_FACE_UP)
40  public class IsFaceUp extends TestCard {
41  
42  	/***
43  	 * Create an instance of IsFaceUp by reading a file. Offset's file must
44  	 * pointing on the first byte of this test <br>
45  	 * <ul>
46  	 * Structure of InputStream : Data[size]
47  	 * </ul>
48  	 * 
49  	 * @param inputFile
50  	 *          is the file containing this event
51  	 * @throws IOException
52  	 *           if error occurred during the reading process from the specified
53  	 *           input stream
54  	 */
55  	IsFaceUp(InputStream inputFile) throws IOException {
56  		super(inputFile);
57  	}
58  
59  	@Override
60  	public boolean testCard(Ability ability, MCard tested) {
61  		return on.getCard(ability, tested).visibility.isVisibleForYou();
62  	}
63  
64  	@Override
65  	public void extractTriggeredEvents(List<MEventListener> res, MCard source,
66  			Test globalTest) {
67  		// we wath either Face-down either Face-up event
68  		res.add(new FacedUp(IdZones.PLAY, And.append(new IsTested(on), globalTest),
69  				source));
70  		res.add(new FacedDown(IdZones.PLAY, And
71  				.append(new IsTested(on), globalTest), source));
72  	}
73  }