View Javadoc

1   /*
2    *   Firemox 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   */
20  package net.sf.firemox.modifier;
21  
22  import net.sf.firemox.action.AddModifierFromStaticModifier;
23  import net.sf.firemox.clickable.ability.TriggeredStaticModifierAbility;
24  import net.sf.firemox.event.MovedCard;
25  import net.sf.firemox.modifier.model.ModifierModel;
26  import net.sf.firemox.test.InZone;
27  import net.sf.firemox.test.TestOn;
28  import net.sf.firemox.test.True;
29  import net.sf.firemox.token.IdZones;
30  
31  /***
32   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
33   * @since 0.86 Any event interfering with the filter-test make this
34   *        static-modifier to be re-evaluated for the concerned card.
35   */
36  public class StaticModifier extends Modifier {
37  
38  	/***
39  	 * Creates a new instance of StaticModifier <br>
40  	 * 
41  	 * @param context
42  	 *          the modifier context.
43  	 * @param modifiers
44  	 *          are the modifiers attached to this static way to attach globally
45  	 *          card in the looked for zone.
46  	 * @param filterZone
47  	 *          is the looked for zone where this modifier can be added. Only
48  	 *          components in this zone are affected by this modifier.
49  	 */
50  	public StaticModifier(ModifierContext context, ModifierModel[] modifiers,
51  			int filterZone) {
52  		super(context);
53  
54  		// we add the trigger looking for new cards coming into the zone
55  		if (filterZone != IdZones.ANYWHERE) {
56  			final TriggeredStaticModifierAbility refreshAbility = new TriggeredStaticModifierAbility(
57  					new MovedCard(filterZone, True.getInstance(), new InZone(filterZone,
58  							TestOn.TESTED), ability.getCard()),
59  					new AddModifierFromStaticModifier(modifiers), ability.getCard(),
60  					modifiers);
61  			abilities.add(refreshAbility);
62  			refreshAbility.registerToManager();
63  		}
64  	}
65  
66  	@Override
67  	public void refresh() {
68  		// TODO remove refresh ability of this modifier
69  		// Ignored : throw new InternalError("This modifier cannot be refreshed this
70  		// way");
71  	}
72  
73  }