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/>.
*****************************************************************************/
package main.java.org.justcheckers.android;
package org.justcheckers.android;
import main.java.org.justcheckers.game.Game;
import main.java.org.justcheckers.game.Rulebook;
import org.justcheckers.game.Game;
import org.justcheckers.game.Rulebook;
import android.app.Activity;
import android.os.Bundle;

View File

@ -19,14 +19,14 @@
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.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import main.java.org.justcheckers.common.GlobalConstants;
import org.justcheckers.common.GlobalConstants;
import android.app.Activity;
import android.os.Bundle;

View File

@ -19,10 +19,10 @@
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 main.java.org.justcheckers.common.LoggingAndStatistics;
import org.justcheckers.common.GlobalConstants;
import org.justcheckers.common.LoggingAndStatistics;
import android.app.Activity;
import android.content.Intent;
@ -59,7 +59,7 @@ public class MenuActivity extends Activity implements OnClickListener {
menuButton.setOnClickListener(this);
// TODO: Move logging info in a better place.
LoggingAndStatistics.logApplicationInfo(this);
// LoggingAndStatistics.logApplicationInfo(this);
LoggingAndStatistics.logDeviceAndSystemInfo();
}

View File

@ -19,7 +19,7 @@
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.os.Bundle;

View File

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

View File

@ -19,7 +19,7 @@
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.

View File

@ -19,31 +19,39 @@
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;
import android.os.Build;
import android.util.Log;
// TODO Resolve this with separation of various platform setups...
//import org.justcheckers.android.R;
//
//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.
*
* @author Dorian Pula
*/
public class LoggingAndStatistics {
public abstract class LoggingAndStatistics {
/**
* Logs information about the program. Displays the game's header and
* 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);
String gameWebsite = caller.getString(R.string.project_website);
// TODO Fix
// String gameVersion = caller.getString(R.string.app_version);
// String gameWebsite = caller.getString(R.string.project_website);
String appInfo = "justCheckers -- Version:" + gameVersion
+ " - 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() {
// System properties.
String sysList = "SDK version: " + Build.VERSION.RELEASE
+ " - API: " + Build.VERSION.SDK_INT
+ " - Device: " + Build.MANUFACTURER + " " + Build.MODEL;
// String sysList = "SDK version: " + Build.VERSION.RELEASE
// + " - API: " + Build.VERSION.SDK_INT
// + " - 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/>.
*****************************************************************************/
package main.java.org.justcheckers.game;
package org.justcheckers.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/>.
*****************************************************************************/
package main.java.org.justcheckers.game;
import android.graphics.Point;
package org.justcheckers.game;
/**
* 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
* to null if not in use.
*/
private final Point jumpInProgress;
private final IPoint jumpInProgress;
/** Represents the light (usually attacking) player. */
private Player lightPlayer;
/** Represents whose turn it is. */
@ -245,7 +243,7 @@ public class Game {
/**
* @return the jumpInProgress
*/
public Point getJumpInProgress() {
public IPoint getJumpInProgress() {
return jumpInProgress;
}
}

View File

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

View File

@ -19,7 +19,7 @@
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

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.File;
@ -20,7 +20,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
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){
String msg = "Problem : " + getFile().toString()
+ " 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){
String msg = "Problem : couldn't output to the given file : "
+ 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;

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml;
package org.justcheckers.xml;
import java.io.BufferedWriter;
import java.io.File;
@ -20,7 +20,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
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){
String msg = "Problem : " + getFile().toString()
+ " 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){
String msg = "Problem : couldn't output to the given file : "
+ 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.HashMap;

View File

@ -1,4 +1,4 @@
package main.java.org.justcheckers.xml;
package org.justcheckers.xml;
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.File;
@ -20,7 +20,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
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){
String msg = "Problem : " + getFile().toString()
+ " 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){
String msg = "Problem : couldn't output to the given file : "
+ 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.
// ********************************************************************
package main.java.org.justcheckers.xml;
package org.justcheckers.xml;
import java.util.Iterator;
import org.jdom.Element;
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.FileFilter;

View File

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

View File

@ -19,10 +19,10 @@
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 main.java.org.justcheckers.game.Rulebook;
import org.justcheckers.game.Game;
import org.justcheckers.game.Rulebook;
/**
* Test the game state logic. Tests the NQPOJO (not quite plain old Java