Le metric crapload of changes to bring things up to date with the latest
Narya libraries and to finish the name change from Venison to Atlantissonne. git-svn-id: https://samskivert.googlecode.com/svn/trunk@969 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
(jde-set-variables
|
||||||
|
'(jde-db-source-directories (quote ("/export/local/jdk1.4/src" "/home/mdb/projects/samskivert/src/java" "/home/mdb/work/narya/src/java" "/home/mdb/projects/atlanti/src/java")))
|
||||||
|
'(jde-global-classpath (quote ("/home/mdb/projects/samskivert/dist/classes" "/home/mdb/work/narya/dist/classes" "/home/mdb/projects/atlanti/dist/classes")))
|
||||||
|
)
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<!-- build configuration -->
|
<!-- build configuration -->
|
||||||
<project name="venison" default="compile" basedir=".">
|
<project name="atlanti" default="compile" basedir=".">
|
||||||
|
|
||||||
<!-- things you may want to change -->
|
<!-- things you may want to change -->
|
||||||
<property name="app.name" value="venison"/>
|
<property name="app.name" value="atlanti"/>
|
||||||
<property name="doc.packages" value="com.threerings.venison.*"/>
|
<property name="doc.packages" value="com.threerings.atlanti.*"/>
|
||||||
<property name="doc.overview" value="com/threerings/venison/overview.html"/>
|
<property name="doc.overview" value="com/threerings/atlanti/overview.html"/>
|
||||||
<property name="copyright.holder" value="Michael Bayne"/>
|
<property name="copyright.holder" value="Michael Bayne"/>
|
||||||
<property name="build.compiler" value="jikes"/>
|
<property name="build.compiler" value="jikes"/>
|
||||||
<property name="java.libraries" value="/usr/share/java"/>
|
<property name="java.libraries" value="/usr/share/java"/>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Required external libraries
|
Required external libraries
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
The Venison code requires the following external Java libraries (JAR
|
The Atlantissonne code requires the following external Java libraries (JAR
|
||||||
files) to be placed (or symlinked) here in the lib/ directory or in the
|
files) to be placed (or symlinked) here in the lib/ directory or in the
|
||||||
shared library directory specified in the build.xml file
|
shared library directory specified in the build.xml file
|
||||||
(${java.libraries}).
|
(${java.libraries}).
|
||||||
@@ -12,17 +12,9 @@ shared library directory specified in the build.xml file
|
|||||||
* The samskivert package:
|
* The samskivert package:
|
||||||
http://www.waywardgeeks.org/code/samskivert/
|
http://www.waywardgeeks.org/code/samskivert/
|
||||||
|
|
||||||
* MM MySQL driver:
|
* A MySQL driver:
|
||||||
http://mmmysql.sourceforge.net/
|
http://mmmysql.sourceforge.net/
|
||||||
|
|
||||||
* Matt Welsh's Non-blocking IO library:
|
|
||||||
http://www.cs.berkeley.edu/~mdw/proj/java-nbio/
|
|
||||||
|
|
||||||
(The native code shared library should be built and placed into
|
|
||||||
lib/i686-Linux where it will be automatically added to LD_LIBRARY_PATH
|
|
||||||
by the runjava script. Alternatively you can put it into your
|
|
||||||
LD_LIBRARY_PATH by hand.)
|
|
||||||
|
|
||||||
* The Java API for XML Processing (JAXP) 1.1 Reference Implementation:
|
* The Java API for XML Processing (JAXP) 1.1 Reference Implementation:
|
||||||
http://java.sun.com/xml/download.html
|
http://java.sun.com/xml/download.html
|
||||||
|
|
||||||
@@ -32,15 +24,12 @@ shared library directory specified in the build.xml file
|
|||||||
* Megginson Technologies' XMLWriter 0.2 library:
|
* Megginson Technologies' XMLWriter 0.2 library:
|
||||||
http://www.megginson.com/Software/xml-writer-0.2.zip
|
http://www.megginson.com/Software/xml-writer-0.2.zip
|
||||||
|
|
||||||
* The ? game development platform
|
* The Narya game development libraries
|
||||||
http://www.threerings.net/code/?/
|
http://www.threerings.net/code/narya/
|
||||||
|
|
||||||
* The MiCasa game hosting service
|
|
||||||
http://www.threerings.net/code/micasa/
|
|
||||||
|
|
||||||
Once the jar files are in place (regardless of what they are named), the
|
Once the jar files are in place (regardless of what they are named), the
|
||||||
build system will automatically include them in the compile-time
|
build system will automatically include them in the compile-time
|
||||||
classpath.
|
classpath.
|
||||||
|
|
||||||
--
|
--
|
||||||
$Id: README,v 1.1 2001/10/09 20:27:35 mdb Exp $
|
$Id: README,v 1.2 2002/12/12 05:51:53 mdb Exp $
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#
|
#
|
||||||
# $Id: dbmap.properties,v 1.1 2001/10/09 20:27:35 mdb Exp $
|
# $Id: dbmap.properties,v 1.2 2002/12/12 05:51:53 mdb Exp $
|
||||||
#
|
#
|
||||||
# This provides information on the JDBC connections that are used by
|
# This provides information on the JDBC connections that are used by
|
||||||
# Venison server services.
|
# Atlantisonne server services.
|
||||||
|
|
||||||
#
|
#
|
||||||
# The database mapping for the user database.
|
# The database mapping for the user database.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#
|
#
|
||||||
# $Id: server.properties,v 1.1 2001/10/09 20:27:35 mdb Exp $
|
# $Id: server.properties,v 1.2 2002/12/12 05:51:53 mdb Exp $
|
||||||
#
|
#
|
||||||
# Configuration for the Venison server
|
# Configuration for the Atlantissonne server
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
#
|
#
|
||||||
# $Id: server.properties,v 1.2 2001/10/24 03:25:11 mdb Exp $
|
# $Id: server.properties,v 1.3 2002/12/12 05:51:53 mdb Exp $
|
||||||
#
|
#
|
||||||
# Configuration for the MiCasa server
|
# Configuration for the MiCasa server
|
||||||
|
|
||||||
|
_package = atlanti.server
|
||||||
|
_overrides = micasa.server
|
||||||
|
|
||||||
#
|
#
|
||||||
# The list of lobby identifiers to be loaded into this server.
|
# The list of lobby identifiers to be loaded into this server.
|
||||||
#
|
#
|
||||||
lobby_ids = venison
|
lobby_ids = atlanti
|
||||||
|
|
||||||
#
|
#
|
||||||
# The cofiguration for the test lobby.
|
# The cofiguration for the test lobby.
|
||||||
#
|
#
|
||||||
venison.config = com.threerings.micasa.lobby.table.TableLobbyConfig
|
atlanti.config = com.threerings.micasa.lobby.table.TableLobbyConfig
|
||||||
venison.ugi = venison,board,tile,strategy
|
atlanti.ugi = atlanti,board,tile,strategy
|
||||||
venison.name = Venison Lobby
|
atlanti.name = Atlanti Lobby
|
||||||
venison.game_config = com.threerings.venison.VenisonConfig
|
atlanti.game_config = com.samskivert.atlanti.data.AtlantiConfig
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
//
|
//
|
||||||
// $Id: Log.java,v 1.2 2001/10/09 20:27:35 mdb Exp $
|
// $Id: Log.java,v 1.3 2002/12/12 05:51:53 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A placeholder class that contains a reference to the log object used by
|
* A placeholder class that contains a reference to the log object used by
|
||||||
* the Venison package. This is a useful pattern to use when using the
|
* this package. This is a useful pattern to use when using the samskivert
|
||||||
* samskivert logging facilities. One creates a top-level class like this
|
* logging facilities. One creates a top-level class like this one that
|
||||||
* one that instantiates a log object with an name that identifies log
|
* instantiates a log object with an name that identifies log messages
|
||||||
* messages from that package and then provides static methods that
|
* from that package and then provides static methods that generate log
|
||||||
* generate log messages using that instance. Then, classes in that
|
* messages using that instance. Then, classes in that package need only
|
||||||
* package need only import the log wrapper class and can easily use it to
|
* import the log wrapper class and can easily use it to generate log
|
||||||
* generate log messages. For example:
|
* messages. For example:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* import com.threerings.venison.Log;
|
* import com.samskivert.atlanti.Log;
|
||||||
* // ...
|
* // ...
|
||||||
* Log.warning("All hell is breaking loose!");
|
* Log.warning("All hell is breaking loose!");
|
||||||
* // ...
|
* // ...
|
||||||
@@ -26,7 +26,7 @@ public class Log
|
|||||||
{
|
{
|
||||||
/** The static log instance configured for use by this package. */
|
/** The static log instance configured for use by this package. */
|
||||||
public static com.samskivert.util.Log log =
|
public static com.samskivert.util.Log log =
|
||||||
new com.samskivert.util.Log("venison");
|
new com.samskivert.util.Log("atlanti");
|
||||||
|
|
||||||
/** Convenience function. */
|
/** Convenience function. */
|
||||||
public static void debug (String message)
|
public static void debug (String message)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileGeometryTest.java,v 1.5 2002/01/29 23:45:56 mdb Exp $
|
// $Id: TileGeometryTest.java,v 1.6 2002/12/12 05:51:53 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@@ -16,17 +16,21 @@ import com.threerings.resource.ResourceManager;
|
|||||||
import com.threerings.media.ImageManager;
|
import com.threerings.media.ImageManager;
|
||||||
import com.threerings.media.tile.TileManager;
|
import com.threerings.media.tile.TileManager;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.data.AtlantiTile;
|
||||||
|
import com.samskivert.atlanti.data.TileCodes;
|
||||||
|
import com.samskivert.atlanti.util.PiecenUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple class for testing the tile geometry specifications by drawing
|
* A simple class for testing the tile geometry specifications by drawing
|
||||||
* them.
|
* them.
|
||||||
*/
|
*/
|
||||||
public class TileGeometryTest
|
public class TileGeometryTest extends JPanel
|
||||||
extends JPanel implements TileCodes
|
implements TileCodes
|
||||||
{
|
{
|
||||||
public TileGeometryTest ()
|
public TileGeometryTest ()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < TILE_TYPES; i++) {
|
for (int i = 0; i < TILE_TYPES; i++) {
|
||||||
_tiles[i] = new VenisonTile(i+1, true, NORTH, i % 5, i / 5);
|
_tiles[i] = new AtlantiTile(i+1, true, NORTH, i % 5, i / 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,12 +54,12 @@ public class TileGeometryTest
|
|||||||
{
|
{
|
||||||
JFrame frame = new JFrame("Tile geometry test");
|
JFrame frame = new JFrame("Tile geometry test");
|
||||||
|
|
||||||
ResourceManager rmgr = new ResourceManager("rsrc", null, null);
|
ResourceManager rmgr = new ResourceManager("rsrc");
|
||||||
ImageManager imgr = new ImageManager(rmgr, frame);
|
ImageManager imgr = new ImageManager(rmgr, frame);
|
||||||
TileManager tmgr = new TileManager(imgr);
|
TileManager tmgr = new TileManager(imgr);
|
||||||
|
|
||||||
VenisonTile.setTileManager(tmgr);
|
AtlantiTile.setManagers(imgr, tmgr);
|
||||||
VenisonTile.piecenDebug = true;
|
AtlantiTile.piecenDebug = true;
|
||||||
PiecenUtil.init(tmgr);
|
PiecenUtil.init(tmgr);
|
||||||
|
|
||||||
// quit if we're closed
|
// quit if we're closed
|
||||||
@@ -67,5 +71,5 @@ public class TileGeometryTest
|
|||||||
frame.show();
|
frame.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VenisonTile[] _tiles = new VenisonTile[TILE_TYPES];
|
protected AtlantiTile[] _tiles = new AtlantiTile[TILE_TYPES];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiBoard.java,v 1.17 2002/05/21 04:45:10 mdb Exp $
|
// $Id: AtlantiBoard.java,v 1.18 2002/12/12 05:51:53 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.client;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
@@ -18,27 +18,34 @@ import com.samskivert.util.CollectionUtil;
|
|||||||
|
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.Log;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiCodes;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiTile;
|
||||||
|
import com.samskivert.atlanti.data.Piecen;
|
||||||
|
import com.samskivert.atlanti.data.TileCodes;
|
||||||
|
import com.samskivert.atlanti.util.TileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the tiles that make up the Venison board.
|
* Displays the tiles that make up the board.
|
||||||
*/
|
*/
|
||||||
public class VenisonBoard
|
public class AtlantiBoard extends JPanel
|
||||||
extends JPanel implements TileCodes, VenisonCodes
|
implements TileCodes, AtlantiCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs a Venison board.
|
* Constructs a board.
|
||||||
*/
|
*/
|
||||||
public VenisonBoard ()
|
public AtlantiBoard ()
|
||||||
{
|
{
|
||||||
// create mouse adapters that will let us know when interesting
|
// create mouse adapters that will let us know when interesting
|
||||||
// mouse events happen
|
// mouse events happen
|
||||||
addMouseListener(new MouseAdapter() {
|
addMouseListener(new MouseAdapter() {
|
||||||
public void mouseClicked (MouseEvent evt) {
|
public void mouseClicked (MouseEvent evt) {
|
||||||
VenisonBoard.this.mouseClicked(evt);
|
AtlantiBoard.this.mouseClicked(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addMouseMotionListener(new MouseMotionAdapter() {
|
addMouseMotionListener(new MouseMotionAdapter() {
|
||||||
public void mouseMoved (MouseEvent evt) {
|
public void mouseMoved (MouseEvent evt) {
|
||||||
VenisonBoard.this.mouseMoved(evt);
|
AtlantiBoard.this.mouseMoved(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -56,7 +63,7 @@ public class VenisonBoard
|
|||||||
* are forgotten and the new tiles are initialized according to their
|
* are forgotten and the new tiles are initialized according to their
|
||||||
* geometry to set up initial claim groups.
|
* geometry to set up initial claim groups.
|
||||||
*
|
*
|
||||||
* @param tset the set of {@link VenisonTile} objects to be displayed
|
* @param tset the set of {@link AtlantiTile} objects to be displayed
|
||||||
* by this board.
|
* by this board.
|
||||||
*/
|
*/
|
||||||
public void setTiles (DSet tset)
|
public void setTiles (DSet tset)
|
||||||
@@ -94,7 +101,7 @@ public class VenisonBoard
|
|||||||
* Instructs the board to add the specified tile to the display. The
|
* Instructs the board to add the specified tile to the display. The
|
||||||
* tile will have its claims inherited accordingly.
|
* tile will have its claims inherited accordingly.
|
||||||
*/
|
*/
|
||||||
public void addTile (VenisonTile tile)
|
public void addTile (AtlantiTile tile)
|
||||||
{
|
{
|
||||||
Log.info("Adding tile to board " + tile + ".");
|
Log.info("Adding tile to board " + tile + ".");
|
||||||
|
|
||||||
@@ -135,7 +142,7 @@ public class VenisonBoard
|
|||||||
// locate the tile associated with this piecen
|
// locate the tile associated with this piecen
|
||||||
int tidx = _tiles.indexOf(piecen);
|
int tidx = _tiles.indexOf(piecen);
|
||||||
if (tidx != -1) {
|
if (tidx != -1) {
|
||||||
VenisonTile tile = (VenisonTile)_tiles.get(tidx);
|
AtlantiTile tile = (AtlantiTile)_tiles.get(tidx);
|
||||||
// set the piecen on the tile (supplying our tile list so that
|
// set the piecen on the tile (supplying our tile list so that
|
||||||
// the necessary claim group adjustments can be made)
|
// the necessary claim group adjustments can be made)
|
||||||
tile.setPiecen(piecen, _tiles);
|
tile.setPiecen(piecen, _tiles);
|
||||||
@@ -157,7 +164,7 @@ public class VenisonBoard
|
|||||||
// locate the tile associated with this piecen key
|
// locate the tile associated with this piecen key
|
||||||
int tsize = _tiles.size();
|
int tsize = _tiles.size();
|
||||||
for (int i = 0; i < tsize; i++) {
|
for (int i = 0; i < tsize; i++) {
|
||||||
VenisonTile tile = (VenisonTile)_tiles.get(i);
|
AtlantiTile tile = (AtlantiTile)_tiles.get(i);
|
||||||
if (tile.getKey().equals(key)) {
|
if (tile.getKey().equals(key)) {
|
||||||
// clear the piecen out of the tile
|
// clear the piecen out of the tile
|
||||||
tile.clearPiecen();
|
tile.clearPiecen();
|
||||||
@@ -208,12 +215,12 @@ public class VenisonBoard
|
|||||||
* @param tile the new tile to be placed or null if no tile is to
|
* @param tile the new tile to be placed or null if no tile is to
|
||||||
* currently be placed.
|
* currently be placed.
|
||||||
*/
|
*/
|
||||||
public void setTileToBePlaced (VenisonTile tile)
|
public void setTileToBePlaced (AtlantiTile tile)
|
||||||
{
|
{
|
||||||
Log.info("Setting tile to be placed [tile=" + tile + "].");
|
Log.info("Setting tile to be placed [tile=" + tile + "].");
|
||||||
|
|
||||||
// make a copy of this tile so that we can play with it
|
// make a copy of this tile so that we can play with it
|
||||||
_placingTile = (VenisonTile)tile.clone();;
|
_placingTile = (AtlantiTile)tile.clone();;
|
||||||
|
|
||||||
// update our internal state based on this new placing tile
|
// update our internal state based on this new placing tile
|
||||||
if (_placingTile != null) {
|
if (_placingTile != null) {
|
||||||
@@ -224,7 +231,7 @@ public class VenisonBoard
|
|||||||
/**
|
/**
|
||||||
* Returns the last tile placed by the user.
|
* Returns the last tile placed by the user.
|
||||||
*/
|
*/
|
||||||
public VenisonTile getPlacedTile ()
|
public AtlantiTile getPlacedTile ()
|
||||||
{
|
{
|
||||||
return _placedTile;
|
return _placedTile;
|
||||||
}
|
}
|
||||||
@@ -242,7 +249,7 @@ public class VenisonBoard
|
|||||||
/**
|
/**
|
||||||
* Causes the supplied tile to be repainted.
|
* Causes the supplied tile to be repainted.
|
||||||
*/
|
*/
|
||||||
public void repaintTile (VenisonTile tile)
|
public void repaintTile (AtlantiTile tile)
|
||||||
{
|
{
|
||||||
int offx = _tx + (tile.x + _origX) * TILE_WIDTH;
|
int offx = _tx + (tile.x + _origX) * TILE_WIDTH;
|
||||||
int offy = _ty + (tile.y + _origY) * TILE_HEIGHT;
|
int offy = _ty + (tile.y + _origY) * TILE_HEIGHT;
|
||||||
@@ -262,7 +269,7 @@ public class VenisonBoard
|
|||||||
// iterate over our tiles, painting each of them
|
// iterate over our tiles, painting each of them
|
||||||
int tsize = _tiles.size();
|
int tsize = _tiles.size();
|
||||||
for (int i = 0; i < tsize; i++) {
|
for (int i = 0; i < tsize; i++) {
|
||||||
VenisonTile tile = (VenisonTile)_tiles.get(i);
|
AtlantiTile tile = (AtlantiTile)_tiles.get(i);
|
||||||
tile.paint(g2, _origX, _origY);
|
tile.paint(g2, _origX, _origY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,7 +558,7 @@ public class VenisonBoard
|
|||||||
// figure out what our boundaries are
|
// figure out what our boundaries are
|
||||||
int tsize = _tiles.size();
|
int tsize = _tiles.size();
|
||||||
for (int i = 0; i < tsize; i++) {
|
for (int i = 0; i < tsize; i++) {
|
||||||
VenisonTile tile = (VenisonTile)_tiles.get(i);
|
AtlantiTile tile = (AtlantiTile)_tiles.get(i);
|
||||||
if (tile.x > maxX) {
|
if (tile.x > maxX) {
|
||||||
maxX = tile.x;
|
maxX = tile.x;
|
||||||
} else if (tile.x < minX) {
|
} else if (tile.x < minX) {
|
||||||
@@ -594,24 +601,24 @@ public class VenisonBoard
|
|||||||
{
|
{
|
||||||
JFrame frame = new JFrame("Board test");
|
JFrame frame = new JFrame("Board test");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
VenisonBoard board = new VenisonBoard();
|
AtlantiBoard board = new AtlantiBoard();
|
||||||
|
|
||||||
TestDSet set = new TestDSet();
|
TestDSet set = new TestDSet();
|
||||||
set.addTile(new VenisonTile(CITY_TWO, true, WEST, 0, 0));
|
set.addTile(new AtlantiTile(CITY_TWO, true, WEST, 0, 0));
|
||||||
set.addTile(new VenisonTile(CITY_TWO, false, WEST, -1, 1));
|
set.addTile(new AtlantiTile(CITY_TWO, false, WEST, -1, 1));
|
||||||
set.addTile(new VenisonTile(CITY_ONE, false, SOUTH, -1, -1));
|
set.addTile(new AtlantiTile(CITY_ONE, false, SOUTH, -1, -1));
|
||||||
VenisonTile zero = new VenisonTile(CURVED_ROAD, false, WEST, 0, 2);
|
AtlantiTile zero = new AtlantiTile(CURVED_ROAD, false, WEST, 0, 2);
|
||||||
set.addTile(zero);
|
set.addTile(zero);
|
||||||
VenisonTile one = new VenisonTile(TWO_CITY_TWO, false, NORTH, 0, 1);
|
AtlantiTile one = new AtlantiTile(TWO_CITY_TWO, false, NORTH, 0, 1);
|
||||||
set.addTile(one);
|
set.addTile(one);
|
||||||
set.addTile(new VenisonTile(CITY_THREE, false, WEST, 1, 1));
|
set.addTile(new AtlantiTile(CITY_THREE, false, WEST, 1, 1));
|
||||||
set.addTile(new VenisonTile(CITY_THREE_ROAD, false, EAST, 1, 2));
|
set.addTile(new AtlantiTile(CITY_THREE_ROAD, false, EAST, 1, 2));
|
||||||
set.addTile(new VenisonTile(CITY_THREE, false, NORTH, -1, 0));
|
set.addTile(new AtlantiTile(CITY_THREE, false, NORTH, -1, 0));
|
||||||
VenisonTile two = new VenisonTile(CITY_ONE, false, EAST, -2, 0);
|
AtlantiTile two = new AtlantiTile(CITY_ONE, false, EAST, -2, 0);
|
||||||
set.addTile(two);
|
set.addTile(two);
|
||||||
board.setTiles(set);
|
board.setTiles(set);
|
||||||
|
|
||||||
VenisonTile placing = new VenisonTile(CITY_TWO, false, NORTH, 0, 0);
|
AtlantiTile placing = new AtlantiTile(CITY_TWO, false, NORTH, 0, 0);
|
||||||
board.setTileToBePlaced(placing);
|
board.setTileToBePlaced(placing);
|
||||||
|
|
||||||
// set a feature group to test propagation
|
// set a feature group to test propagation
|
||||||
@@ -640,12 +647,7 @@ public class VenisonBoard
|
|||||||
|
|
||||||
protected static class TestDSet extends DSet
|
protected static class TestDSet extends DSet
|
||||||
{
|
{
|
||||||
public TestDSet ()
|
public void addTile (AtlantiTile tile)
|
||||||
{
|
|
||||||
super(VenisonTile.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTile (VenisonTile tile)
|
|
||||||
{
|
{
|
||||||
add(tile);
|
add(tile);
|
||||||
}
|
}
|
||||||
@@ -655,13 +657,13 @@ public class VenisonBoard
|
|||||||
protected ArrayList _tiles = new ArrayList();
|
protected ArrayList _tiles = new ArrayList();
|
||||||
|
|
||||||
/** The tile currently being placed by the user. */
|
/** The tile currently being placed by the user. */
|
||||||
protected VenisonTile _placingTile;
|
protected AtlantiTile _placingTile;
|
||||||
|
|
||||||
/** The last tile being placed by the user. */
|
/** The last tile being placed by the user. */
|
||||||
protected VenisonTile _placedTile;
|
protected AtlantiTile _placedTile;
|
||||||
|
|
||||||
/** The last tile placed on the board via {@link #addTile}. */
|
/** The last tile placed on the board via {@link #addTile}. */
|
||||||
protected VenisonTile _lastPlacedTile;
|
protected AtlantiTile _lastPlacedTile;
|
||||||
|
|
||||||
/** A flag indicating whether or not we're placing a piecen. */
|
/** A flag indicating whether or not we're placing a piecen. */
|
||||||
protected boolean _placingPiecen = false;
|
protected boolean _placingPiecen = false;
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// $Id: AtlantiConfigurator.java,v 1.1 2002/12/12 05:51:53 mdb Exp $
|
||||||
|
|
||||||
|
package com.samskivert.atlanti.client;
|
||||||
|
|
||||||
|
import com.samskivert.swing.SimpleSlider;
|
||||||
|
import com.samskivert.swing.VGroupLayout;
|
||||||
|
|
||||||
|
import com.threerings.micasa.lobby.table.TableGameConfigurator;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.data.AtlantiConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a user interface for configuring a game.
|
||||||
|
*/
|
||||||
|
public class AtlantiConfigurator extends TableGameConfigurator
|
||||||
|
{
|
||||||
|
// documentation inherited
|
||||||
|
protected void createConfigInterface ()
|
||||||
|
{
|
||||||
|
super.createConfigInterface();
|
||||||
|
|
||||||
|
// _boardSize = new SimpleSlider("Board size:", 16, 48, 32);
|
||||||
|
// add(_boardSize, VGroupLayout.FIXED);
|
||||||
|
// _handSize = new SimpleSlider("Hand size:", 2, 5, 5);
|
||||||
|
// add(_handSize, VGroupLayout.FIXED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
protected void gotGameConfig ()
|
||||||
|
{
|
||||||
|
super.gotGameConfig();
|
||||||
|
_vconfig = (AtlantiConfig)_config;
|
||||||
|
|
||||||
|
// // configure our elements
|
||||||
|
// _boardSize.setValue(_vconfig.boardWidth);
|
||||||
|
// _handSize.setValue(_vconfig.handSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
protected void flushGameConfig ()
|
||||||
|
{
|
||||||
|
super.flushGameConfig();
|
||||||
|
|
||||||
|
// // configure our elements
|
||||||
|
// _vconfig.boardWidth = _boardSize.getValue();
|
||||||
|
// _vconfig.boardHeight = _boardSize.getValue();
|
||||||
|
// _vconfig.handSize = _handSize.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AtlantiConfig _vconfig;
|
||||||
|
// protected SimpleSlider _boardSize;
|
||||||
|
// protected SimpleSlider _handSize;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id
|
// $Id
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.client;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import com.samskivert.util.ListUtil;
|
import com.samskivert.util.ListUtil;
|
||||||
@@ -25,19 +25,24 @@ import com.threerings.parlor.util.ParlorContext;
|
|||||||
|
|
||||||
import com.threerings.micasa.util.MiCasaContext;
|
import com.threerings.micasa.util.MiCasaContext;
|
||||||
|
|
||||||
import com.threerings.venison.Log;
|
import com.samskivert.atlanti.Log;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiCodes;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiObject;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiTile;
|
||||||
|
import com.samskivert.atlanti.data.Piecen;
|
||||||
|
import com.samskivert.atlanti.util.TileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main coordinator of user interface activities on the client-side of
|
* The main coordinator of user interface activities on the client-side of
|
||||||
* the Venison game.
|
* the game.
|
||||||
*/
|
*/
|
||||||
public class VenisonController extends GameController
|
public class AtlantiController extends GameController
|
||||||
implements TurnGameController, VenisonCodes, SetListener
|
implements TurnGameController, AtlantiCodes, SetListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates our controller and prepares it for operation.
|
* Creates our controller and prepares it for operation.
|
||||||
*/
|
*/
|
||||||
public VenisonController ()
|
public AtlantiController ()
|
||||||
{
|
{
|
||||||
addDelegate(_delegate = new TurnGameControllerDelegate(this));
|
addDelegate(_delegate = new TurnGameControllerDelegate(this));
|
||||||
}
|
}
|
||||||
@@ -54,7 +59,7 @@ public class VenisonController extends GameController
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected PlaceView createPlaceView ()
|
protected PlaceView createPlaceView ()
|
||||||
{
|
{
|
||||||
_panel = new VenisonPanel((MiCasaContext)_ctx, this);
|
_panel = new AtlantiPanel((MiCasaContext)_ctx, this);
|
||||||
return _panel;
|
return _panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +69,7 @@ public class VenisonController extends GameController
|
|||||||
super.willEnterPlace(plobj);
|
super.willEnterPlace(plobj);
|
||||||
|
|
||||||
// get a casted reference to our game object
|
// get a casted reference to our game object
|
||||||
_venobj = (VenisonObject)plobj;
|
_venobj = (AtlantiObject)plobj;
|
||||||
|
|
||||||
// find out what our index is and use that as our piecen color
|
// find out what our index is and use that as our piecen color
|
||||||
_selfIndex = ListUtil.indexOfEqual(_venobj.players, _self.username);
|
_selfIndex = ListUtil.indexOfEqual(_venobj.players, _self.username);
|
||||||
@@ -99,10 +104,10 @@ public class VenisonController extends GameController
|
|||||||
super.attributeChanged(event);
|
super.attributeChanged(event);
|
||||||
|
|
||||||
// handle the setting of the board state
|
// handle the setting of the board state
|
||||||
if (event.getName().equals(VenisonObject.TILES)) {
|
if (event.getName().equals(AtlantiObject.TILES)) {
|
||||||
_panel.board.setTiles(_venobj.tiles);
|
_panel.board.setTiles(_venobj.tiles);
|
||||||
|
|
||||||
} else if (event.getName().equals(VenisonObject.PIECENS)) {
|
} else if (event.getName().equals(AtlantiObject.PIECENS)) {
|
||||||
_panel.board.setPiecens(_venobj.piecens);
|
_panel.board.setPiecens(_venobj.piecens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,12 +116,12 @@ public class VenisonController extends GameController
|
|||||||
public void entryAdded (EntryAddedEvent event)
|
public void entryAdded (EntryAddedEvent event)
|
||||||
{
|
{
|
||||||
// we care about additions to TILES and PIECENS
|
// we care about additions to TILES and PIECENS
|
||||||
if (event.getName().equals(VenisonObject.TILES)) {
|
if (event.getName().equals(AtlantiObject.TILES)) {
|
||||||
// a tile was added, add it to the board
|
// a tile was added, add it to the board
|
||||||
VenisonTile tile = (VenisonTile)event.getEntry();
|
AtlantiTile tile = (AtlantiTile)event.getEntry();
|
||||||
_panel.board.addTile(tile);
|
_panel.board.addTile(tile);
|
||||||
|
|
||||||
} else if (event.getName().equals(VenisonObject.PIECENS)) {
|
} else if (event.getName().equals(AtlantiObject.PIECENS)) {
|
||||||
// a piecen was added, place it on the board
|
// a piecen was added, place it on the board
|
||||||
Piecen piecen = (Piecen)event.getEntry();
|
Piecen piecen = (Piecen)event.getEntry();
|
||||||
_panel.board.placePiecen(piecen);
|
_panel.board.placePiecen(piecen);
|
||||||
@@ -131,7 +136,7 @@ public class VenisonController extends GameController
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void entryRemoved (EntryRemovedEvent event)
|
public void entryRemoved (EntryRemovedEvent event)
|
||||||
{
|
{
|
||||||
if (event.getName().equals(VenisonObject.PIECENS)) {
|
if (event.getName().equals(AtlantiObject.PIECENS)) {
|
||||||
// a piecen was removed, update the board
|
// a piecen was removed, update the board
|
||||||
_panel.board.clearPiecen(event.getKey());
|
_panel.board.clearPiecen(event.getKey());
|
||||||
}
|
}
|
||||||
@@ -141,7 +146,7 @@ public class VenisonController extends GameController
|
|||||||
public boolean handleAction (ActionEvent action)
|
public boolean handleAction (ActionEvent action)
|
||||||
{
|
{
|
||||||
if (action.getActionCommand().equals(TILE_PLACED)) {
|
if (action.getActionCommand().equals(TILE_PLACED)) {
|
||||||
VenisonTile tile = _panel.board.getPlacedTile();
|
AtlantiTile tile = _panel.board.getPlacedTile();
|
||||||
|
|
||||||
// the user placed the tile into a valid location. grab the
|
// the user placed the tile into a valid location. grab the
|
||||||
// placed tile from the board and submit it to the server
|
// placed tile from the board and submit it to the server
|
||||||
@@ -204,10 +209,10 @@ public class VenisonController extends GameController
|
|||||||
protected TurnGameControllerDelegate _delegate;
|
protected TurnGameControllerDelegate _delegate;
|
||||||
|
|
||||||
/** A reference to our game panel. */
|
/** A reference to our game panel. */
|
||||||
protected VenisonPanel _panel;
|
protected AtlantiPanel _panel;
|
||||||
|
|
||||||
/** A reference to our game panel. */
|
/** A reference to our game panel. */
|
||||||
protected VenisonObject _venobj;
|
protected AtlantiObject _venobj;
|
||||||
|
|
||||||
/** A reference to our body object. */
|
/** A reference to our body object. */
|
||||||
protected BodyObject _self;
|
protected BodyObject _self;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id
|
// $Id
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.client;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@@ -27,22 +27,27 @@ import com.threerings.crowd.client.PlaceView;
|
|||||||
import com.threerings.micasa.client.ChatPanel;
|
import com.threerings.micasa.client.ChatPanel;
|
||||||
import com.threerings.micasa.util.MiCasaContext;
|
import com.threerings.micasa.util.MiCasaContext;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.Log;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiCodes;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiTile;
|
||||||
|
import com.samskivert.atlanti.util.PiecenUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The top-level user interface component for the Venison game display.
|
* The top-level user interface component for the game display.
|
||||||
*/
|
*/
|
||||||
public class VenisonPanel
|
public class AtlantiPanel extends JPanel
|
||||||
extends JPanel implements PlaceView, ControllerProvider, VenisonCodes
|
implements PlaceView, ControllerProvider, AtlantiCodes
|
||||||
{
|
{
|
||||||
/** A reference to the board that is accessible to the controller. */
|
/** A reference to the board that is accessible to the controller. */
|
||||||
public VenisonBoard board;
|
public AtlantiBoard board;
|
||||||
|
|
||||||
/** A reference to our _noplace button. */
|
/** A reference to our _noplace button. */
|
||||||
public JButton noplace;
|
public JButton noplace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new Venison game display.
|
* Constructs a new game display.
|
||||||
*/
|
*/
|
||||||
public VenisonPanel (MiCasaContext ctx, VenisonController controller)
|
public AtlantiPanel (MiCasaContext ctx, AtlantiController controller)
|
||||||
{
|
{
|
||||||
// give ourselves a wee bit of a border
|
// give ourselves a wee bit of a border
|
||||||
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||||
@@ -52,7 +57,7 @@ public class VenisonPanel
|
|||||||
setLayout(gl);
|
setLayout(gl);
|
||||||
|
|
||||||
// create the board
|
// create the board
|
||||||
board = new VenisonBoard();
|
board = new AtlantiBoard();
|
||||||
|
|
||||||
// create a scroll area to contain the board
|
// create a scroll area to contain the board
|
||||||
JScrollPane scrolly = new JScrollPane(board);
|
JScrollPane scrolly = new JScrollPane(board);
|
||||||
@@ -101,23 +106,20 @@ public class VenisonPanel
|
|||||||
|
|
||||||
// we'll need this later to provide it
|
// we'll need this later to provide it
|
||||||
_controller = controller;
|
_controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void addNotify ()
|
||||||
|
{
|
||||||
|
super.addNotify();
|
||||||
|
|
||||||
// we can't create our image manager until we have access to our
|
// we can't create our image manager until we have access to our
|
||||||
// containing frame
|
// containing frame
|
||||||
addAncestorListener(new AncestorListener() {
|
JRootPane rpane = getRootPane();
|
||||||
public void ancestorAdded (AncestorEvent event) {
|
ImageManager imgr = new ImageManager(_rmgr, rpane);
|
||||||
// create our image manager
|
TileManager tmgr = new TileManager(imgr);
|
||||||
JRootPane rpane = getRootPane();
|
AtlantiTile.setManagers(imgr, tmgr);
|
||||||
ImageManager imgr = new ImageManager(_rmgr, rpane);
|
PiecenUtil.init(tmgr);
|
||||||
TileManager tmgr = new TileManager(imgr);
|
|
||||||
VenisonTile.setTileManager(tmgr);
|
|
||||||
PiecenUtil.init(tmgr);
|
|
||||||
}
|
|
||||||
public void ancestorMoved (AncestorEvent event) {
|
|
||||||
}
|
|
||||||
public void ancestorRemoved (AncestorEvent event) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -140,15 +142,15 @@ public class VenisonPanel
|
|||||||
|
|
||||||
/** A reference to our controller that we need to implement the {@link
|
/** A reference to our controller that we need to implement the {@link
|
||||||
* ControllerProvider} interface. */
|
* ControllerProvider} interface. */
|
||||||
protected VenisonController _controller;
|
protected AtlantiController _controller;
|
||||||
|
|
||||||
// this stuff is all a bit of a hack right now. by all rights, the
|
// this stuff is all a bit of a hack right now. by all rights, the
|
||||||
// venison app should set up the resource manager, because it knows
|
// MiCasa game app should set up the resource manager, because it
|
||||||
// about that sort of stuff, and make it available via the venison
|
// knows about that sort of stuff, and make it available via the
|
||||||
// context and we may have some better place for the tile manager to
|
// MiCasa context and we may have some better place for the tile
|
||||||
// live. but it's late and i want to get this working, so fooey.
|
// manager to live. but it's late and i want to get this working, so
|
||||||
|
// fooey.
|
||||||
|
|
||||||
/** Our resource manager. */
|
/** Our resource manager. */
|
||||||
protected static ResourceManager _rmgr =
|
protected static ResourceManager _rmgr = new ResourceManager("rsrc");
|
||||||
new ResourceManager("rsrc", null, null);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: PlayerInfoView.java,v 1.4 2002/05/21 04:45:09 mdb Exp $
|
// $Id: PlayerInfoView.java,v 1.5 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.client;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
@@ -20,6 +20,11 @@ import com.threerings.presents.dobj.EntryRemovedEvent;
|
|||||||
import com.threerings.crowd.client.PlaceView;
|
import com.threerings.crowd.client.PlaceView;
|
||||||
import com.threerings.crowd.data.PlaceObject;
|
import com.threerings.crowd.data.PlaceObject;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.data.AtlantiCodes;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiObject;
|
||||||
|
import com.samskivert.atlanti.data.Feature;
|
||||||
|
import com.samskivert.atlanti.util.TileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays each of the players in the game, their piece color and their
|
* Displays each of the players in the game, their piece color and their
|
||||||
* score.
|
* score.
|
||||||
@@ -29,8 +34,8 @@ public class PlayerInfoView
|
|||||||
implements PlaceView, AttributeChangeListener, SetListener
|
implements PlaceView, AttributeChangeListener, SetListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs a new player info panel, ready for insertion into a
|
* Constructs a new player info panel, ready for insertion into the
|
||||||
* Venison game panel.
|
* game panel.
|
||||||
*/
|
*/
|
||||||
public PlayerInfoView ()
|
public PlayerInfoView ()
|
||||||
{
|
{
|
||||||
@@ -45,26 +50,25 @@ public class PlayerInfoView
|
|||||||
{
|
{
|
||||||
// we want to grab a reference to the game object and add
|
// we want to grab a reference to the game object and add
|
||||||
// ourselves as an attribute change listener
|
// ourselves as an attribute change listener
|
||||||
_venobj = (VenisonObject)plobj;
|
_atlobj = (AtlantiObject)plobj;
|
||||||
_venobj.addListener(this);
|
_atlobj.addListener(this);
|
||||||
|
|
||||||
// we need score and piecen labels arrays so that we can keep
|
// we need score and piecen labels arrays so that we can keep
|
||||||
// track of per player information
|
// track of per player information
|
||||||
_scoreLabels = new JLabel[_venobj.players.length];
|
_scoreLabels = new JLabel[_atlobj.players.length];
|
||||||
_piecenLabels = new JLabel[_venobj.players.length];
|
_piecenLabels = new JLabel[_atlobj.players.length];
|
||||||
|
|
||||||
// now that we're here, we can add an entry for every player
|
// now that we're here, we can add an entry for every player
|
||||||
for (int i = 0; i < _venobj.players.length; i++) {
|
for (int i = 0; i < _atlobj.players.length; i++) {
|
||||||
addPlayer(i, _venobj.players[i]);
|
addPlayer(i, _atlobj.players[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have scores, update them
|
// if we have scores, update them
|
||||||
if (_venobj.scores.length == _venobj.players.length) {
|
if (_atlobj.scores != null) {
|
||||||
updateScores();
|
updateScores();
|
||||||
|
// and the piecen count
|
||||||
|
updatePiecenCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the piecen count
|
|
||||||
updatePiecenCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,15 +105,15 @@ public class PlayerInfoView
|
|||||||
public void didLeavePlace (PlaceObject plobj)
|
public void didLeavePlace (PlaceObject plobj)
|
||||||
{
|
{
|
||||||
// remove our listening self
|
// remove our listening self
|
||||||
_venobj.removeListener(this);
|
_atlobj.removeListener(this);
|
||||||
_venobj = null;
|
_atlobj = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void attributeChanged (AttributeChangedEvent event)
|
public void attributeChanged (AttributeChangedEvent event)
|
||||||
{
|
{
|
||||||
// we care about the scores (which change)
|
// we care about the scores (which change)
|
||||||
if (event.getName().equals(VenisonObject.SCORES)) {
|
if (event.getName().equals(AtlantiObject.SCORES)) {
|
||||||
updateScores();
|
updateScores();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,8 +140,8 @@ public class PlayerInfoView
|
|||||||
*/
|
*/
|
||||||
protected void updateScores ()
|
protected void updateScores ()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _venobj.scores.length; i++) {
|
for (int i = 0; i < _atlobj.scores.length; i++) {
|
||||||
_scoreLabels[i].setText(Integer.toString(_venobj.scores[i]));
|
_scoreLabels[i].setText(Integer.toString(_atlobj.scores[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,15 +150,15 @@ public class PlayerInfoView
|
|||||||
*/
|
*/
|
||||||
protected void updatePiecenCount ()
|
protected void updatePiecenCount ()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _venobj.scores.length; i++) {
|
for (int i = 0; i < _atlobj.scores.length; i++) {
|
||||||
int pcount = TileUtil.countPiecens(_venobj.piecens, i);
|
int pcount = TileUtil.countPiecens(_atlobj.piecens, i);
|
||||||
int pleft = VenisonCodes.PIECENS_PER_PLAYER - pcount;
|
int pleft = AtlantiCodes.PIECENS_PER_PLAYER - pcount;
|
||||||
_piecenLabels[i].setText("(" + pleft + ")");
|
_piecenLabels[i].setText("(" + pleft + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A reference to the game object. */
|
/** A reference to the game object. */
|
||||||
protected VenisonObject _venobj;
|
protected AtlantiObject _atlobj;
|
||||||
|
|
||||||
/** References to our score label components. */
|
/** References to our score label components. */
|
||||||
protected JLabel[] _scoreLabels;
|
protected JLabel[] _scoreLabels;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileLabel.java,v 1.1 2001/10/16 01:41:55 mdb Exp $
|
// $Id: TileLabel.java,v 1.2 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.client;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
@@ -10,11 +10,14 @@ import java.awt.Graphics2D;
|
|||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.data.AtlantiTile;
|
||||||
|
import com.samskivert.atlanti.data.TileCodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a single tile in a Swing component.
|
* Displays a single tile in a Swing component.
|
||||||
*/
|
*/
|
||||||
public class TileLabel
|
public class TileLabel extends JComponent
|
||||||
extends JComponent implements TileCodes
|
implements TileCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Configures the component to display the specified tile.
|
* Configures the component to display the specified tile.
|
||||||
@@ -22,7 +25,7 @@ public class TileLabel
|
|||||||
* @param tile a reference to the tile to display or null if no tile
|
* @param tile a reference to the tile to display or null if no tile
|
||||||
* should be displayed.
|
* should be displayed.
|
||||||
*/
|
*/
|
||||||
public void setTile (VenisonTile tile)
|
public void setTile (AtlantiTile tile)
|
||||||
{
|
{
|
||||||
_tile = tile;
|
_tile = tile;
|
||||||
repaint();
|
repaint();
|
||||||
@@ -46,5 +49,5 @@ public class TileLabel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The tile we are displaying. */
|
/** The tile we are displaying. */
|
||||||
protected VenisonTile _tile;
|
protected AtlantiTile _tile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: TurnIndicatorView.java,v 1.3 2002/01/29 23:47:03 mdb Exp $
|
// $Id: TurnIndicatorView.java,v 1.4 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.client;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -14,12 +14,14 @@ import com.threerings.presents.dobj.AttributeChangedEvent;
|
|||||||
import com.threerings.crowd.data.PlaceObject;
|
import com.threerings.crowd.data.PlaceObject;
|
||||||
import com.threerings.crowd.client.PlaceView;
|
import com.threerings.crowd.client.PlaceView;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.data.AtlantiObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays who the current turn holder is as well as the tile they are
|
* Displays who the current turn holder is as well as the tile they are
|
||||||
* currently placing.
|
* currently placing.
|
||||||
*/
|
*/
|
||||||
public class TurnIndicatorView
|
public class TurnIndicatorView extends JPanel
|
||||||
extends JPanel implements PlaceView, AttributeChangeListener
|
implements PlaceView, AttributeChangeListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a new turn indicator view which in turn creates its
|
* Creates a new turn indicator view which in turn creates its
|
||||||
@@ -47,8 +49,8 @@ public class TurnIndicatorView
|
|||||||
{
|
{
|
||||||
// we want to grab a reference to the game object and add
|
// we want to grab a reference to the game object and add
|
||||||
// ourselves as an attribute change listener
|
// ourselves as an attribute change listener
|
||||||
_venobj = (VenisonObject)plobj;
|
_atlobj = (AtlantiObject)plobj;
|
||||||
_venobj.addListener(this);
|
_atlobj.addListener(this);
|
||||||
|
|
||||||
// update our displays
|
// update our displays
|
||||||
updateCurrentTile();
|
updateCurrentTile();
|
||||||
@@ -61,24 +63,24 @@ public class TurnIndicatorView
|
|||||||
public void didLeavePlace (PlaceObject plobj)
|
public void didLeavePlace (PlaceObject plobj)
|
||||||
{
|
{
|
||||||
// remove our listening self
|
// remove our listening self
|
||||||
_venobj.removeListener(this);
|
_atlobj.removeListener(this);
|
||||||
_venobj = null;
|
_atlobj = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void attributeChanged (AttributeChangedEvent event)
|
public void attributeChanged (AttributeChangedEvent event)
|
||||||
{
|
{
|
||||||
if (event.getName().equals(VenisonObject.CURRENT_TILE)) {
|
if (event.getName().equals(AtlantiObject.CURRENT_TILE)) {
|
||||||
// update the current tile display
|
// update the current tile display
|
||||||
updateCurrentTile();
|
updateCurrentTile();
|
||||||
|
|
||||||
} else if (event.getName().equals(VenisonObject.STATE)) {
|
} else if (event.getName().equals(AtlantiObject.STATE)) {
|
||||||
// update the game state display
|
// update the game state display
|
||||||
updateGameState();
|
updateGameState();
|
||||||
// update the tiles remaining
|
// update the tiles remaining
|
||||||
updateRemainingTiles();
|
updateRemainingTiles();
|
||||||
|
|
||||||
} else if (event.getName().equals(VenisonObject.TURN_HOLDER)) {
|
} else if (event.getName().equals(AtlantiObject.TURN_HOLDER)) {
|
||||||
// update the turn holder
|
// update the turn holder
|
||||||
updateTurnHolder();
|
updateTurnHolder();
|
||||||
|
|
||||||
@@ -89,16 +91,16 @@ public class TurnIndicatorView
|
|||||||
|
|
||||||
protected void updateGameState ()
|
protected void updateGameState ()
|
||||||
{
|
{
|
||||||
switch (_venobj.state) {
|
switch (_atlobj.state) {
|
||||||
case VenisonObject.AWAITING_PLAYERS:
|
case AtlantiObject.AWAITING_PLAYERS:
|
||||||
_whoLabel.setText("Awaiting players...");
|
_whoLabel.setText("Awaiting players...");
|
||||||
_tileLabel.setTile(null);
|
_tileLabel.setTile(null);
|
||||||
break;
|
break;
|
||||||
case VenisonObject.GAME_OVER:
|
case AtlantiObject.GAME_OVER:
|
||||||
_whoLabel.setText("Game over.");
|
_whoLabel.setText("Game over.");
|
||||||
_tileLabel.setTile(null);
|
_tileLabel.setTile(null);
|
||||||
break;
|
break;
|
||||||
case VenisonObject.CANCELLED:
|
case AtlantiObject.CANCELLED:
|
||||||
_whoLabel.setText("Cancelled.");
|
_whoLabel.setText("Cancelled.");
|
||||||
_tileLabel.setTile(null);
|
_tileLabel.setTile(null);
|
||||||
break;
|
break;
|
||||||
@@ -107,20 +109,20 @@ public class TurnIndicatorView
|
|||||||
|
|
||||||
protected void updateTurnHolder ()
|
protected void updateTurnHolder ()
|
||||||
{
|
{
|
||||||
if (_venobj.state == VenisonObject.IN_PLAY) {
|
if (_atlobj.state == AtlantiObject.IN_PLAY) {
|
||||||
_whoLabel.setText(_venobj.turnHolder);
|
_whoLabel.setText(_atlobj.turnHolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateCurrentTile ()
|
protected void updateCurrentTile ()
|
||||||
{
|
{
|
||||||
// display the tile to be placed
|
// display the tile to be placed
|
||||||
_tileLabel.setTile(_venobj.currentTile);
|
_tileLabel.setTile(_atlobj.currentTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateRemainingTiles ()
|
protected void updateRemainingTiles ()
|
||||||
{
|
{
|
||||||
_countLabel.setText("Tiles remaining: " + (71-_venobj.tiles.size()));
|
_countLabel.setText("Tiles remaining: " + (71-_atlobj.tiles.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The label displaying whose turn it is. */
|
/** The label displaying whose turn it is. */
|
||||||
@@ -133,5 +135,5 @@ public class TurnIndicatorView
|
|||||||
protected JLabel _countLabel;
|
protected JLabel _countLabel;
|
||||||
|
|
||||||
/** A reference to the game object. */
|
/** A reference to the game object. */
|
||||||
protected VenisonObject _venobj;
|
protected AtlantiObject _atlobj;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiCodes.java,v 1.5 2002/05/21 04:45:10 mdb Exp $
|
// $Id: AtlantiCodes.java,v 1.6 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants used by the Venison game code.
|
* Constants used by the Atlanti game code.
|
||||||
*/
|
*/
|
||||||
public interface VenisonCodes
|
public interface AtlantiCodes
|
||||||
{
|
{
|
||||||
/** The message bundle identifier for translation messages. */
|
/** The message bundle identifier for translation messages. */
|
||||||
public static final String VENISON_MESSAGE_BUNDLE = "venison";
|
public static final String ATLANTI_MESSAGE_BUNDLE = "atlanti";
|
||||||
|
|
||||||
/** The number of piecens provided to each player. */
|
/** The number of piecens provided to each player. */
|
||||||
public static final int PIECENS_PER_PLAYER = 7;
|
public static final int PIECENS_PER_PLAYER = 7;
|
||||||
|
|
||||||
/** The name of the command posted by the {@link VenisonBoard} when
|
/** The name of the command posted by the {@link AtlantiBoard} when
|
||||||
* the user places a tile into a valid position. */
|
* the user places a tile into a valid position. */
|
||||||
public static final String TILE_PLACED = "tile_placed";
|
public static final String TILE_PLACED = "tile_placed";
|
||||||
|
|
||||||
/** The name of the command posted by the {@link VenisonBoard} when
|
/** The name of the command posted by the {@link AtlantiBoard} when
|
||||||
* the user places a piecen onto an unclaimed feature. */
|
* the user places a piecen onto an unclaimed feature. */
|
||||||
public static final String PIECEN_PLACED = "piecen_placed";
|
public static final String PIECEN_PLACED = "piecen_placed";
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,41 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiConfig.java,v 1.3 2001/10/24 03:24:53 mdb Exp $
|
// $Id: AtlantiConfig.java,v 1.4 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.data;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
|
|
||||||
import com.threerings.parlor.game.GameConfig;
|
import com.threerings.io.ObjectInputStream;
|
||||||
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
|
||||||
import com.threerings.parlor.data.TableConfig;
|
import com.threerings.parlor.data.TableConfig;
|
||||||
|
import com.threerings.parlor.game.GameConfig;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.client.AtlantiConfigurator;
|
||||||
|
import com.samskivert.atlanti.client.AtlantiController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the configuration parameters for a game of Venison.
|
* Describes the configuration parameters for the game.
|
||||||
*/
|
*/
|
||||||
public class VenisonConfig
|
public class AtlantiConfig extends GameConfig
|
||||||
extends GameConfig implements TableConfig
|
implements TableConfig
|
||||||
{
|
{
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Class getControllerClass ()
|
public Class getControllerClass ()
|
||||||
{
|
{
|
||||||
return VenisonController.class;
|
return AtlantiController.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public Class getConfiguratorClass ()
|
||||||
|
{
|
||||||
|
return AtlantiConfigurator.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public String getManagerClassName ()
|
public String getManagerClassName ()
|
||||||
{
|
{
|
||||||
return "com.threerings.venison.VenisonManager";
|
return "com.samskivert.atlanti.server.AtlantiManager";
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -53,18 +63,18 @@ public class VenisonConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void writeTo (DataOutputStream out)
|
public void writeObject (ObjectOutputStream out)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
super.writeTo(out);
|
out.defaultWriteObject();
|
||||||
out.writeInt(_desiredPlayers);
|
out.writeInt(_desiredPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void readFrom (DataInputStream in)
|
public void readObject (ObjectInputStream in)
|
||||||
throws IOException
|
throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
super.readFrom(in);
|
in.defaultReadObject();
|
||||||
_desiredPlayers = in.readInt();
|
_desiredPlayers = in.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiObject.dobj,v 1.1 2002/05/21 04:45:10 mdb Exp $
|
// $Id: AtlantiObject.dobj,v 1.2 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.data;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
|
|
||||||
import com.threerings.parlor.game.GameObject;
|
import com.threerings.parlor.game.GameObject;
|
||||||
import com.threerings.parlor.turn.TurnGameObject;
|
import com.threerings.parlor.turn.TurnGameObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The distributed object used to maintain state for the Venison game.
|
* The distributed object used to maintain state for the game.
|
||||||
*/
|
*/
|
||||||
public class VenisonObject extends GameObject
|
public class AtlantiObject extends GameObject
|
||||||
implements TurnGameObject
|
implements TurnGameObject
|
||||||
{
|
{
|
||||||
/** The username of the current turn holder. */
|
/** The username of the current turn holder. */
|
||||||
@@ -19,19 +19,25 @@ public class VenisonObject extends GameObject
|
|||||||
|
|
||||||
/** A set containing all of the tiles that are in play in this
|
/** A set containing all of the tiles that are in play in this
|
||||||
* game. */
|
* game. */
|
||||||
public DSet tiles = new DSet(VenisonTile.class);
|
public DSet tiles = new DSet();
|
||||||
|
|
||||||
/** The tile being placed by the current turn holder. This value is
|
/** The tile being placed by the current turn holder. This value is
|
||||||
* only valid while it is someone's turn. */
|
* only valid while it is someone's turn. */
|
||||||
public VenisonTile currentTile = VenisonTile.STARTING_TILE;
|
public AtlantiTile currentTile = AtlantiTile.STARTING_TILE;
|
||||||
|
|
||||||
/** A set containing all of the piecens that are placed on the
|
/** A set containing all of the piecens that are placed on the
|
||||||
* board. */
|
* board. */
|
||||||
public DSet piecens = new DSet(Piecen.class);
|
public DSet piecens = new DSet();
|
||||||
|
|
||||||
/** The scores for each player. */
|
/** The scores for each player. */
|
||||||
public int[] scores;
|
public int[] scores;
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public String[] getPlayers ()
|
||||||
|
{
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public String getTurnHolderFieldName ()
|
public String getTurnHolderFieldName ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiObject.java,v 1.8 2002/05/21 04:45:10 mdb Exp $
|
// $Id: AtlantiObject.java,v 1.9 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.data;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
|
|
||||||
import com.threerings.parlor.game.GameObject;
|
import com.threerings.parlor.game.GameObject;
|
||||||
import com.threerings.parlor.turn.TurnGameObject;
|
import com.threerings.parlor.turn.TurnGameObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The distributed object used to maintain state for the Venison game.
|
* The distributed object used to maintain state for the game.
|
||||||
*/
|
*/
|
||||||
public class VenisonObject extends GameObject
|
public class AtlantiObject extends GameObject
|
||||||
implements TurnGameObject
|
implements TurnGameObject
|
||||||
{
|
{
|
||||||
/** The field name of the <code>turnHolder</code> field. */
|
/** The field name of the <code>turnHolder</code> field. */
|
||||||
@@ -34,19 +34,25 @@ public class VenisonObject extends GameObject
|
|||||||
|
|
||||||
/** A set containing all of the tiles that are in play in this
|
/** A set containing all of the tiles that are in play in this
|
||||||
* game. */
|
* game. */
|
||||||
public DSet tiles = new DSet(VenisonTile.class);
|
public DSet tiles = new DSet();
|
||||||
|
|
||||||
/** The tile being placed by the current turn holder. This value is
|
/** The tile being placed by the current turn holder. This value is
|
||||||
* only valid while it is someone's turn. */
|
* only valid while it is someone's turn. */
|
||||||
public VenisonTile currentTile = VenisonTile.STARTING_TILE;
|
public AtlantiTile currentTile = AtlantiTile.STARTING_TILE;
|
||||||
|
|
||||||
/** A set containing all of the piecens that are placed on the
|
/** A set containing all of the piecens that are placed on the
|
||||||
* board. */
|
* board. */
|
||||||
public DSet piecens = new DSet(Piecen.class);
|
public DSet piecens = new DSet();
|
||||||
|
|
||||||
/** The scores for each player. */
|
/** The scores for each player. */
|
||||||
public int[] scores;
|
public int[] scores;
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public String[] getPlayers ()
|
||||||
|
{
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public String getTurnHolderFieldName ()
|
public String getTurnHolderFieldName ()
|
||||||
{
|
{
|
||||||
@@ -127,7 +133,7 @@ public class VenisonObject extends GameObject
|
|||||||
* clients) will apply the value change when they received the
|
* clients) will apply the value change when they received the
|
||||||
* attribute changed notification.
|
* attribute changed notification.
|
||||||
*/
|
*/
|
||||||
public void setCurrentTile (VenisonTile currentTile)
|
public void setCurrentTile (AtlantiTile currentTile)
|
||||||
{
|
{
|
||||||
this.currentTile = currentTile;
|
this.currentTile = currentTile;
|
||||||
requestAttributeChange(CURRENT_TILE, currentTile);
|
requestAttributeChange(CURRENT_TILE, currentTile);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiTile.java,v 1.14 2002/05/21 04:45:10 mdb Exp $
|
// $Id: AtlantiTile.java,v 1.15 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.data;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@@ -14,28 +14,38 @@ import java.awt.geom.AffineTransform;
|
|||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.samskivert.util.IntTuple;
|
import com.samskivert.util.IntTuple;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
|
import com.threerings.media.ImageManager;
|
||||||
|
import com.threerings.media.tile.ImageProvider;
|
||||||
import com.threerings.media.tile.Tile;
|
import com.threerings.media.tile.Tile;
|
||||||
import com.threerings.media.tile.TileManager;
|
import com.threerings.media.tile.TileManager;
|
||||||
import com.threerings.media.tile.UniformTileSet;
|
import com.threerings.media.tile.UniformTileSet;
|
||||||
|
|
||||||
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.Log;
|
||||||
|
import com.samskivert.atlanti.util.FeatureUtil;
|
||||||
|
import com.samskivert.atlanti.util.PiecenUtil;
|
||||||
|
import com.samskivert.atlanti.util.TileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a single tile in play on the Venison game board.
|
* Represents a single tile in play on the game board.
|
||||||
|
*
|
||||||
|
* <p><em>Note:</em> this should really be split into a pure data class
|
||||||
|
* and an associated visualization class in the
|
||||||
|
* <code>altanti.client</code> package.
|
||||||
*/
|
*/
|
||||||
public class VenisonTile
|
public class AtlantiTile
|
||||||
implements DSet.Entry, TileCodes, Cloneable, Comparable
|
implements DSet.Entry, TileCodes, Cloneable, Comparable
|
||||||
{
|
{
|
||||||
/** The starting tile. */
|
/** The starting tile. */
|
||||||
public static final VenisonTile STARTING_TILE =
|
public static final AtlantiTile STARTING_TILE =
|
||||||
new VenisonTile(CITY_ONE_ROAD_STRAIGHT, false, NORTH, 0, 0);
|
new AtlantiTile(CITY_ONE_ROAD_STRAIGHT, false, NORTH, 0, 0);
|
||||||
|
|
||||||
/** Activate this to render a piecen on every feature (useful for the
|
/** Activate this to render a piecen on every feature (useful for the
|
||||||
* tile geometry test). */
|
* tile geometry test). */
|
||||||
@@ -58,19 +68,19 @@ public class VenisonTile
|
|||||||
* connects to this tile, it will be represented here by a non-zero
|
* connects to this tile, it will be represented here by a non-zero
|
||||||
* claim group in the array slot that corresponds to the claimed
|
* claim group in the array slot that corresponds to the claimed
|
||||||
* feature. */
|
* feature. */
|
||||||
public int[] claims;
|
public transient int[] claims;
|
||||||
|
|
||||||
/** A reference to our static feature descriptions. */
|
/** A reference to our static feature descriptions. */
|
||||||
public Feature[] features;
|
public transient Feature[] features;
|
||||||
|
|
||||||
/** A reference to the piecen on this tile or null if no piecen has
|
/** A reference to the piecen on this tile or null if no piecen has
|
||||||
* been placed on this tile. */
|
* been placed on this tile. */
|
||||||
public Piecen piecen;
|
public transient Piecen piecen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a tile with all of the supplied tile information.
|
* Constructs a tile with all of the supplied tile information.
|
||||||
*/
|
*/
|
||||||
public VenisonTile (int type, boolean hasShield, int orientation,
|
public AtlantiTile (int type, boolean hasShield, int orientation,
|
||||||
int x, int y)
|
int x, int y)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@@ -87,7 +97,7 @@ public class VenisonTile
|
|||||||
* Constructs a tile with the type information set, but in the default
|
* Constructs a tile with the type information set, but in the default
|
||||||
* <code>NORTH</code> orientation and with no position.
|
* <code>NORTH</code> orientation and with no position.
|
||||||
*/
|
*/
|
||||||
public VenisonTile (int type, boolean hasShield)
|
public AtlantiTile (int type, boolean hasShield)
|
||||||
{
|
{
|
||||||
this(type, hasShield, NORTH, 0, 0);
|
this(type, hasShield, NORTH, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -95,7 +105,7 @@ public class VenisonTile
|
|||||||
/**
|
/**
|
||||||
* Constructs a blank tile, suitable for unserialization.
|
* Constructs a blank tile, suitable for unserialization.
|
||||||
*/
|
*/
|
||||||
public VenisonTile ()
|
public AtlantiTile ()
|
||||||
{
|
{
|
||||||
// nothing doing
|
// nothing doing
|
||||||
}
|
}
|
||||||
@@ -348,11 +358,11 @@ public class VenisonTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a copy of this Venison tile object.
|
* Returns a copy of this tile object.
|
||||||
*/
|
*/
|
||||||
public Object clone ()
|
public Object clone ()
|
||||||
{
|
{
|
||||||
return new VenisonTile(type, hasShield, orientation, x, y);
|
return new AtlantiTile(type, hasShield, orientation, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -365,8 +375,8 @@ public class VenisonTile
|
|||||||
if (other == null) {
|
if (other == null) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
} else if (other instanceof VenisonTile) {
|
} else if (other instanceof AtlantiTile) {
|
||||||
VenisonTile tile = (VenisonTile)other;
|
AtlantiTile tile = (AtlantiTile)other;
|
||||||
return (tile.x == x) ? y - tile.y : x - tile.x;
|
return (tile.x == x) ? y - tile.y : x - tile.x;
|
||||||
|
|
||||||
} else if (other instanceof IntTuple) {
|
} else if (other instanceof IntTuple) {
|
||||||
@@ -390,32 +400,20 @@ public class VenisonTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Object getKey ()
|
public Comparable getKey ()
|
||||||
{
|
{
|
||||||
// our key is our coordinates conflated into one integer
|
// our key is our coordinates conflated into one integer
|
||||||
return new Integer((x + 128) * 256 + y + 128);
|
return new Integer((x + 128) * 256 + y + 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
/**
|
||||||
public void writeTo (DataOutputStream out)
|
* After we've been unserialized we have to initialize some derived
|
||||||
throws IOException
|
* fields.
|
||||||
|
*/
|
||||||
|
public void readObject (ObjectInputStream in)
|
||||||
|
throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
out.writeInt(type);
|
in.defaultReadObject();
|
||||||
out.writeBoolean(hasShield);
|
|
||||||
out.writeInt(orientation);
|
|
||||||
out.writeInt(x);
|
|
||||||
out.writeInt(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited
|
|
||||||
public void readFrom (DataInputStream in)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
type = in.readInt();
|
|
||||||
hasShield = in.readBoolean();
|
|
||||||
orientation = in.readInt();
|
|
||||||
x = in.readInt();
|
|
||||||
y = in.readInt();
|
|
||||||
initFeatures();
|
initFeatures();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,8 +452,9 @@ public class VenisonTile
|
|||||||
* Someone needs to configure this so that we can display tiles on
|
* Someone needs to configure this so that we can display tiles on
|
||||||
* screen.
|
* screen.
|
||||||
*/
|
*/
|
||||||
public static void setTileManager (TileManager tmgr)
|
public static void setManagers (ImageManager imgr, TileManager tmgr)
|
||||||
{
|
{
|
||||||
|
_imgr = imgr;
|
||||||
_tmgr = tmgr;
|
_tmgr = tmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,12 +465,9 @@ public class VenisonTile
|
|||||||
{
|
{
|
||||||
// load up the tile set if we haven't already
|
// load up the tile set if we haven't already
|
||||||
if (_tset == null) {
|
if (_tset == null) {
|
||||||
_tset = new UniformTileSet();
|
_tset = _tmgr.loadTileSet(TILES_IMG_PATH, TILE_TYPES,
|
||||||
_tset.setTileCount(TILE_TYPES);
|
TILE_WIDTH, TILE_HEIGHT);
|
||||||
_tset.setWidth(TILE_WIDTH);
|
_tset.setImageProvider(_imgprov);
|
||||||
_tset.setHeight(TILE_HEIGHT);
|
|
||||||
_tset.setImagePath(TILES_IMG_PATH);
|
|
||||||
_tset.setImageProvider(_tmgr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch the tile
|
// fetch the tile
|
||||||
@@ -485,12 +481,9 @@ public class VenisonTile
|
|||||||
{
|
{
|
||||||
// load up the tile set if we haven't already
|
// load up the tile set if we haven't already
|
||||||
if (_stset == null) {
|
if (_stset == null) {
|
||||||
_stset = new UniformTileSet();
|
_stset = _tmgr.loadTileSet(SHIELD_IMG_PATH, 1,
|
||||||
_stset.setTileCount(1);
|
SHIELD_SIZE, SHIELD_SIZE);
|
||||||
_stset.setWidth(SHIELD_SIZE);
|
_stset.setImageProvider(_imgprov);
|
||||||
_stset.setHeight(SHIELD_SIZE);
|
|
||||||
_stset.setImagePath(SHIELD_IMG_PATH);
|
|
||||||
_stset.setImageProvider(_tmgr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch the tile
|
// fetch the tile
|
||||||
@@ -498,11 +491,25 @@ public class VenisonTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The tile image that we use to render this tile. */
|
/** The tile image that we use to render this tile. */
|
||||||
protected Image _tileImage;
|
protected transient Image _tileImage;
|
||||||
|
|
||||||
|
/** Our image manager. */
|
||||||
|
protected static ImageManager _imgr;
|
||||||
|
|
||||||
/** Our tile manager. */
|
/** Our tile manager. */
|
||||||
protected static TileManager _tmgr;
|
protected static TileManager _tmgr;
|
||||||
|
|
||||||
|
/** Used to load tile images. The default image provider (the tile
|
||||||
|
* manager) optimizes the images for display on the screen which seems
|
||||||
|
* to fuck Java's ability to apply rotational transforms to the image
|
||||||
|
* prior to rendering. Yay! */
|
||||||
|
protected static ImageProvider _imgprov = new ImageProvider() {
|
||||||
|
public Image loadImage (String path)
|
||||||
|
throws IOException {
|
||||||
|
return _imgr.loadImage(path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Our tile image tileset. */
|
/** Our tile image tileset. */
|
||||||
protected static UniformTileSet _tset;
|
protected static UniformTileSet _tset;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: Feature.java,v 1.5 2001/12/18 13:14:58 mdb Exp $
|
// $Id: Feature.java,v 1.6 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.data;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@@ -17,6 +17,10 @@ import java.awt.geom.RoundRectangle2D;
|
|||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.Log;
|
||||||
|
import com.samskivert.atlanti.util.FeatureUtil;
|
||||||
|
import com.samskivert.atlanti.util.TileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents all of the necessary information for a particular feature of
|
* Represents all of the necessary information for a particular feature of
|
||||||
* a particular tile.
|
* a particular tile.
|
||||||
@@ -24,6 +28,16 @@ import com.samskivert.util.StringUtil;
|
|||||||
public class Feature
|
public class Feature
|
||||||
implements TileCodes
|
implements TileCodes
|
||||||
{
|
{
|
||||||
|
/** Maps piecen color codes to colors. */
|
||||||
|
public static Color[] PIECEN_COLOR_MAP = {
|
||||||
|
new Color(0x0246B7), // BLUE
|
||||||
|
new Color(0x028A12), // GREEN
|
||||||
|
new Color(0xF47A02), // ORANGE
|
||||||
|
new Color(0xC20292), // MAGENTA
|
||||||
|
new Color(0xB90202), // RED
|
||||||
|
new Color(0xFECA11), // YELLOW
|
||||||
|
};
|
||||||
|
|
||||||
/** The type of this feature. */
|
/** The type of this feature. */
|
||||||
public int type;
|
public int type;
|
||||||
|
|
||||||
@@ -355,16 +369,6 @@ public class Feature
|
|||||||
Color.yellow.darker(), // CLOISTER
|
Color.yellow.darker(), // CLOISTER
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Maps piecen color codes to colors. */
|
|
||||||
protected static Color[] PIECEN_COLOR_MAP = {
|
|
||||||
new Color(0x0246B7), // BLUE
|
|
||||||
new Color(0x028A12), // GREEN
|
|
||||||
new Color(0xF47A02), // ORANGE
|
|
||||||
new Color(0xC20292), // MAGENTA
|
|
||||||
new Color(0xB90202), // RED
|
|
||||||
new Color(0xFECA11), // YELLOW
|
|
||||||
};
|
|
||||||
|
|
||||||
/** For rendering piecens with alpha. */
|
/** For rendering piecens with alpha. */
|
||||||
protected static final Composite ALPHA_PLACING =
|
protected static final Composite ALPHA_PLACING =
|
||||||
AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
|
AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: Piecen.java,v 1.3 2002/05/21 04:45:09 mdb Exp $
|
// $Id: Piecen.java,v 1.4 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.data;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
@@ -75,7 +75,7 @@ public class Piecen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Object getKey ()
|
public Comparable getKey ()
|
||||||
{
|
{
|
||||||
// our key is our coordinates conflated into one integer
|
// our key is our coordinates conflated into one integer
|
||||||
return new Integer((x + 128) * 256 + y + 128);
|
return new Integer((x + 128) * 256 + y + 128);
|
||||||
@@ -108,8 +108,8 @@ public class Piecen
|
|||||||
if (other == null) {
|
if (other == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else if (other instanceof VenisonTile) {
|
} else if (other instanceof AtlantiTile) {
|
||||||
VenisonTile tile = (VenisonTile)other;
|
AtlantiTile tile = (AtlantiTile)other;
|
||||||
return (tile.x == x) ? (y == tile.y) : false;
|
return (tile.x == x) ? (y == tile.y) : false;
|
||||||
|
|
||||||
} else if (other instanceof Piecen) {
|
} else if (other instanceof Piecen) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileCodes.java,v 1.9 2001/12/18 11:58:53 mdb Exp $
|
// $Id: TileCodes.java,v 1.10 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A repository for constants related to the tiles that are used in the
|
* A repository for constants related to the tiles that are used in the
|
||||||
* game of Venison.
|
* game of Atlantissonne.
|
||||||
*/
|
*/
|
||||||
public interface TileCodes
|
public interface TileCodes
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiManager.java,v 1.23 2002/05/21 04:45:10 mdb Exp $
|
// $Id: AtlantiManager.java,v 1.24 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.server;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -22,31 +22,40 @@ import com.threerings.presents.dobj.MessageEvent;
|
|||||||
import com.threerings.presents.dobj.MessageEvent;
|
import com.threerings.presents.dobj.MessageEvent;
|
||||||
|
|
||||||
import com.threerings.crowd.chat.ChatProvider;
|
import com.threerings.crowd.chat.ChatProvider;
|
||||||
|
import com.threerings.crowd.chat.SpeakProvider;
|
||||||
import com.threerings.crowd.data.PlaceObject;
|
import com.threerings.crowd.data.PlaceObject;
|
||||||
|
|
||||||
import com.threerings.crowd.chat.ChatMessageHandler;
|
|
||||||
import com.threerings.crowd.chat.ChatService;
|
|
||||||
import com.threerings.crowd.data.PlaceConfig;
|
import com.threerings.crowd.data.PlaceConfig;
|
||||||
import com.threerings.crowd.server.PlaceManager;
|
import com.threerings.crowd.server.PlaceManager;
|
||||||
|
|
||||||
import com.threerings.parlor.game.GameManager;
|
import com.threerings.parlor.game.GameManager;
|
||||||
import com.threerings.parlor.turn.TurnGameManager;
|
import com.threerings.parlor.turn.TurnGameManager;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.Log;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiCodes;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiObject;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiTile;
|
||||||
|
import com.samskivert.atlanti.data.Feature;
|
||||||
|
import com.samskivert.atlanti.data.Piecen;
|
||||||
|
import com.samskivert.atlanti.data.TileCodes;
|
||||||
|
import com.samskivert.atlanti.util.FeatureUtil;
|
||||||
|
import com.samskivert.atlanti.util.TileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main coordinator of the Venison game on the server side.
|
* The main coordinator of the Atlantissonne game on the server side.
|
||||||
*/
|
*/
|
||||||
public class VenisonManager extends GameManager
|
public class AtlantiManager extends GameManager
|
||||||
implements TurnGameManager, VenisonCodes, SetListener
|
implements TurnGameManager, AtlantiCodes, SetListener
|
||||||
{
|
{
|
||||||
public VenisonManager ()
|
public AtlantiManager ()
|
||||||
{
|
{
|
||||||
addDelegate(_delegate = new VenisonManagerDelegate(this));
|
addDelegate(_delegate = new AtlantiManagerDelegate(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected Class getPlaceObjectClass ()
|
protected Class getPlaceObjectClass ()
|
||||||
{
|
{
|
||||||
return VenisonObject.class;
|
return AtlantiObject.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTilesInBox ()
|
public int getTilesInBox ()
|
||||||
@@ -60,8 +69,6 @@ public class VenisonManager extends GameManager
|
|||||||
super.didInit();
|
super.didInit();
|
||||||
|
|
||||||
// register our message handlers
|
// register our message handlers
|
||||||
registerMessageHandler(
|
|
||||||
ChatService.SPEAK_REQUEST, new ChatMessageHandler());
|
|
||||||
registerMessageHandler(PLACE_TILE_REQUEST, new PlaceTileHandler());
|
registerMessageHandler(PLACE_TILE_REQUEST, new PlaceTileHandler());
|
||||||
registerMessageHandler(
|
registerMessageHandler(
|
||||||
PLACE_PIECEN_REQUEST, new PlacePiecenHandler());
|
PLACE_PIECEN_REQUEST, new PlacePiecenHandler());
|
||||||
@@ -75,7 +82,7 @@ public class VenisonManager extends GameManager
|
|||||||
super.didStartup();
|
super.didStartup();
|
||||||
|
|
||||||
// grab our own casted game object reference
|
// grab our own casted game object reference
|
||||||
_venobj = (VenisonObject)_gameobj;
|
_atlobj = (AtlantiObject)_gameobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,18 +106,18 @@ public class VenisonManager extends GameManager
|
|||||||
_tiles.clear();
|
_tiles.clear();
|
||||||
|
|
||||||
// create a claim group vector
|
// create a claim group vector
|
||||||
_claimGroupVector = new int[_players.length];
|
_claimGroupVector = new int[getPlayerCount()];
|
||||||
|
|
||||||
// clear out the scores
|
// clear out the scores
|
||||||
_venobj.setScores(new int[_players.length]);
|
_atlobj.setScores(new int[getPlayerCount()]);
|
||||||
|
|
||||||
// clear out the tile and piecen set
|
// clear out the tile and piecen set
|
||||||
_venobj.setTiles(new DSet(VenisonTile.class));
|
_atlobj.setTiles(new DSet());
|
||||||
_venobj.setPiecens(new DSet(Piecen.class));
|
_atlobj.setPiecens(new DSet());
|
||||||
|
|
||||||
// and add the starting tile
|
// and add the starting tile
|
||||||
VenisonTile start = TileUtil.getStartingTile();
|
AtlantiTile start = TileUtil.getStartingTile();
|
||||||
_venobj.addToTiles(start);
|
_atlobj.addToTiles(start);
|
||||||
_tiles.add(start);
|
_tiles.add(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,8 +126,14 @@ public class VenisonManager extends GameManager
|
|||||||
{
|
{
|
||||||
// let the players know what the next tile is that should be
|
// let the players know what the next tile is that should be
|
||||||
// played
|
// played
|
||||||
VenisonTile tile = (VenisonTile)_tilesInBox.remove(0);
|
AtlantiTile tile = (AtlantiTile)_tilesInBox.remove(0);
|
||||||
_venobj.setCurrentTile(tile);
|
_atlobj.setCurrentTile(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void turnDidStart ()
|
||||||
|
{
|
||||||
|
// nothing doing
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -142,9 +155,9 @@ public class VenisonManager extends GameManager
|
|||||||
// compute the final scores by iterating over each tile and
|
// compute the final scores by iterating over each tile and
|
||||||
// scoring its features
|
// scoring its features
|
||||||
Piecen[] piecens = getPiecens();
|
Piecen[] piecens = getPiecens();
|
||||||
Iterator iter = _venobj.tiles.entries();
|
Iterator iter = _atlobj.tiles.entries();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
VenisonTile tile = (VenisonTile)iter.next();
|
AtlantiTile tile = (AtlantiTile)iter.next();
|
||||||
scoreFeatures(tile, piecens, true);
|
scoreFeatures(tile, piecens, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +165,7 @@ public class VenisonManager extends GameManager
|
|||||||
scoreFarms();
|
scoreFarms();
|
||||||
|
|
||||||
// update the final scores
|
// update the final scores
|
||||||
_venobj.setScores(_venobj.scores);
|
_atlobj.setScores(_atlobj.scores);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -163,8 +176,8 @@ public class VenisonManager extends GameManager
|
|||||||
protected Piecen[] getPiecens ()
|
protected Piecen[] getPiecens ()
|
||||||
{
|
{
|
||||||
// create a piecen array that we can manipulate while scoring
|
// create a piecen array that we can manipulate while scoring
|
||||||
Piecen[] piecens = new Piecen[_venobj.piecens.size()];
|
Piecen[] piecens = new Piecen[_atlobj.piecens.size()];
|
||||||
Iterator iter = _venobj.piecens.entries();
|
Iterator iter = _atlobj.piecens.entries();
|
||||||
for (int i = 0; iter.hasNext(); i++) {
|
for (int i = 0; iter.hasNext(); i++) {
|
||||||
piecens[i] = (Piecen)iter.next();
|
piecens[i] = (Piecen)iter.next();
|
||||||
}
|
}
|
||||||
@@ -182,7 +195,7 @@ public class VenisonManager extends GameManager
|
|||||||
* we don't remove piecens from the board as we score them.
|
* we don't remove piecens from the board as we score them.
|
||||||
*/
|
*/
|
||||||
protected void scoreFeatures (
|
protected void scoreFeatures (
|
||||||
VenisonTile tile, Piecen[] piecens, boolean finalTally)
|
AtlantiTile tile, Piecen[] piecens, boolean finalTally)
|
||||||
{
|
{
|
||||||
// potentially score all features on the tile
|
// potentially score all features on the tile
|
||||||
for (int i = 0; i < tile.features.length; i++) {
|
for (int i = 0; i < tile.features.length; i++) {
|
||||||
@@ -222,27 +235,27 @@ public class VenisonManager extends GameManager
|
|||||||
StringBuffer names = new StringBuffer();
|
StringBuffer names = new StringBuffer();
|
||||||
for (int p = 0; p < cgv.length; p++) {
|
for (int p = 0; p < cgv.length; p++) {
|
||||||
// adjust the score
|
// adjust the score
|
||||||
_venobj.scores[p] += (score * cgv[p]);
|
_atlobj.scores[p] += (score * cgv[p]);
|
||||||
|
|
||||||
// append the scorers name to the list
|
// append the scorers name to the list
|
||||||
if (cgv[p] > 0) {
|
if (cgv[p] > 0) {
|
||||||
if (names.length() > 0) {
|
if (names.length() > 0) {
|
||||||
names.append(", ");
|
names.append(", ");
|
||||||
}
|
}
|
||||||
names.append(_players[p]);
|
names.append(getPlayerName(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = qual + " " + TileCodes.FEATURE_NAMES[f.type] +
|
String message = qual + " " + TileCodes.FEATURE_NAMES[f.type] +
|
||||||
" scored " + score + " points for " + names + ".";
|
" scored " + score + " points for " + names + ".";
|
||||||
ChatProvider.sendSystemMessage(
|
SpeakProvider.sendSystemSpeak(
|
||||||
_venobj.getOid(), VENISON_MESSAGE_BUNDLE, message);
|
_atlobj, ATLANTI_MESSAGE_BUNDLE, message);
|
||||||
|
|
||||||
Log.info("New scores: " + StringUtil.toString(_venobj.scores));
|
Log.info("New scores: " + StringUtil.toString(_atlobj.scores));
|
||||||
|
|
||||||
// broadcast the new scores if this isn't the final tally
|
// broadcast the new scores if this isn't the final tally
|
||||||
if (!finalTally) {
|
if (!finalTally) {
|
||||||
_venobj.setScores(_venobj.scores);
|
_atlobj.setScores(_atlobj.scores);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and free up the scored piecens
|
// and free up the scored piecens
|
||||||
@@ -259,7 +272,7 @@ public class VenisonManager extends GameManager
|
|||||||
for (int dx = -1; dx < 2; dx++) {
|
for (int dx = -1; dx < 2; dx++) {
|
||||||
for (int dy = -1; dy < 2; dy++) {
|
for (int dy = -1; dy < 2; dy++) {
|
||||||
// find our neighbor and make sure they exist
|
// find our neighbor and make sure they exist
|
||||||
VenisonTile neighbor =
|
AtlantiTile neighbor =
|
||||||
TileUtil.findTile(_tiles, tile.x + dx, tile.y + dy);
|
TileUtil.findTile(_tiles, tile.x + dx, tile.y + dy);
|
||||||
if (neighbor == null) {
|
if (neighbor == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -306,18 +319,18 @@ public class VenisonManager extends GameManager
|
|||||||
|
|
||||||
// deliver a chat notification to tell the
|
// deliver a chat notification to tell the
|
||||||
// players about the score
|
// players about the score
|
||||||
String message = _players[p.owner] + " scored " +
|
String message = getPlayerName(p.owner) + " scored " +
|
||||||
score + " points for " + qual + " temple.";
|
score + " points for " + qual + " temple.";
|
||||||
ChatProvider.sendSystemMessage(
|
SpeakProvider.sendSystemSpeak(
|
||||||
_venobj.getOid(), VENISON_MESSAGE_BUNDLE, message);
|
_atlobj, ATLANTI_MESSAGE_BUNDLE, message);
|
||||||
|
|
||||||
// add the score to the owning player
|
// add the score to the owning player
|
||||||
_venobj.scores[p.owner] += score;
|
_atlobj.scores[p.owner] += score;
|
||||||
|
|
||||||
// only broadcast the updated scores if this isn't
|
// only broadcast the updated scores if this isn't
|
||||||
// the final tally
|
// the final tally
|
||||||
if (!finalTally) {
|
if (!finalTally) {
|
||||||
_venobj.setScores(_venobj.scores);
|
_atlobj.setScores(_atlobj.scores);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and clear out the piecen (only removing it from
|
// and clear out the piecen (only removing it from
|
||||||
@@ -335,7 +348,7 @@ public class VenisonManager extends GameManager
|
|||||||
protected void scoreFarms ()
|
protected void scoreFarms ()
|
||||||
{
|
{
|
||||||
HashIntMap cities = new HashIntMap();
|
HashIntMap cities = new HashIntMap();
|
||||||
int[] cityScores = new int[_players.length];
|
int[] cityScores = new int[getPlayerCount()];
|
||||||
|
|
||||||
// clear out the claims for incompleted cities and claim unclaimed
|
// clear out the claims for incompleted cities and claim unclaimed
|
||||||
// completed cities
|
// completed cities
|
||||||
@@ -344,7 +357,7 @@ public class VenisonManager extends GameManager
|
|||||||
// do the big process-ola
|
// do the big process-ola
|
||||||
int tsize = _tiles.size();
|
int tsize = _tiles.size();
|
||||||
for (int i = 0; i < tsize; i++) {
|
for (int i = 0; i < tsize; i++) {
|
||||||
VenisonTile tile = (VenisonTile)_tiles.get(i);
|
AtlantiTile tile = (AtlantiTile)_tiles.get(i);
|
||||||
|
|
||||||
// iterate over all of the city features in this tile
|
// iterate over all of the city features in this tile
|
||||||
for (int f = 0; f < tile.features.length; f++) {
|
for (int f = 0; f < tile.features.length; f++) {
|
||||||
@@ -410,10 +423,10 @@ public class VenisonManager extends GameManager
|
|||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
int cityClaim = ((Integer)iter.next()).intValue();
|
int cityClaim = ((Integer)iter.next()).intValue();
|
||||||
int[] farmClaims = (int[])cities.get(cityClaim);
|
int[] farmClaims = (int[])cities.get(cityClaim);
|
||||||
int[] pcount = new int[_players.length];
|
int[] pcount = new int[getPlayerCount()];
|
||||||
int max = 0;
|
int max = 0;
|
||||||
|
|
||||||
Iterator piter = _venobj.piecens.entries();
|
Iterator piter = _atlobj.piecens.entries();
|
||||||
while (piter.hasNext()) {
|
while (piter.hasNext()) {
|
||||||
Piecen p = (Piecen)piter.next();
|
Piecen p = (Piecen)piter.next();
|
||||||
// see if the piecen is on any of the farms
|
// see if the piecen is on any of the farms
|
||||||
@@ -442,7 +455,7 @@ public class VenisonManager extends GameManager
|
|||||||
for (int i = 0; i < pcount.length; i++) {
|
for (int i = 0; i < pcount.length; i++) {
|
||||||
if (pcount[i] == max) {
|
if (pcount[i] == max) {
|
||||||
Log.info("Scoring city for player [cgroup=" + cityClaim +
|
Log.info("Scoring city for player [cgroup=" + cityClaim +
|
||||||
", player=" + _players[i] +
|
", player=" + getPlayerName(i) +
|
||||||
", pcount=" + pcount[i] + "].");
|
", pcount=" + pcount[i] + "].");
|
||||||
cityScores[i] += 4;
|
cityScores[i] += 4;
|
||||||
}
|
}
|
||||||
@@ -451,13 +464,13 @@ public class VenisonManager extends GameManager
|
|||||||
|
|
||||||
// now report the scoring and transfer the counts to the score
|
// now report the scoring and transfer the counts to the score
|
||||||
// array
|
// array
|
||||||
for (int i = 0; i < _players.length; i++) {
|
for (int i = 0; i < getPlayerCount(); i++) {
|
||||||
if (cityScores[i] > 0) {
|
if (cityScores[i] > 0) {
|
||||||
_venobj.scores[i] += cityScores[i];
|
_atlobj.scores[i] += cityScores[i];
|
||||||
String message = _players[i] + " scores " + cityScores[i] +
|
String message = getPlayerName(i) + " scores " +
|
||||||
" points for fisheries.";
|
cityScores[i] + " points for fisheries.";
|
||||||
ChatProvider.sendSystemMessage(
|
SpeakProvider.sendSystemSpeak(
|
||||||
_venobj.getOid(), VENISON_MESSAGE_BUNDLE, message);
|
_atlobj, ATLANTI_MESSAGE_BUNDLE, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -524,7 +537,7 @@ public class VenisonManager extends GameManager
|
|||||||
|
|
||||||
// if this isn't the final tally, we also clear 'em from the board
|
// if this isn't the final tally, we also clear 'em from the board
|
||||||
if (!finalTally) {
|
if (!finalTally) {
|
||||||
Iterator iter = _venobj.piecens.entries();
|
Iterator iter = _atlobj.piecens.entries();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Piecen p = (Piecen)iter.next();
|
Piecen p = (Piecen)iter.next();
|
||||||
if (p.claimGroup == claimGroup) {
|
if (p.claimGroup == claimGroup) {
|
||||||
@@ -550,14 +563,14 @@ public class VenisonManager extends GameManager
|
|||||||
Log.warning("Requested to remove piecen that is not " +
|
Log.warning("Requested to remove piecen that is not " +
|
||||||
"associated with any tile [piecen=" + piecen + "].");
|
"associated with any tile [piecen=" + piecen + "].");
|
||||||
} else {
|
} else {
|
||||||
VenisonTile tile = (VenisonTile)_tiles.get(tidx);
|
AtlantiTile tile = (AtlantiTile)_tiles.get(tidx);
|
||||||
// and clear the piecen
|
// and clear the piecen
|
||||||
tile.clearPiecen();
|
tile.clearPiecen();
|
||||||
}
|
}
|
||||||
|
|
||||||
// also remove from the piecens dset if requested
|
// also remove from the piecens dset if requested
|
||||||
if (removeFromPiecens) {
|
if (removeFromPiecens) {
|
||||||
_venobj.removeFromPiecens(piecen.getKey());
|
_atlobj.removeFromPiecens(piecen.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,11 +582,11 @@ public class VenisonManager extends GameManager
|
|||||||
// before scoring so that the players can see the piecen pop up on
|
// before scoring so that the players can see the piecen pop up on
|
||||||
// their screen and then disappear with a scoring notice rather
|
// their screen and then disappear with a scoring notice rather
|
||||||
// than never show up at all; plus it simplifies our code
|
// than never show up at all; plus it simplifies our code
|
||||||
if (event.getName().equals(VenisonObject.PIECENS)) {
|
if (event.getName().equals(AtlantiObject.PIECENS)) {
|
||||||
Piecen piecen = (Piecen)event.getEntry();
|
Piecen piecen = (Piecen)event.getEntry();
|
||||||
|
|
||||||
// make sure this is a valid placement
|
// make sure this is a valid placement
|
||||||
VenisonTile tile = (VenisonTile)_venobj.tiles.get(piecen.getKey());
|
AtlantiTile tile = (AtlantiTile)_atlobj.tiles.get(piecen.getKey());
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
Log.warning("Can't find tile for piecen scoring " +
|
Log.warning("Can't find tile for piecen scoring " +
|
||||||
piecen + ".");
|
piecen + ".");
|
||||||
@@ -604,14 +617,14 @@ public class VenisonManager extends GameManager
|
|||||||
*/
|
*/
|
||||||
protected void handlePlaceTileRequest (MessageEvent event)
|
protected void handlePlaceTileRequest (MessageEvent event)
|
||||||
{
|
{
|
||||||
VenisonTile tile = (VenisonTile)event.getArgs()[0];
|
AtlantiTile tile = (AtlantiTile)event.getArgs()[0];
|
||||||
int pidx = _delegate.getTurnHolderIndex();
|
int pidx = _delegate.getTurnHolderIndex();
|
||||||
|
|
||||||
// make sure it's this player's turn
|
// make sure it's this player's turn
|
||||||
if (_playerOids[pidx] != event.getSourceOid()) {
|
if (_playerOids[pidx] != event.getSourceOid()) {
|
||||||
Log.warning("Requested to place tile by non-turn holder " +
|
Log.warning("Requested to place tile by non-turn holder " +
|
||||||
"[event=" + event +
|
"[event=" + event +
|
||||||
", turnHolder=" + _venobj.turnHolder + "].");
|
", turnHolder=" + _atlobj.turnHolder + "].");
|
||||||
|
|
||||||
// make sure this is a valid placement
|
// make sure this is a valid placement
|
||||||
} else if (TileUtil.isValidPlacement(_tiles, tile)) {
|
} else if (TileUtil.isValidPlacement(_tiles, tile)) {
|
||||||
@@ -623,7 +636,7 @@ public class VenisonManager extends GameManager
|
|||||||
TileUtil.inheritClaims(_tiles, tile);
|
TileUtil.inheritClaims(_tiles, tile);
|
||||||
|
|
||||||
// add the tile to the tiles set
|
// add the tile to the tiles set
|
||||||
_venobj.addToTiles(tile);
|
_atlobj.addToTiles(tile);
|
||||||
|
|
||||||
// placing a piece may have completed road or city
|
// placing a piece may have completed road or city
|
||||||
// features. if it did, we score them now
|
// features. if it did, we score them now
|
||||||
@@ -634,7 +647,7 @@ public class VenisonManager extends GameManager
|
|||||||
// if the player has no free piecens or if there are no
|
// if the player has no free piecens or if there are no
|
||||||
// unclaimed features on this tile, we end their turn
|
// unclaimed features on this tile, we end their turn
|
||||||
// straight away
|
// straight away
|
||||||
int pcount = TileUtil.countPiecens(_venobj.piecens, pidx);
|
int pcount = TileUtil.countPiecens(_atlobj.piecens, pidx);
|
||||||
if (pcount >= PIECENS_PER_PLAYER ||
|
if (pcount >= PIECENS_PER_PLAYER ||
|
||||||
!tile.hasUnclaimedFeature()) {
|
!tile.hasUnclaimedFeature()) {
|
||||||
_delegate.endTurn();
|
_delegate.endTurn();
|
||||||
@@ -651,15 +664,15 @@ public class VenisonManager extends GameManager
|
|||||||
protected void handlePlacePiecenRequest (MessageEvent event)
|
protected void handlePlacePiecenRequest (MessageEvent event)
|
||||||
{
|
{
|
||||||
Piecen piecen = (Piecen)event.getArgs()[0];
|
Piecen piecen = (Piecen)event.getArgs()[0];
|
||||||
VenisonTile tile = (VenisonTile)_venobj.tiles.get(piecen.getKey());
|
AtlantiTile tile = (AtlantiTile)_atlobj.tiles.get(piecen.getKey());
|
||||||
int pidx = _delegate.getTurnHolderIndex();
|
int pidx = _delegate.getTurnHolderIndex();
|
||||||
int pcount = TileUtil.countPiecens(_venobj.piecens, pidx);
|
int pcount = TileUtil.countPiecens(_atlobj.piecens, pidx);
|
||||||
|
|
||||||
// make sure it's this player's turn
|
// make sure it's this player's turn
|
||||||
if (_playerOids[pidx] != event.getSourceOid()) {
|
if (_playerOids[pidx] != event.getSourceOid()) {
|
||||||
Log.warning("Requested to place piecen by non-turn holder " +
|
Log.warning("Requested to place piecen by non-turn holder " +
|
||||||
"[event=" + event +
|
"[event=" + event +
|
||||||
", turnHolder=" + _venobj.turnHolder + "].");
|
", turnHolder=" + _atlobj.turnHolder + "].");
|
||||||
|
|
||||||
// do some checking before we place the piecen
|
// do some checking before we place the piecen
|
||||||
} else if (pcount >= PIECENS_PER_PLAYER) {
|
} else if (pcount >= PIECENS_PER_PLAYER) {
|
||||||
@@ -683,7 +696,7 @@ public class VenisonManager extends GameManager
|
|||||||
// and add the piecen to the game object. when we receive
|
// and add the piecen to the game object. when we receive
|
||||||
// the piecen added event, we'll score it and then end the
|
// the piecen added event, we'll score it and then end the
|
||||||
// turn
|
// turn
|
||||||
_venobj.addToPiecens(piecen);
|
_atlobj.addToPiecens(piecen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +710,7 @@ public class VenisonManager extends GameManager
|
|||||||
if (_playerOids[pidx] != event.getSourceOid()) {
|
if (_playerOids[pidx] != event.getSourceOid()) {
|
||||||
Log.warning("Requested to place nothing by non-turn holder " +
|
Log.warning("Requested to place nothing by non-turn holder " +
|
||||||
"[event=" + event +
|
"[event=" + event +
|
||||||
", turnHolder=" + _venobj.turnHolder + "].");
|
", turnHolder=" + _atlobj.turnHolder + "].");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// player doesn't want to place anything, so we just end
|
// player doesn't want to place anything, so we just end
|
||||||
@@ -734,10 +747,10 @@ public class VenisonManager extends GameManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Our turn game delegate. */
|
/** Our turn game delegate. */
|
||||||
protected VenisonManagerDelegate _delegate;
|
protected AtlantiManagerDelegate _delegate;
|
||||||
|
|
||||||
/** A casted reference to our Venison game object. */
|
/** A casted reference to our Atlanti game object. */
|
||||||
protected VenisonObject _venobj;
|
protected AtlantiObject _atlobj;
|
||||||
|
|
||||||
/** The (shuffled) list of tiles remaining to be played in this
|
/** The (shuffled) list of tiles remaining to be played in this
|
||||||
* game. */
|
* game. */
|
||||||
|
|||||||
+10
-8
@@ -1,23 +1,25 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiManagerDelegate.java,v 1.1 2002/05/21 04:45:10 mdb Exp $
|
// $Id: AtlantiManagerDelegate.java,v 1.2 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.server;
|
||||||
|
|
||||||
import com.threerings.parlor.turn.TurnGameManagerDelegate;
|
import com.threerings.parlor.turn.TurnGameManagerDelegate;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.data.AtlantiCodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the turn-based gameplay.
|
* Handles the turn-based gameplay.
|
||||||
*/
|
*/
|
||||||
public class VenisonManagerDelegate extends TurnGameManagerDelegate
|
public class AtlantiManagerDelegate extends TurnGameManagerDelegate
|
||||||
implements VenisonCodes
|
implements AtlantiCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs the delegate and prepares it for operation.
|
* Constructs the delegate and prepares it for operation.
|
||||||
*/
|
*/
|
||||||
public VenisonManagerDelegate (VenisonManager vmgr)
|
public AtlantiManagerDelegate (AtlantiManager vmgr)
|
||||||
{
|
{
|
||||||
super(vmgr);
|
super(vmgr);
|
||||||
_vmgr = vmgr;
|
_amgr = vmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +28,7 @@ public class VenisonManagerDelegate extends TurnGameManagerDelegate
|
|||||||
protected void setNextTurnHolder ()
|
protected void setNextTurnHolder ()
|
||||||
{
|
{
|
||||||
// if we have tiles left, we move to the next player as normal
|
// if we have tiles left, we move to the next player as normal
|
||||||
if (_vmgr.getTilesInBox() > 0) {
|
if (_amgr.getTilesInBox() > 0) {
|
||||||
super.setNextTurnHolder();
|
super.setNextTurnHolder();
|
||||||
} else {
|
} else {
|
||||||
// if we don't, we ensure that a new turn isn't started by
|
// if we don't, we ensure that a new turn isn't started by
|
||||||
@@ -36,5 +38,5 @@ public class VenisonManagerDelegate extends TurnGameManagerDelegate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The manager for whom we're delegating. */
|
/** The manager for whom we're delegating. */
|
||||||
protected VenisonManager _vmgr;
|
protected AtlantiManager _amgr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
//
|
//
|
||||||
// $Id: FeatureUtil.java,v 1.5 2001/12/18 11:58:53 mdb Exp $
|
// $Id: FeatureUtil.java,v 1.6 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.util;
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.data.Feature;
|
||||||
|
import com.samskivert.atlanti.data.TileCodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feature related constants and utility functions.
|
* Feature related constants and utility functions.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: PiecenUtil.java,v 1.2 2002/05/21 04:45:09 mdb Exp $
|
// $Id: PiecenUtil.java,v 1.3 2002/12/12 05:51:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.util;
|
||||||
|
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileUtil.java,v 1.16 2002/05/21 04:45:09 mdb Exp $
|
// $Id: TileUtil.java,v 1.17 2002/12/12 05:51:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.samskivert.atlanti.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -12,8 +12,14 @@ import com.samskivert.util.IntTuple;
|
|||||||
|
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
|
|
||||||
|
import com.samskivert.atlanti.Log;
|
||||||
|
import com.samskivert.atlanti.data.AtlantiTile;
|
||||||
|
import com.samskivert.atlanti.data.Feature;
|
||||||
|
import com.samskivert.atlanti.data.Piecen;
|
||||||
|
import com.samskivert.atlanti.data.TileCodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility functions relating to the Venison tiles.
|
* Utility functions relating to the Atlantissonne tiles.
|
||||||
*/
|
*/
|
||||||
public class TileUtil implements TileCodes
|
public class TileUtil implements TileCodes
|
||||||
{
|
{
|
||||||
@@ -21,15 +27,15 @@ public class TileUtil implements TileCodes
|
|||||||
* Returns an instance of the starting tile (properly cloned so that
|
* Returns an instance of the starting tile (properly cloned so that
|
||||||
* it can be messed with by the server).
|
* it can be messed with by the server).
|
||||||
*/
|
*/
|
||||||
public static VenisonTile getStartingTile ()
|
public static AtlantiTile getStartingTile ()
|
||||||
{
|
{
|
||||||
return (VenisonTile)VenisonTile.STARTING_TILE.clone();
|
return (AtlantiTile)AtlantiTile.STARTING_TILE.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list containing the standard tile set for the Venison
|
* Returns a list containing the standard tile set for the
|
||||||
* game. The list is a clone, so it can be bent, folded and modified
|
* Atlantissonne game. The list is a clone, so it can be bent, folded
|
||||||
* by the caller.
|
* and modified by the caller.
|
||||||
*/
|
*/
|
||||||
public static List getStandardTileSet ()
|
public static List getStandardTileSet ()
|
||||||
{
|
{
|
||||||
@@ -38,7 +44,7 @@ public class TileUtil implements TileCodes
|
|||||||
List tiles = new ArrayList();
|
List tiles = new ArrayList();
|
||||||
int tsize = TILE_SET.size();
|
int tsize = TILE_SET.size();
|
||||||
for (int i = 0; i < tsize; i++) {
|
for (int i = 0; i < tsize; i++) {
|
||||||
tiles.add(((VenisonTile)TILE_SET.get(i)).clone());
|
tiles.add(((AtlantiTile)TILE_SET.get(i)).clone());
|
||||||
}
|
}
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
@@ -60,7 +66,7 @@ public class TileUtil implements TileCodes
|
|||||||
* up with the direction constants specified in {@link TileCodes}.
|
* up with the direction constants specified in {@link TileCodes}.
|
||||||
*/
|
*/
|
||||||
public static boolean[] computeValidOrients (
|
public static boolean[] computeValidOrients (
|
||||||
List tiles, VenisonTile target)
|
List tiles, AtlantiTile target)
|
||||||
{
|
{
|
||||||
// this contains a count of tiles that match up with the candidate
|
// this contains a count of tiles that match up with the candidate
|
||||||
// tile in each of its four orientations
|
// tile in each of its four orientations
|
||||||
@@ -68,7 +74,7 @@ public class TileUtil implements TileCodes
|
|||||||
|
|
||||||
int tsize = tiles.size();
|
int tsize = tiles.size();
|
||||||
for (int i = 0; i < tsize; i++) {
|
for (int i = 0; i < tsize; i++) {
|
||||||
VenisonTile tile = (VenisonTile)tiles.get(i);
|
AtlantiTile tile = (AtlantiTile)tiles.get(i);
|
||||||
|
|
||||||
// figure out where this tile is in relation to the candidate
|
// figure out where this tile is in relation to the candidate
|
||||||
int xdiff = tile.x - target.x;
|
int xdiff = tile.x - target.x;
|
||||||
@@ -132,13 +138,13 @@ public class TileUtil implements TileCodes
|
|||||||
* @return true if the target tile is configured with a valid position
|
* @return true if the target tile is configured with a valid position
|
||||||
* and orientation, false if it is not.
|
* and orientation, false if it is not.
|
||||||
*/
|
*/
|
||||||
public static boolean isValidPlacement (List tiles, VenisonTile target)
|
public static boolean isValidPlacement (List tiles, AtlantiTile target)
|
||||||
{
|
{
|
||||||
boolean matchedAnEdge = false;
|
boolean matchedAnEdge = false;
|
||||||
|
|
||||||
int tsize = tiles.size();
|
int tsize = tiles.size();
|
||||||
for (int i = 0; i < tsize; i++) {
|
for (int i = 0; i < tsize; i++) {
|
||||||
VenisonTile tile = (VenisonTile)tiles.get(i);
|
AtlantiTile tile = (AtlantiTile)tiles.get(i);
|
||||||
|
|
||||||
// figure out where this tile is in relation to the candidate
|
// figure out where this tile is in relation to the candidate
|
||||||
int xdiff = tile.x - target.x;
|
int xdiff = tile.x - target.x;
|
||||||
@@ -203,7 +209,7 @@ public class TileUtil implements TileCodes
|
|||||||
* not include the tile whose features are being configured).
|
* not include the tile whose features are being configured).
|
||||||
* @param tile the tile whose features should be configured.
|
* @param tile the tile whose features should be configured.
|
||||||
*/
|
*/
|
||||||
public static void inheritClaims (List tiles, VenisonTile tile)
|
public static void inheritClaims (List tiles, AtlantiTile tile)
|
||||||
{
|
{
|
||||||
List flist = new ArrayList();
|
List flist = new ArrayList();
|
||||||
|
|
||||||
@@ -263,7 +269,7 @@ public class TileUtil implements TileCodes
|
|||||||
* @param claimGroup the claim group value to set.
|
* @param claimGroup the claim group value to set.
|
||||||
*/
|
*/
|
||||||
public static void setClaimGroup (
|
public static void setClaimGroup (
|
||||||
List tiles, VenisonTile tile, int featureIndex, int claimGroup)
|
List tiles, AtlantiTile tile, int featureIndex, int claimGroup)
|
||||||
{
|
{
|
||||||
// load up this feature group
|
// load up this feature group
|
||||||
List flist = new ArrayList();
|
List flist = new ArrayList();
|
||||||
@@ -291,7 +297,7 @@ public class TileUtil implements TileCodes
|
|||||||
* score for a partial feature group.
|
* score for a partial feature group.
|
||||||
*/
|
*/
|
||||||
public static int computeFeatureScore (
|
public static int computeFeatureScore (
|
||||||
List tiles, VenisonTile tile, int featureIndex)
|
List tiles, AtlantiTile tile, int featureIndex)
|
||||||
{
|
{
|
||||||
Feature feature = tile.features[featureIndex];
|
Feature feature = tile.features[featureIndex];
|
||||||
|
|
||||||
@@ -316,7 +322,7 @@ public class TileUtil implements TileCodes
|
|||||||
|
|
||||||
// now iterate over the list, counting only unique tiles
|
// now iterate over the list, counting only unique tiles
|
||||||
int score = 0;
|
int score = 0;
|
||||||
VenisonTile lastTile = null;
|
AtlantiTile lastTile = null;
|
||||||
int fsize = flist.size();
|
int fsize = flist.size();
|
||||||
for (int i = 0; i < fsize; i++) {
|
for (int i = 0; i < fsize; i++) {
|
||||||
TileFeature feat = (TileFeature)flist.get(i);
|
TileFeature feat = (TileFeature)flist.get(i);
|
||||||
@@ -347,9 +353,9 @@ public class TileUtil implements TileCodes
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper function for {@link
|
* A helper function for {@link
|
||||||
* #computeFeatureScore(List,VenisonTile,int)}.
|
* #computeFeatureScore(List,AtlantiTile,int)}.
|
||||||
*/
|
*/
|
||||||
protected static int computeCloisterScore (List tiles, VenisonTile tile)
|
protected static int computeCloisterScore (List tiles, AtlantiTile tile)
|
||||||
{
|
{
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
@@ -381,7 +387,7 @@ public class TileUtil implements TileCodes
|
|||||||
// iterate over the tiles, marking every city completed or not
|
// iterate over the tiles, marking every city completed or not
|
||||||
int tsize = tiles.size();
|
int tsize = tiles.size();
|
||||||
for (int i = 0; i < tsize; i++) {
|
for (int i = 0; i < tsize; i++) {
|
||||||
VenisonTile tile = (VenisonTile)tiles.get(i);
|
AtlantiTile tile = (AtlantiTile)tiles.get(i);
|
||||||
|
|
||||||
// iterate over each feature on this tile
|
// iterate over each feature on this tile
|
||||||
for (int f = 0; f < tile.features.length; f++) {
|
for (int f = 0; f < tile.features.length; f++) {
|
||||||
@@ -448,7 +454,7 @@ public class TileUtil implements TileCodes
|
|||||||
* features), false if it is not.
|
* features), false if it is not.
|
||||||
*/
|
*/
|
||||||
protected static boolean enumerateGroup (
|
protected static boolean enumerateGroup (
|
||||||
List tiles, VenisonTile tile, int featureIndex, List group)
|
List tiles, AtlantiTile tile, int featureIndex, List group)
|
||||||
{
|
{
|
||||||
// create a tilefeature for this feature
|
// create a tilefeature for this feature
|
||||||
TileFeature feat = new TileFeature(tile, featureIndex);
|
TileFeature feat = new TileFeature(tile, featureIndex);
|
||||||
@@ -477,7 +483,7 @@ public class TileUtil implements TileCodes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// look up our neighbor
|
// look up our neighbor
|
||||||
VenisonTile neighbor = null;
|
AtlantiTile neighbor = null;
|
||||||
int dir = FeatureUtil.ADJACENCY_MAP[c+1];
|
int dir = FeatureUtil.ADJACENCY_MAP[c+1];
|
||||||
dir = (dir + tile.orientation) % 4;
|
dir = (dir + tile.orientation) % 4;
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
@@ -530,11 +536,11 @@ public class TileUtil implements TileCodes
|
|||||||
* @return the tile with the requested coordinates or null if no tile
|
* @return the tile with the requested coordinates or null if no tile
|
||||||
* exists at those coordinates.
|
* exists at those coordinates.
|
||||||
*/
|
*/
|
||||||
protected static VenisonTile findTile (List tiles, int x, int y)
|
public static AtlantiTile findTile (List tiles, int x, int y)
|
||||||
{
|
{
|
||||||
IntTuple coord = new IntTuple(x, y);
|
IntTuple coord = new IntTuple(x, y);
|
||||||
int tidx = Collections.binarySearch(tiles, coord);
|
int tidx = Collections.binarySearch(tiles, coord);
|
||||||
return (tidx >= 0) ? (VenisonTile)tiles.get(tidx) : null;
|
return (tidx >= 0) ? (AtlantiTile)tiles.get(tidx) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -551,7 +557,7 @@ public class TileUtil implements TileCodes
|
|||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
VenisonTile tile = (VenisonTile)tiles.get(i);
|
AtlantiTile tile = (AtlantiTile)tiles.get(i);
|
||||||
if (tile.piecen != null &&
|
if (tile.piecen != null &&
|
||||||
tile.piecen.owner == playerIndex) {
|
tile.piecen.owner == playerIndex) {
|
||||||
count++;
|
count++;
|
||||||
@@ -604,7 +610,7 @@ public class TileUtil implements TileCodes
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Used to generate our standard tile set. */
|
/** Used to generate our standard tile set. */
|
||||||
protected static void addTiles (int count, List list, VenisonTile tile)
|
protected static void addTiles (int count, List list, AtlantiTile tile)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
list.add(tile);
|
list.add(tile);
|
||||||
@@ -615,13 +621,13 @@ public class TileUtil implements TileCodes
|
|||||||
protected static final class TileFeature implements Comparable
|
protected static final class TileFeature implements Comparable
|
||||||
{
|
{
|
||||||
/** The tile that contains the feature. */
|
/** The tile that contains the feature. */
|
||||||
public VenisonTile tile;
|
public AtlantiTile tile;
|
||||||
|
|
||||||
/** The index of the feature in the tile. */
|
/** The index of the feature in the tile. */
|
||||||
public int featureIndex;
|
public int featureIndex;
|
||||||
|
|
||||||
/** Constructs a new tile feature. */
|
/** Constructs a new tile feature. */
|
||||||
public TileFeature (VenisonTile tile, int featureIndex)
|
public TileFeature (AtlantiTile tile, int featureIndex)
|
||||||
{
|
{
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
this.featureIndex = featureIndex;
|
this.featureIndex = featureIndex;
|
||||||
@@ -689,40 +695,40 @@ public class TileUtil implements TileCodes
|
|||||||
GRASS, GRASS, ROAD, ROAD, // CURVED_ROAD
|
GRASS, GRASS, ROAD, ROAD, // CURVED_ROAD
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The standard tile set for a game of Venison. */
|
/** The standard tile set for a game of Atlantissonne. */
|
||||||
protected static ArrayList TILE_SET = new ArrayList();
|
protected static ArrayList TILE_SET = new ArrayList();
|
||||||
|
|
||||||
// create our standard tile set
|
// create our standard tile set
|
||||||
static {
|
static {
|
||||||
addTiles(1, TILE_SET, new VenisonTile(CITY_FOUR, true));
|
addTiles(1, TILE_SET, new AtlantiTile(CITY_FOUR, true));
|
||||||
|
|
||||||
addTiles(3, TILE_SET, new VenisonTile(CITY_THREE, false));
|
addTiles(3, TILE_SET, new AtlantiTile(CITY_THREE, false));
|
||||||
addTiles(1, TILE_SET, new VenisonTile(CITY_THREE, true));
|
addTiles(1, TILE_SET, new AtlantiTile(CITY_THREE, true));
|
||||||
addTiles(1, TILE_SET, new VenisonTile(CITY_THREE_ROAD, false));
|
addTiles(1, TILE_SET, new AtlantiTile(CITY_THREE_ROAD, false));
|
||||||
addTiles(2, TILE_SET, new VenisonTile(CITY_THREE_ROAD, true));
|
addTiles(2, TILE_SET, new AtlantiTile(CITY_THREE_ROAD, true));
|
||||||
|
|
||||||
addTiles(3, TILE_SET, new VenisonTile(CITY_TWO, false));
|
addTiles(3, TILE_SET, new AtlantiTile(CITY_TWO, false));
|
||||||
addTiles(2, TILE_SET, new VenisonTile(CITY_TWO, true));
|
addTiles(2, TILE_SET, new AtlantiTile(CITY_TWO, true));
|
||||||
addTiles(3, TILE_SET, new VenisonTile(CITY_TWO_ROAD, false));
|
addTiles(3, TILE_SET, new AtlantiTile(CITY_TWO_ROAD, false));
|
||||||
addTiles(2, TILE_SET, new VenisonTile(CITY_TWO_ROAD, true));
|
addTiles(2, TILE_SET, new AtlantiTile(CITY_TWO_ROAD, true));
|
||||||
addTiles(1, TILE_SET, new VenisonTile(CITY_TWO_ACROSS, false));
|
addTiles(1, TILE_SET, new AtlantiTile(CITY_TWO_ACROSS, false));
|
||||||
addTiles(2, TILE_SET, new VenisonTile(CITY_TWO_ACROSS, true));
|
addTiles(2, TILE_SET, new AtlantiTile(CITY_TWO_ACROSS, true));
|
||||||
|
|
||||||
addTiles(2, TILE_SET, new VenisonTile(TWO_CITY_TWO, false));
|
addTiles(2, TILE_SET, new AtlantiTile(TWO_CITY_TWO, false));
|
||||||
addTiles(3, TILE_SET, new VenisonTile(TWO_CITY_TWO_ACROSS, false));
|
addTiles(3, TILE_SET, new AtlantiTile(TWO_CITY_TWO_ACROSS, false));
|
||||||
|
|
||||||
addTiles(5, TILE_SET, new VenisonTile(CITY_ONE, false));
|
addTiles(5, TILE_SET, new AtlantiTile(CITY_ONE, false));
|
||||||
addTiles(3, TILE_SET, new VenisonTile(CITY_ONE_ROAD_RIGHT, false));
|
addTiles(3, TILE_SET, new AtlantiTile(CITY_ONE_ROAD_RIGHT, false));
|
||||||
addTiles(3, TILE_SET, new VenisonTile(CITY_ONE_ROAD_LEFT, false));
|
addTiles(3, TILE_SET, new AtlantiTile(CITY_ONE_ROAD_LEFT, false));
|
||||||
addTiles(3, TILE_SET, new VenisonTile(CITY_ONE_ROAD_TEE, false));
|
addTiles(3, TILE_SET, new AtlantiTile(CITY_ONE_ROAD_TEE, false));
|
||||||
addTiles(3, TILE_SET, new VenisonTile(CITY_ONE_ROAD_STRAIGHT, false));
|
addTiles(3, TILE_SET, new AtlantiTile(CITY_ONE_ROAD_STRAIGHT, false));
|
||||||
|
|
||||||
addTiles(4, TILE_SET, new VenisonTile(CLOISTER_PLAIN, false));
|
addTiles(4, TILE_SET, new AtlantiTile(CLOISTER_PLAIN, false));
|
||||||
addTiles(2, TILE_SET, new VenisonTile(CLOISTER_ROAD, false));
|
addTiles(2, TILE_SET, new AtlantiTile(CLOISTER_ROAD, false));
|
||||||
|
|
||||||
addTiles(1, TILE_SET, new VenisonTile(FOUR_WAY_ROAD, false));
|
addTiles(1, TILE_SET, new AtlantiTile(FOUR_WAY_ROAD, false));
|
||||||
addTiles(4, TILE_SET, new VenisonTile(THREE_WAY_ROAD, false));
|
addTiles(4, TILE_SET, new AtlantiTile(THREE_WAY_ROAD, false));
|
||||||
addTiles(8, TILE_SET, new VenisonTile(STRAIGHT_ROAD, false));
|
addTiles(8, TILE_SET, new AtlantiTile(STRAIGHT_ROAD, false));
|
||||||
addTiles(9, TILE_SET, new VenisonTile(CURVED_ROAD, false));
|
addTiles(9, TILE_SET, new AtlantiTile(CURVED_ROAD, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user