-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ship serialization, multiplayer sim in swing
- Loading branch information
Marcus Lankenau
committed
May 10, 2011
1 parent
ce3ad95
commit 1832ea0
Showing
11 changed files
with
212 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="test"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="lib" path="/home/mlankenau/projects/Galaxy/lib/json_simple-1.1.jar"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,8 @@ public String getId() { | |
return name; | ||
} | ||
|
||
public String toString() { | ||
return "party:"+name; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.galaxy; | ||
|
||
import java.util.Date; | ||
|
||
import static junit.framework.Assert.*; | ||
|
||
import org.json.simple.JSONObject; | ||
import org.json.simple.JSONValue; | ||
import org.junit.Test; | ||
|
||
|
||
|
||
public class ShipTest { | ||
|
||
@Test | ||
public void testJson() { | ||
Game game = new Game(); | ||
game.initEmpty(); | ||
|
||
long time = new Date().getTime(); | ||
|
||
Planet a = new Planet(0, game.getMe(), new Vector(0,0), PlanetClass.planetClasses[1]); | ||
Planet b = new Planet(1, game.getMe(), new Vector(0,0), PlanetClass.planetClasses[1]); | ||
game.getPlanets().add(a); | ||
game.getPlanets().add(b); | ||
|
||
Ship ship = new Ship(game.getMe(),a, b, 10.f, time); | ||
String jsonString = ship.toJson(); | ||
|
||
assertNotNull(jsonString); | ||
|
||
JSONObject obj = (JSONObject) JSONValue.parse(jsonString); | ||
Ship shipCopy = new Ship(game, obj); | ||
|
||
assertEquals(ship.getSource(), shipCopy.getSource()); | ||
assertEquals(ship.getDest(), shipCopy.getDest()); | ||
assertEquals(game.getOpponent(), ship.getParty()); | ||
assertEquals(ship.getSpeed(), shipCopy.getSpeed()); | ||
assertEquals(ship.getDeviation(), shipCopy.getDeviation()); | ||
} | ||
} |
Oops, something went wrong.