View Javadoc

1   /*
2    *   Magic-Project is a turn based strategy simulator
3    *   Copyright (C) 2003-2007 Fabrice Daugan
4    *
5    *   This program is free software; you can redistribute it and/or modify it 
6    * under the terms of the GNU General Public License as published by the Free 
7    * Software Foundation; either version 2 of the License, or (at your option) any
8    * later version.
9    *
10   *   This program is distributed in the hope that it will be useful, but WITHOUT 
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
13   * details.
14   *
15   *   You should have received a copy of the GNU General Public License along  
16   * with this program; if not, write to the Free Software Foundation, Inc., 
17   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 }