Transitioned code to a more modular build.

This commit is contained in:
Dorian 2013-04-03 17:10:49 -04:00
parent 001f104da7
commit 723966396d
25 changed files with 103 additions and 60 deletions

1
android/local.properties Normal file
View File

@ -0,0 +1 @@
sdk.dir=/home/dorian/Coding/android-sdk-linux

View File

@ -19,10 +19,10 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.android; package org.justcheckers.android;
import main.java.org.justcheckers.game.Game; import org.justcheckers.game.Game;
import main.java.org.justcheckers.game.Rulebook; import org.justcheckers.game.Rulebook;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;

View File

@ -19,14 +19,14 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.android; package org.justcheckers.android;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import main.java.org.justcheckers.common.GlobalConstants; import org.justcheckers.common.GlobalConstants;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;

View File

@ -19,10 +19,10 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.android; package org.justcheckers.android;
import main.java.org.justcheckers.common.GlobalConstants; import org.justcheckers.common.GlobalConstants;
import main.java.org.justcheckers.common.LoggingAndStatistics; import org.justcheckers.common.LoggingAndStatistics;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
@ -59,7 +59,7 @@ public class MenuActivity extends Activity implements OnClickListener {
menuButton.setOnClickListener(this); menuButton.setOnClickListener(this);
// TODO: Move logging info in a better place. // TODO: Move logging info in a better place.
LoggingAndStatistics.logApplicationInfo(this); // LoggingAndStatistics.logApplicationInfo(this);
LoggingAndStatistics.logDeviceAndSystemInfo(); LoggingAndStatistics.logDeviceAndSystemInfo();
} }

View File

@ -19,7 +19,7 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.android; package org.justcheckers.android;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;

View File

@ -32,6 +32,7 @@ repositories {
// Dependency management // Dependency management
dependencies { dependencies {
compile 'jdom:jdom:0.7' compile 'jdom:jdom:0.7'
compile 'org.slf4j:slf4j-api:1.7.5'
testCompile 'org.testng:testng:6.8' testCompile 'org.testng:testng:6.8'
} }

View File

@ -19,7 +19,7 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.common; package org.justcheckers.common;
/** /**
* Organizational class to keep all the constants in. * Organizational class to keep all the constants in.

View File

@ -19,31 +19,39 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.common;import org.justcheckers.android.R; package org.justcheckers.common;
import android.app.Activity; // TODO Resolve this with separation of various platform setups...
import android.os.Build; //import org.justcheckers.android.R;
import android.util.Log; //
//import android.app.Activity;
//import android.os.Build;
//import android.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Functions for logging errors and gathering statistics. * Functions for logging errors and gathering statistics.
* *
* @author Dorian Pula * @author Dorian Pula
*/ */
public class LoggingAndStatistics { public abstract class LoggingAndStatistics {
/** /**
* Logs information about the program. Displays the game's header and * Logs information about the program. Displays the game's header and
* relevant system properties at runtime. * relevant system properties at runtime.
*/ */
public static void logApplicationInfo(Activity caller) { public static void logApplicationInfo(String gameVersion, String gameWebsite) {
String gameVersion = caller.getString(R.string.app_version); // TODO Fix
String gameWebsite = caller.getString(R.string.project_website); // String gameVersion = caller.getString(R.string.app_version);
// String gameWebsite = caller.getString(R.string.project_website);
String appInfo = "justCheckers -- Version:" + gameVersion String appInfo = "justCheckers -- Version:" + gameVersion
+ " - Website: " + gameWebsite; + " - Website: " + gameWebsite;
Log.i("ApplInfo", appInfo); // TODO Clean up...
Logger log = LoggerFactory.getLogger(LoggingAndStatistics.class);
log.info("ApplInfo", appInfo);
} }
/** /**
@ -53,11 +61,14 @@ public class LoggingAndStatistics {
public static void logDeviceAndSystemInfo() { public static void logDeviceAndSystemInfo() {
// System properties. // System properties.
String sysList = "SDK version: " + Build.VERSION.RELEASE // String sysList = "SDK version: " + Build.VERSION.RELEASE
+ " - API: " + Build.VERSION.SDK_INT // + " - API: " + Build.VERSION.SDK_INT
+ " - Device: " + Build.MANUFACTURER + " " + Build.MODEL; // + " - Device: " + Build.MANUFACTURER + " " + Build.MODEL;
// TODO Fix
String sysList = "FIXME";
Log.i("DevSysInfo", sysList); Logger log = LoggerFactory.getLogger(LoggingAndStatistics.class);
log.info("DevSysInfo", sysList);
} }
} }

View File

@ -19,7 +19,7 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.game; package org.justcheckers.game;
/** /**
* Container for the state of the checker board during a game. * Container for the state of the checker board during a game.

View File

@ -19,9 +19,7 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.game; package org.justcheckers.game;
import android.graphics.Point;
/** /**
* The main game handling object of GameLoop. * The main game handling object of GameLoop.
@ -61,7 +59,7 @@ public class Game {
* for a piece whose move has not finished after 1 jump. This point is set * for a piece whose move has not finished after 1 jump. This point is set
* to null if not in use. * to null if not in use.
*/ */
private final Point jumpInProgress; private final IPoint jumpInProgress;
/** Represents the light (usually attacking) player. */ /** Represents the light (usually attacking) player. */
private Player lightPlayer; private Player lightPlayer;
/** Represents whose turn it is. */ /** Represents whose turn it is. */
@ -245,7 +243,7 @@ public class Game {
/** /**
* @return the jumpInProgress * @return the jumpInProgress
*/ */
public Point getJumpInProgress() { public IPoint getJumpInProgress() {
return jumpInProgress; return jumpInProgress;
} }
} }

View File

@ -19,7 +19,7 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.game; package org.justcheckers.game;
/** /**
* @author dpula * @author dpula
@ -76,8 +76,8 @@ public class GameEngine {
if (realPositions && game.getJumpInProgress() != null) { if (realPositions && game.getJumpInProgress() != null) {
// Only allow the piece in movement to be moved. // Only allow the piece in movement to be moved.
if (sourceRow == game.getJumpInProgress().y if (sourceRow == game.getJumpInProgress().getY()
&& sourceCol == game.getJumpInProgress().x) { && sourceCol == game.getJumpInProgress().getX()) {
legalMove = canJump(game, sourceRow, sourceCol, targetRow, legalMove = canJump(game, sourceRow, sourceCol, targetRow,
targetCol); targetCol);
isJump = true; isJump = true;

View File

@ -0,0 +1,14 @@
package org.justcheckers.game;
/**
* @author dorian
* Created 2013-04-03 @ 4:59 PM by IntelliJ IDEA.
*/
public interface IPoint {
public void setX(double x);
public void setY(double y);
public double getX();
public double getY();
}

View File

@ -19,7 +19,7 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.game; package org.justcheckers.game;
/** /**
* Manages the information of a single player. * Manages the information of a single player.

View File

@ -19,7 +19,7 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.game; package org.justcheckers.game;
/** /**
* The rules for a game of checkers. This class provides a reference object for * The rules for a game of checkers. This class provides a reference object for

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
/*************************************************************************** /***************************************************************************
* * * *

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
@ -20,7 +20,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter; import org.jdom.output.XMLOutputter;
import android.util.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*************************************************************************** /***************************************************************************
* * * *
@ -67,7 +68,10 @@ public class ConfigSettingsIO extends XML_IO{
catch(JDOMException e){ catch(JDOMException e){
String msg = "Problem : " + getFile().toString() String msg = "Problem : " + getFile().toString()
+ " is not a well formed XML document"; + " is not a well formed XML document";
Log.e("ConfigSettingsIO", msg);
// TODO Clean up...
Logger log = LoggerFactory.getLogger(UserSettingsIO.class);
log.error("ConfigSettingsIO", msg);
} }
} }
@ -91,7 +95,9 @@ public class ConfigSettingsIO extends XML_IO{
catch(IOException e){ catch(IOException e){
String msg = "Problem : couldn't output to the given file : " String msg = "Problem : couldn't output to the given file : "
+ getFile().toString(); + getFile().toString();
Log.e("ConfigSettingsIO", msg); // TODO Clean up...
Logger log = LoggerFactory.getLogger(ConfigSettingsIO.class);
log.error("ConfigSettingsIO", msg);
} }
} }

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
@ -20,7 +20,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter; import org.jdom.output.XMLOutputter;
import android.util.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/* ************************************************************************** /* **************************************************************************
* * * *
@ -69,7 +70,9 @@ public class GameSettingsIO extends XML_IO{
catch(JDOMException e){ catch(JDOMException e){
String msg = "Problem : " + getFile().toString() String msg = "Problem : " + getFile().toString()
+ " is not a well formed XML document"; + " is not a well formed XML document";
Log.e("GameSettingsIO", msg); // TODO Clean up...
Logger log = LoggerFactory.getLogger(GameSettingsIO.class);
log.error("GameSettingsIO", msg);
} }
} }
@ -93,7 +96,9 @@ public class GameSettingsIO extends XML_IO{
catch(IOException e){ catch(IOException e){
String msg = "Problem : couldn't output to the given file : " String msg = "Problem : couldn't output to the given file : "
+ getFile().toString(); + getFile().toString();
Log.e("GameSettingsIO", msg); // TODO Clean up...
Logger log = LoggerFactory.getLogger(GameSettingsIO.class);
log.error("GameSettingsIO", msg);
} }
} }

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.util.Set; import java.util.Set;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
@ -20,7 +20,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter; import org.jdom.output.XMLOutputter;
import android.util.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/* ************************************************************************** /* **************************************************************************
* * * *
@ -69,7 +70,10 @@ public class UserSettingsIO extends XML_IO{
catch(JDOMException e){ catch(JDOMException e){
String msg = "Problem : " + getFile().toString() String msg = "Problem : " + getFile().toString()
+ " is not a well formed XML document"; + " is not a well formed XML document";
Log.e("UserSettingsIO", msg);
// TODO Clean up...
Logger log = LoggerFactory.getLogger(UserSettingsIO.class);
log.error("UserSettingsIO", msg);
} }
} }
@ -93,7 +97,10 @@ public class UserSettingsIO extends XML_IO{
catch(IOException e){ catch(IOException e){
String msg = "Problem : couldn't output to the given file : " String msg = "Problem : couldn't output to the given file : "
+ getFile().toString(); + getFile().toString();
Log.e("UserSettingsIO", msg);
// TODO Clean up...
Logger log = LoggerFactory.getLogger(UserSettingsIO.class);
log.error("UserSettingsIO", msg);
} }
} }

View File

@ -9,7 +9,7 @@
// (at your option) any later version. // (at your option) any later version.
// ******************************************************************** // ********************************************************************
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.util.Iterator; import java.util.Iterator;
import org.jdom.Element; import org.jdom.Element;
import org.jdom.Text; import org.jdom.Text;

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml; package org.justcheckers.xml;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;

View File

@ -19,10 +19,10 @@
along with justCheckers. If not, see <http://www.gnu.org/licenses/>. along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
package main.java.org.justcheckers.test.game; package org.justcheckers.test.game;
import main.java.org.justcheckers.game.Game; import org.justcheckers.game.Game;
import main.java.org.justcheckers.game.Rulebook; import org.justcheckers.game.Rulebook;
/** /**
* Test the game state logic. Tests the NQPOJO (not quite plain old Java * Test the game state logic. Tests the NQPOJO (not quite plain old Java