2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
* You should have received a copy of the GNU General Public License
11
* along with this program; if not, write to the Free Software
12
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* Created on October 14, 2001, 7:28 AM
21
package games.strategy.engine.data;
23
import java.util.Properties;
25
import games.strategy.engine.delegate.*;
28
* A single step in a game.<p>
30
* Typically turn based strategy games are composed of a set of distinct phases (in chess this would
31
* be two, white move, black move).
34
* @author Sean Bridges
37
public class GameStep extends GameDataComponent
39
private final String m_name;
40
private final String m_displayName;
41
private final PlayerID m_player;
42
private final String m_delegate;
43
private int m_hashCode = -1;
44
private int m_runCount = 0;
45
private int m_maxRunCount = -1;
46
private final Properties m_properties;
49
/** Creates new GameStep */
50
public GameStep(String name, String displayName, PlayerID player, IDelegate delegate, GameData data, Properties stepProperties)
54
m_displayName = displayName;
56
m_delegate = delegate.getName();
57
m_properties = stepProperties;
60
public String getName()
65
public PlayerID getPlayerID()
70
public IDelegate getDelegate()
72
return getData().getDelegateList().getDelegate(m_delegate);
75
public boolean equals(Object o)
77
if(o == null || ! (o instanceof GameStep))
80
GameStep other = (GameStep) o;
82
return other.m_name.equals(this.m_name) &&
83
other.m_delegate.equals(this.m_delegate) &&
84
other.m_player.equals(this.m_player);
87
public boolean hasReachedMaxRunCount()
89
if(m_maxRunCount == -1)
91
return m_maxRunCount <= m_runCount;
94
public int getRunCount()
99
public void incrementRunCount()
104
public void setMaxRunCount(int count)
106
m_maxRunCount = count;
109
public int getMaxRunCount()
111
return m_maxRunCount;
114
public int hashCode()
118
String s = m_name + m_delegate + m_player;
119
m_hashCode = s.hashCode();
125
public String getDisplayName()
127
if(m_displayName == null)
128
return getDelegate().getDisplayName();
130
return m_displayName;
133
public Properties getProperties()