Code Search for Developers
 
 
  

PlayAction.java from The Geronimo Project at Krugle


Show PlayAction.java syntax highlighted

package geronimo.hoshigo.control.player;

import geronimo.hoshigo.model.game.Game;
import geronimo.hoshigo.model.game.HumanPlayer;
import geronimo.hoshigo.model.goban.Vertex;

import org.eclipse.jface.action.Action;

public class PlayAction extends Action
{
	private static PlayAction instance;

	private Game   selectedGame;
	private Vertex selectedVertex;
	
	/**
	 * Constructeur. Il est privé car on ne peut créer qu'une instance de cette
	 * classe.
	 * @see AnyColorPassAction#getInstance()
	 */
	private PlayAction()
	{
		super();
	}
	
	/**
	 * Accès à l'instance
	 * @return Retourne l'instance de la classe
	 */
	public static synchronized PlayAction getInstance()
	{
		// Création de l'instance au premier appel
		if( PlayAction.instance == null )
		{
			PlayAction.instance = new PlayAction();
		}
		return PlayAction.instance;
	}
	
	/**
	 * Changement de la partie active.
	 * @param game Nouvelle partie courante
	 */
	public void setActiveGame(Game game)
	{
		this.selectedGame = game;
		this.setEnabled(false);
	}
	
	/**
	 * Changement de la position selectionnee
	 * @param vertex Nouvelle position, ou null
	 */
	public void setSelectedVertex(Vertex vertex)
	{
		this.selectedVertex = vertex;
		this.setEnabled(this.selectedGame != null && this.selectedVertex != null
			&& this.selectedGame.currentGameState.getGoban().isEmptyAt(this.selectedVertex) );
	}
	
	/**
	 * Lancement de l'action
	 */
	public final void run()
	{
		if( this.selectedGame != null && this.selectedVertex != null 
				&& this.selectedGame.currentGameState.getGoban().isEmptyAt(this.selectedVertex) )
		{
			HumanPlayer player = (HumanPlayer)this.selectedGame.getCurrentPlayer();
			player.play(this.selectedVertex);
		}
	}
}




See more files for this project here

The Geronimo Project

The Geronimo project concists of two software :\n- Geronimo Hoshigo : a playable graphical user interface to play Go\n- Geronimo Margo : a artificial intelligence program which plays Go

Project homepage: http://sourceforge.net/projects/geronimo
Programming language(s): Java,Pascal,Perl,PHP
License: gpl2

  AnyColorPassAction.java
  BlackPassAction.java
  PassAction.java
  PlayAction.java
  PlayerActionManager.java
  WhitePassAction.java