Permalink
Browse files

Renaming and comments

  • Loading branch information...
1 parent 4c43036 commit dc316bc3a1d44c9d751391b5c02345d743af8c3f @lrozenblyum committed Jan 1, 2013
@@ -3,7 +3,7 @@
import com.leokom.chess.framework.DrawOfferedListener;
import com.leokom.chess.framework.Player;
-import com.leokom.chess.framework.PlayerMovedListener;
+import com.leokom.chess.framework.NeedToGoListener;
import com.leokom.chess.gui.winboard.WinboardFactory;
import org.apache.log4j.Logger;
@@ -22,9 +22,9 @@ public static void main( String[] args ) {
final Player player = WinboardFactory.getPlayer();
- final PlayerMovedListener onMovePlayerMovedListener = new MoveListener( player );
+ final NeedToGoListener onMoveNeedToGoListener = new MoveListener( player );
- player.onMoved( onMovePlayerMovedListener );
+ player.onMoved( onMoveNeedToGoListener );
player.onDrawOffered( new DrawOfferedListener() {
@Override
public void anotherPlayerOfferedDraw() {
@@ -40,7 +40,7 @@ public void anotherPlayerOfferedDraw() {
/**
* Basic implementation of 'on move allowed'
*/
- private static class MoveListener implements PlayerMovedListener {
+ private static class MoveListener implements NeedToGoListener {
//TODO: this moveNumber is totally unreliable (after end-of-game it must be reset)
private int moveNumber;
private final Player anotherPlayer;
@@ -51,7 +51,7 @@ public MoveListener( Player anotherPlayer ) {
}
@Override
- public void anotherPlayerMoved( String move ) {
+ public void anotherPlayerMoved( String anotherPlayerMove ) {
moveNumber++;
logger.info( "Detected allowance to go. Move number = " + moveNumber );
switch ( moveNumber ) {
@@ -0,0 +1,19 @@
+package com.leokom.chess.framework;
+
+/**
+ * Listener to fact that we need to go
+ * Author: Leonid
+ * Date-time: 20.08.12 19:38
+ */
+public interface NeedToGoListener {
+ //for sure in next versions it may be some Command object so that
+ //it's NOT dependent on xboard.
+
+ /**
+ * React on another player's move
+ * If it's null - means it's our first move
+ * which we must execute
+ * @param anotherPlayerMove
+ */
+ void anotherPlayerMoved( String anotherPlayerMove );
+}
@@ -1,23 +1,21 @@
package com.leokom.chess.framework;
-import com.leokom.chess.framework.DrawOfferedListener;
-
/**
* Engine-agnostic player.
* This interface is suggested to be common chess player abstraction
* (independent of the fact the player is represented by a chess engine,
* a human or a winboard-protocol )
*/
-public interface Player extends PlayerMovedListener, DrawOfferedListener, ResignListener {
+public interface Player extends NeedToGoListener, DrawOfferedListener, ResignListener {
//may create attach - now it's over-projecting - 1 is OK
/**
* Set up listener for the event 'moved'.
* It means: current player has executed the move
* and informs the interested subscriber (currently only 1)
* about this
- * @param playerMovedListenerToSet
+ * @param needToGoListenerToSet
*/
- void onMoved( PlayerMovedListener playerMovedListenerToSet );
+ void onMoved( NeedToGoListener needToGoListenerToSet );
//TODO: think if it's player's property
void run();
@@ -1,12 +0,0 @@
-package com.leokom.chess.framework;
-
-/**
- * General listener to some command received
- * Author: Leonid
- * Date-time: 20.08.12 19:38
- */
-public interface PlayerMovedListener {
- //for sure in next versions it may be some Command object so that
- //it's NOT dependent on xboard.
- void anotherPlayerMoved( String move );
-}
@@ -2,7 +2,7 @@
import com.leokom.chess.framework.DrawOfferedListener;
import com.leokom.chess.framework.Player;
-import com.leokom.chess.framework.PlayerMovedListener;
+import com.leokom.chess.framework.NeedToGoListener;
import org.apache.log4j.Logger;
/**
@@ -12,7 +12,7 @@
* Date-time: 20.08.12 19:28
*/
public class WinboardPlayer implements Player {
- private PlayerMovedListener playerMovedListener;
+ private NeedToGoListener needToGoListener;
private Logger logger = Logger.getLogger( this.getClass() );
private WinboardCommander commander;
private boolean needQuit = false;
@@ -47,14 +47,14 @@ public void execute() {
@Override
public void execute( String move ) {
//TODO: prove this parameter passing
- playerMovedListener.anotherPlayerMoved( move );
+ needToGoListener.anotherPlayerMoved( move );
}
} );
commander.onGo( new GoListener() {
@Override
public void execute() {
- playerMovedListener.anotherPlayerMoved( null );
+ needToGoListener.anotherPlayerMoved( null );
}
} );
@@ -76,8 +76,8 @@ public void execute( int protocolVersion ) {
//may create attach - now it's over-projecting - 1 is OK
@Override
- public void onMoved( PlayerMovedListener playerMovedListenerToSet ) {
- this.playerMovedListener = playerMovedListenerToSet;
+ public void onMoved( NeedToGoListener needToGoListenerToSet ) {
+ this.needToGoListener = needToGoListenerToSet;
}
/**
@@ -106,8 +106,8 @@ public void execute() {
//listener to another player's move
@Override
- public void anotherPlayerMoved( String move ) {
- commander.anotherPlayerMoved( move );
+ public void anotherPlayerMoved( String anotherPlayerMove ) {
+ commander.anotherPlayerMoved( anotherPlayerMove );
}
@Override

0 comments on commit dc316bc

Please sign in to comment.