View Javadoc

1   /*   Magic-Project is a turn based strategy simulator
2    *   Copyright (C) 2003-2007 Fabrice Daugan
3    *
4    *   This program is free software; you can redistribute it and/or modify it 
5    * under the terms of the GNU General Public License as published by the Free 
6    * Software Foundation; either version 2 of the License, or (at your option) any
7    * later version.
8    *
9    *   This program is distributed in the hope that it will be useful, but WITHOUT 
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
12   * details.
13   *
14   *   You should have received a copy of the GNU General Public License along  
15   * with this program; if not, write to the Free Software Foundation, Inc., 
16   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17   */
18  package net.sf.magicproject.clickable.targetable.card;
19  
20  import java.awt.event.ActionEvent;
21  
22  import javax.swing.JTabbedPane;
23  
24  import net.sf.magicproject.clickable.targetable.Targetable;
25  import net.sf.magicproject.clickable.targetable.TargetableFactory;
26  import net.sf.magicproject.clickable.targetable.player.Player;
27  import net.sf.magicproject.database.DatabaseFactory;
28  import net.sf.magicproject.stack.StackManager;
29  import net.sf.magicproject.token.IdZones;
30  import net.sf.magicproject.ui.MagicUIComponents;
31  import net.sf.magicproject.zone.ExpandableZone;
32  import net.sf.magicproject.zone.MZone;
33  
34  /***
35   * MSystemCard.java Created on 5 mars 2004
36   * 
37   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
38   * @since 0.60
39   */
40  public final class SystemCard extends MCard {
41  
42  	/***
43  	 * The unique instance of this class
44  	 */
45  	public static SystemCard instance = new SystemCard();
46  
47  	/***
48  	 * Create a new instance of this class. Private status is there to prevent
49  	 * user to instanciate this class
50  	 */
51  	private SystemCard() {
52  		super();
53  		this.database = DatabaseFactory.getDatabase(null, CardFactory
54  				.getCardModel("system"), null);
55  		idZone = IdZones.PLAY;
56  	}
57  
58  	@Override
59  	public Player getController() {
60  		return StackManager.activePlayer();
61  	}
62  
63  	@Override
64  	public void actionPerformed(ActionEvent evt) {
65  		final String action = evt.getActionCommand();
66  		final MZone container = TargetableFactory.triggerTargetable.getContainer();
67  		if (action == CardFactory.STR_GATHER || action == CardFactory.STR_EXPAND) {
68  			// expand/gather container
69  			((ExpandableZone) container).toggle();
70  			// } else if (evt.getSource() == CardFactory.javaDebugItem) {
71  			// TODO java debug option
72  		} else if (evt.getSource() == CardFactory.databaseCardInfoItem) {
73  			((JTabbedPane) MagicUIComponents.databasePanel.getParent())
74  					.setSelectedComponent(MagicUIComponents.databasePanel);
75  		}
76  	}
77  
78  	@Override
79  	public void decrementTimestampReference(int timestamp) {
80  		// Nothing to do
81  	}
82  
83  	@Override
84  	public void addTimestampReference() {
85  		// Nothing to do
86  	}
87  
88  	@Override
89  	public Targetable getLastKnownTargetable(int timeStamp) {
90  		return this;
91  	}
92  
93  	@Override
94  	public String toString() {
95  		return "system";
96  	}
97  }