Numerous changes to bring things back into sync with the modern Narya
state of affairs. git-svn-id: https://samskivert.googlecode.com/svn/trunk@754 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,12 +1,8 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
#
|
|
||||||
# $Id: runjava,v 1.1 2001/10/09 20:27:35 mdb Exp $
|
|
||||||
#
|
|
||||||
# Invokes java with the necessary classpath and parameters.
|
|
||||||
|
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
|
|
||||||
my $usage = "Usage: $0 [-p pid_file] [-r server_root] args\n";
|
my $usage = "Usage: $0 [-p pid_file] [-r root_directory] args\n";
|
||||||
|
|
||||||
# locations of stuff
|
# locations of stuff
|
||||||
chomp($location = `dirname $0`);
|
chomp($location = `dirname $0`);
|
||||||
@@ -16,8 +12,9 @@ chomp($location = `dirname $0`);
|
|||||||
pop(@parts);
|
pop(@parts);
|
||||||
my $root = join("/", @parts);
|
my $root = join("/", @parts);
|
||||||
|
|
||||||
# make sure JAVA_HOME is set
|
|
||||||
my $jhome = $ENV{"JAVA_HOME"};
|
my $jhome = $ENV{"JAVA_HOME"};
|
||||||
|
|
||||||
|
# make sure JAVA_HOME is set
|
||||||
if (!defined $jhome) {
|
if (!defined $jhome) {
|
||||||
warn "$0: Error: No JAVA_HOME specified!\n";
|
warn "$0: Error: No JAVA_HOME specified!\n";
|
||||||
warn "\n";
|
warn "\n";
|
||||||
@@ -55,22 +52,32 @@ if (defined $libpath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# put everything in our class path
|
# put everything in our class path
|
||||||
my $classpath = "-classpath $jlib:$root/dist/classes";
|
my $classpath = "-classpath $root/dist/classes";
|
||||||
|
|
||||||
# any zip or jar files in our lib/ directory get added to the class path
|
# add zip and jar files from our lib/ directory and the system lib/ directory
|
||||||
if (opendir(DIR, "$root/lib")) {
|
my @dirs = ( "$root/lib", $ENV{"JAVA_LIBS"} );
|
||||||
foreach $lib (grep { /.(zip|jar)/ && -f "$root/lib/$_" } readdir(DIR)) {
|
foreach $dir (@dirs) {
|
||||||
$classpath .= ":$root/lib/$lib";
|
next unless (defined $dir);
|
||||||
|
if (opendir(DIR, $dir)) {
|
||||||
|
foreach $lib (grep { /.(zip|jar)/ && -f "$dir/$_" } readdir(DIR)) {
|
||||||
|
$classpath .= ":$dir/$lib";
|
||||||
|
}
|
||||||
|
closedir DIR;
|
||||||
}
|
}
|
||||||
closedir DIR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# finally add the standard classes
|
||||||
|
$classpath = "$classpath:$jlib";
|
||||||
|
|
||||||
|
# specify our application root (the resource manager needs this)
|
||||||
|
my $rootarg = "-Dresource_url=file:$root/rsrc";
|
||||||
|
|
||||||
my $pid_file = undef;
|
my $pid_file = undef;
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
|
|
||||||
# strip out the args (we'd use getopt() but the damned thing provides no
|
# strip out the -p and -r args (we'd use getopt() but the damned thing
|
||||||
# way of escaping arguments so that we can pass args to runjava that get
|
# provides no way of escaping arguments so that we can pass args to
|
||||||
# passed down to the JVM)
|
# runjava that get passed down to the JVM)
|
||||||
for ($i = 0; $i < @ARGV; $i++) {
|
for ($i = 0; $i < @ARGV; $i++) {
|
||||||
my $arg = $ARGV[$i];
|
my $arg = $ARGV[$i];
|
||||||
|
|
||||||
@@ -84,12 +91,17 @@ for ($i = 0; $i < @ARGV; $i++) {
|
|||||||
$pid_file = $ARGV[$i+1];
|
$pid_file = $ARGV[$i+1];
|
||||||
splice(@ARGV, $i, 2);
|
splice(@ARGV, $i, 2);
|
||||||
$i -= 1; # decrement i so that things stay in sync
|
$i -= 1; # decrement i so that things stay in sync
|
||||||
|
|
||||||
|
} elsif ($arg eq "-r") {
|
||||||
|
$rootarg = "-DDapplication.root=" . $ARGV[$i+1];
|
||||||
|
splice(@ARGV, $i, 2);
|
||||||
|
$i -= 1; # decrement i so that things stay in sync
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# log the pid file if requested to do so
|
# log the pid file if requested to do so
|
||||||
print `echo $$ > $pid_file` if (defined $pid_file);
|
print `echo $$ > $pid_file` if (defined $pid_file);
|
||||||
|
|
||||||
my $cmd = "$java $classpath " . join(" ", @ARGV);
|
my $cmd = "$java -mx256M $classpath $rootarg " . join(" ", @ARGV);
|
||||||
# print "$cmd\n";
|
# print "$cmd\n";
|
||||||
exec($cmd);
|
exec($cmd);
|
||||||
|
|||||||
@@ -8,12 +8,14 @@
|
|||||||
<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"/>
|
||||||
|
<property name="narya.home" value="../../work/narya"/>
|
||||||
|
|
||||||
<!-- things you probably don't want to change -->
|
<!-- things you probably don't want to change -->
|
||||||
<property name="src.dir" value="src/java"/>
|
<property name="src.dir" value="src/java"/>
|
||||||
<property name="deploy.dir" value="dist"/>
|
<property name="deploy.dir" value="dist"/>
|
||||||
<property name="dist.jar" value="${app.name}.jar"/>
|
<property name="dist.jar" value="${app.name}.jar"/>
|
||||||
<property name="javadoc.dir" value="${deploy.dir}/docs"/>
|
<property name="javadoc.dir" value="${deploy.dir}/docs"/>
|
||||||
|
<property name="gendobj.path" value="${narya.home}/bin/gendobj"/>
|
||||||
|
|
||||||
<!-- declare our classpath -->
|
<!-- declare our classpath -->
|
||||||
<path id="classpath">
|
<path id="classpath">
|
||||||
@@ -22,8 +24,16 @@
|
|||||||
<pathelement location="${deploy.dir}/classes"/>
|
<pathelement location="${deploy.dir}/classes"/>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
|
<!-- generates .java files for all .dobj files -->
|
||||||
|
<target name="gendobj">
|
||||||
|
<apply executable="${gendobj.path}" failonerror="true">
|
||||||
|
<srcfile/>
|
||||||
|
<fileset dir="src/java" includes="**/*.dobj"/>
|
||||||
|
</apply>
|
||||||
|
</target>
|
||||||
|
|
||||||
<!-- prepares the application directories -->
|
<!-- prepares the application directories -->
|
||||||
<target name="prepare">
|
<target name="prepare" depends="gendobj">
|
||||||
<mkdir dir="${deploy.dir}"/>
|
<mkdir dir="${deploy.dir}"/>
|
||||||
<mkdir dir="${deploy.dir}/classes"/>
|
<mkdir dir="${deploy.dir}/classes"/>
|
||||||
<mkdir dir="${deploy.dir}/classes/rsrc"/>
|
<mkdir dir="${deploy.dir}/classes/rsrc"/>
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#
|
||||||
|
# $Id: atlanti.properties,v 1.1 2002/05/21 04:45:09 mdb Exp $
|
||||||
|
#
|
||||||
|
# Translation messages
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiBoard.java,v 1.16 2001/11/24 08:25:04 shaper Exp $
|
// $Id: AtlantiBoard.java,v 1.17 2002/05/21 04:45:10 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class VenisonBoard
|
|||||||
_tiles.clear();
|
_tiles.clear();
|
||||||
|
|
||||||
// copy the tiles from the set into our local list
|
// copy the tiles from the set into our local list
|
||||||
CollectionUtil.addAll(_tiles, tset.elements());
|
CollectionUtil.addAll(_tiles, tset.entries());
|
||||||
|
|
||||||
// sort the list
|
// sort the list
|
||||||
Collections.sort(_tiles);
|
Collections.sort(_tiles);
|
||||||
@@ -84,7 +84,7 @@ public class VenisonBoard
|
|||||||
public void setPiecens (DSet piecens)
|
public void setPiecens (DSet piecens)
|
||||||
{
|
{
|
||||||
// just iterate over the set placing each of the piecens in turn
|
// just iterate over the set placing each of the piecens in turn
|
||||||
Iterator iter = piecens.elements();
|
Iterator iter = piecens.entries();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
placePiecen((Piecen)iter.next());
|
placePiecen((Piecen)iter.next());
|
||||||
}
|
}
|
||||||
@@ -616,7 +616,7 @@ public class VenisonBoard
|
|||||||
|
|
||||||
// set a feature group to test propagation
|
// set a feature group to test propagation
|
||||||
List tiles = new ArrayList();
|
List tiles = new ArrayList();
|
||||||
CollectionUtil.addAll(tiles, set.elements());
|
CollectionUtil.addAll(tiles, set.entries());
|
||||||
Collections.sort(tiles);
|
Collections.sort(tiles);
|
||||||
|
|
||||||
zero.setPiecen(new Piecen(Piecen.GREEN, 0, 0, 2), tiles);
|
zero.setPiecen(new Piecen(Piecen.GREEN, 0, 0, 2), tiles);
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import com.samskivert.util.ListUtil;
|
|||||||
|
|
||||||
import com.threerings.presents.dobj.AttributeChangedEvent;
|
import com.threerings.presents.dobj.AttributeChangedEvent;
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
import com.threerings.presents.dobj.ElementAddedEvent;
|
import com.threerings.presents.dobj.EntryAddedEvent;
|
||||||
import com.threerings.presents.dobj.ElementRemovedEvent;
|
import com.threerings.presents.dobj.EntryRemovedEvent;
|
||||||
import com.threerings.presents.dobj.ElementUpdatedEvent;
|
import com.threerings.presents.dobj.EntryUpdatedEvent;
|
||||||
import com.threerings.presents.dobj.MessageEvent;
|
import com.threerings.presents.dobj.MessageEvent;
|
||||||
import com.threerings.presents.dobj.SetListener;
|
import com.threerings.presents.dobj.SetListener;
|
||||||
|
|
||||||
@@ -18,18 +18,30 @@ import com.threerings.crowd.data.BodyObject;
|
|||||||
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.threerings.parlor.game.GameController;
|
||||||
import com.threerings.parlor.turn.TurnGameController;
|
import com.threerings.parlor.turn.TurnGameController;
|
||||||
|
import com.threerings.parlor.turn.TurnGameControllerDelegate;
|
||||||
import com.threerings.parlor.util.ParlorContext;
|
import com.threerings.parlor.util.ParlorContext;
|
||||||
|
|
||||||
|
import com.threerings.micasa.util.MiCasaContext;
|
||||||
|
|
||||||
import com.threerings.venison.Log;
|
import com.threerings.venison.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 Venison game.
|
||||||
*/
|
*/
|
||||||
public class VenisonController
|
public class VenisonController extends GameController
|
||||||
extends TurnGameController implements VenisonCodes, SetListener
|
implements TurnGameController, VenisonCodes, SetListener
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Creates our controller and prepares it for operation.
|
||||||
|
*/
|
||||||
|
public VenisonController ()
|
||||||
|
{
|
||||||
|
addDelegate(_delegate = new TurnGameControllerDelegate(this));
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected void didInit ()
|
protected void didInit ()
|
||||||
{
|
{
|
||||||
@@ -42,7 +54,7 @@ public class VenisonController
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected PlaceView createPlaceView ()
|
protected PlaceView createPlaceView ()
|
||||||
{
|
{
|
||||||
_panel = new VenisonPanel(_ctx, this);
|
_panel = new VenisonPanel((MiCasaContext)_ctx, this);
|
||||||
return _panel;
|
return _panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,16 +79,14 @@ public class VenisonController
|
|||||||
_panel.board.setPiecens(_venobj.piecens);
|
_panel.board.setPiecens(_venobj.piecens);
|
||||||
|
|
||||||
// if it's our turn, set the tile to be placed
|
// if it's our turn, set the tile to be placed
|
||||||
if (isOurTurn()) {
|
if (_delegate.isOurTurn()) {
|
||||||
_panel.board.setTileToBePlaced(_venobj.currentTile);
|
_panel.board.setTileToBePlaced(_venobj.currentTile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected void turnDidChange (String turnHolder)
|
public void turnDidChange (String turnHolder)
|
||||||
{
|
{
|
||||||
super.turnDidChange(turnHolder);
|
|
||||||
|
|
||||||
// if it's our turn, set the tile to be placed
|
// if it's our turn, set the tile to be placed
|
||||||
if (turnHolder.equals(_self.username)) {
|
if (turnHolder.equals(_self.username)) {
|
||||||
_panel.board.setTileToBePlaced(_venobj.currentTile);
|
_panel.board.setTileToBePlaced(_venobj.currentTile);
|
||||||
@@ -98,28 +108,28 @@ public class VenisonController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementAdded (ElementAddedEvent 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(VenisonObject.TILES)) {
|
||||||
// a tile was added, add it to the board
|
// a tile was added, add it to the board
|
||||||
VenisonTile tile = (VenisonTile)event.getElement();
|
VenisonTile tile = (VenisonTile)event.getEntry();
|
||||||
_panel.board.addTile(tile);
|
_panel.board.addTile(tile);
|
||||||
|
|
||||||
} else if (event.getName().equals(VenisonObject.PIECENS)) {
|
} else if (event.getName().equals(VenisonObject.PIECENS)) {
|
||||||
// a piecen was added, place it on the board
|
// a piecen was added, place it on the board
|
||||||
Piecen piecen = (Piecen)event.getElement();
|
Piecen piecen = (Piecen)event.getEntry();
|
||||||
_panel.board.placePiecen(piecen);
|
_panel.board.placePiecen(piecen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementUpdated (ElementUpdatedEvent event)
|
public void entryUpdated (EntryUpdatedEvent event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementRemoved (ElementRemovedEvent event)
|
public void entryRemoved (EntryRemovedEvent event)
|
||||||
{
|
{
|
||||||
if (event.getName().equals(VenisonObject.PIECENS)) {
|
if (event.getName().equals(VenisonObject.PIECENS)) {
|
||||||
// a piecen was removed, update the board
|
// a piecen was removed, update the board
|
||||||
@@ -190,6 +200,9 @@ public class VenisonController
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Our turn game delegate. */
|
||||||
|
protected TurnGameControllerDelegate _delegate;
|
||||||
|
|
||||||
/** A reference to our game panel. */
|
/** A reference to our game panel. */
|
||||||
protected VenisonPanel _panel;
|
protected VenisonPanel _panel;
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import com.threerings.media.tile.TileManager;
|
|||||||
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.threerings.parlor.util.ParlorContext;
|
|
||||||
import com.threerings.micasa.client.ChatPanel;
|
import com.threerings.micasa.client.ChatPanel;
|
||||||
|
import com.threerings.micasa.util.MiCasaContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The top-level user interface component for the Venison game display.
|
* The top-level user interface component for the Venison game display.
|
||||||
@@ -42,7 +42,7 @@ public class VenisonPanel
|
|||||||
/**
|
/**
|
||||||
* Constructs a new Venison game display.
|
* Constructs a new Venison game display.
|
||||||
*/
|
*/
|
||||||
public VenisonPanel (ParlorContext ctx, VenisonController controller)
|
public VenisonPanel (MiCasaContext ctx, VenisonController 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));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: PlayerInfoView.java,v 1.3 2001/10/18 20:53:53 mdb Exp $
|
// $Id: PlayerInfoView.java,v 1.4 2002/05/21 04:45:09 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -13,9 +13,9 @@ import javax.swing.JPanel;
|
|||||||
import com.threerings.presents.dobj.AttributeChangeListener;
|
import com.threerings.presents.dobj.AttributeChangeListener;
|
||||||
import com.threerings.presents.dobj.AttributeChangedEvent;
|
import com.threerings.presents.dobj.AttributeChangedEvent;
|
||||||
import com.threerings.presents.dobj.SetListener;
|
import com.threerings.presents.dobj.SetListener;
|
||||||
import com.threerings.presents.dobj.ElementAddedEvent;
|
import com.threerings.presents.dobj.EntryAddedEvent;
|
||||||
import com.threerings.presents.dobj.ElementUpdatedEvent;
|
import com.threerings.presents.dobj.EntryUpdatedEvent;
|
||||||
import com.threerings.presents.dobj.ElementRemovedEvent;
|
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;
|
||||||
@@ -115,18 +115,18 @@ public class PlayerInfoView
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementAdded (ElementAddedEvent event)
|
public void entryAdded (EntryAddedEvent event)
|
||||||
{
|
{
|
||||||
updatePiecenCount();
|
updatePiecenCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementUpdated (ElementUpdatedEvent event)
|
public void entryUpdated (EntryUpdatedEvent event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementRemoved (ElementRemovedEvent event)
|
public void entryRemoved (EntryRemovedEvent event)
|
||||||
{
|
{
|
||||||
updatePiecenCount();
|
updatePiecenCount();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiCodes.java,v 1.4 2001/10/24 03:24:20 mdb Exp $
|
// $Id: AtlantiCodes.java,v 1.5 2002/05/21 04:45:10 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -8,6 +8,9 @@ package com.threerings.venison;
|
|||||||
*/
|
*/
|
||||||
public interface VenisonCodes
|
public interface VenisonCodes
|
||||||
{
|
{
|
||||||
|
/** The message bundle identifier for translation messages. */
|
||||||
|
public static final String VENISON_MESSAGE_BUNDLE = "venison";
|
||||||
|
|
||||||
/** 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;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
//
|
||||||
|
// $Id: AtlantiObject.dobj,v 1.1 2002/05/21 04:45:10 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.venison;
|
||||||
|
|
||||||
|
import com.samskivert.util.StringUtil;
|
||||||
|
import com.threerings.presents.dobj.DSet;
|
||||||
|
import com.threerings.parlor.game.GameObject;
|
||||||
|
import com.threerings.parlor.turn.TurnGameObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The distributed object used to maintain state for the Venison game.
|
||||||
|
*/
|
||||||
|
public class VenisonObject extends GameObject
|
||||||
|
implements TurnGameObject
|
||||||
|
{
|
||||||
|
/** The username of the current turn holder. */
|
||||||
|
public String turnHolder;
|
||||||
|
|
||||||
|
/** A set containing all of the tiles that are in play in this
|
||||||
|
* game. */
|
||||||
|
public DSet tiles = new DSet(VenisonTile.class);
|
||||||
|
|
||||||
|
/** The tile being placed by the current turn holder. This value is
|
||||||
|
* only valid while it is someone's turn. */
|
||||||
|
public VenisonTile currentTile = VenisonTile.STARTING_TILE;
|
||||||
|
|
||||||
|
/** A set containing all of the piecens that are placed on the
|
||||||
|
* board. */
|
||||||
|
public DSet piecens = new DSet(Piecen.class);
|
||||||
|
|
||||||
|
/** The scores for each player. */
|
||||||
|
public int[] scores;
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public String getTurnHolderFieldName ()
|
||||||
|
{
|
||||||
|
return TURN_HOLDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public String getTurnHolder ()
|
||||||
|
{
|
||||||
|
return turnHolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,22 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiObject.java,v 1.7 2001/10/17 04:34:14 mdb Exp $
|
// $Id: AtlantiObject.java,v 1.8 2002/05/21 04:45:10 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
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.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 Venison game.
|
||||||
*/
|
*/
|
||||||
public class VenisonObject extends TurnGameObject
|
public class VenisonObject extends GameObject
|
||||||
|
implements TurnGameObject
|
||||||
{
|
{
|
||||||
|
/** The field name of the <code>turnHolder</code> field. */
|
||||||
|
public static final String TURN_HOLDER = "turnHolder";
|
||||||
|
|
||||||
/** The field name of the <code>tiles</code> field. */
|
/** The field name of the <code>tiles</code> field. */
|
||||||
public static final String TILES = "tiles";
|
public static final String TILES = "tiles";
|
||||||
|
|
||||||
@@ -24,6 +29,9 @@ public class VenisonObject extends TurnGameObject
|
|||||||
/** The field name of the <code>scores</code> field. */
|
/** The field name of the <code>scores</code> field. */
|
||||||
public static final String SCORES = "scores";
|
public static final String SCORES = "scores";
|
||||||
|
|
||||||
|
/** The username of the current turn holder. */
|
||||||
|
public String turnHolder;
|
||||||
|
|
||||||
/** 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(VenisonTile.class);
|
||||||
@@ -39,103 +47,163 @@ public class VenisonObject extends TurnGameObject
|
|||||||
/** The scores for each player. */
|
/** The scores for each player. */
|
||||||
public int[] scores;
|
public int[] scores;
|
||||||
|
|
||||||
/**
|
// documentation inherited from interface
|
||||||
* Requests that the <code>tiles</code> field be set to the specified
|
public String getTurnHolderFieldName ()
|
||||||
* value.
|
|
||||||
*/
|
|
||||||
public void setTiles (DSet value)
|
|
||||||
{
|
{
|
||||||
requestAttributeChange(TILES, value);
|
return TURN_HOLDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public String getTurnHolder ()
|
||||||
|
{
|
||||||
|
return turnHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the specified element be added to the
|
* Requests that the <code>turnHolder</code> field be set to the specified
|
||||||
* <code>tiles</code> set.
|
* value. The local value will be updated immediately and an event
|
||||||
|
* will be propagated through the system to notify all listeners that
|
||||||
|
* the attribute did change. Proxied copies of this object (on
|
||||||
|
* clients) will apply the value change when they received the
|
||||||
|
* attribute changed notification.
|
||||||
*/
|
*/
|
||||||
public void addToTiles (DSet.Element elem)
|
public void setTurnHolder (String turnHolder)
|
||||||
{
|
{
|
||||||
requestElementAdd(TILES, elem);
|
this.turnHolder = turnHolder;
|
||||||
|
requestAttributeChange(TURN_HOLDER, turnHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the element matching the supplied key be removed from
|
* Requests that the specified entry be added to the
|
||||||
* the <code>tiles</code> set.
|
* <code>tiles</code> set. The set will not change until the event is
|
||||||
|
* actually propagated through the system.
|
||||||
|
*/
|
||||||
|
public void addToTiles (DSet.Entry elem)
|
||||||
|
{
|
||||||
|
requestEntryAdd(TILES, elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the entry matching the supplied key be removed from
|
||||||
|
* the <code>tiles</code> set. The set will not change until the
|
||||||
|
* event is actually propagated through the system.
|
||||||
*/
|
*/
|
||||||
public void removeFromTiles (Object key)
|
public void removeFromTiles (Object key)
|
||||||
{
|
{
|
||||||
requestElementRemove(TILES, key);
|
requestEntryRemove(TILES, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the specified element be updated in the
|
* Requests that the specified entry be updated in the
|
||||||
* <code>tiles</code> set.
|
* <code>tiles</code> set. The set will not change until the event is
|
||||||
|
* actually propagated through the system.
|
||||||
*/
|
*/
|
||||||
public void updateTiles (DSet.Element elem)
|
public void updateTiles (DSet.Entry elem)
|
||||||
{
|
{
|
||||||
requestElementUpdate(TILES, elem);
|
requestEntryUpdate(TILES, elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the <code>currentTile</code> field be set to the
|
* Requests that the <code>tiles</code> field be set to the
|
||||||
* specified value.
|
* specified value. Generally one only adds, updates and removes
|
||||||
|
* entries of a distributed set, but certain situations call for a
|
||||||
|
* complete replacement of the set value. The local value will be
|
||||||
|
* updated immediately and an event will be propagated through the
|
||||||
|
* system to notify all listeners that the attribute did
|
||||||
|
* change. Proxied copies of this object (on clients) will apply the
|
||||||
|
* value change when they received the attribute changed notification.
|
||||||
*/
|
*/
|
||||||
public void setCurrentTile (VenisonTile value)
|
public void setTiles (DSet tiles)
|
||||||
{
|
{
|
||||||
requestAttributeChange(CURRENT_TILE, value);
|
this.tiles = tiles;
|
||||||
|
requestAttributeChange(TILES, tiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the <code>piecens</code> field be set to the specified
|
* Requests that the <code>currentTile</code> field be set to the specified
|
||||||
* value.
|
* value. The local value will be updated immediately and an event
|
||||||
|
* will be propagated through the system to notify all listeners that
|
||||||
|
* the attribute did change. Proxied copies of this object (on
|
||||||
|
* clients) will apply the value change when they received the
|
||||||
|
* attribute changed notification.
|
||||||
*/
|
*/
|
||||||
public void setPiecens (DSet value)
|
public void setCurrentTile (VenisonTile currentTile)
|
||||||
{
|
{
|
||||||
requestAttributeChange(PIECENS, value);
|
this.currentTile = currentTile;
|
||||||
|
requestAttributeChange(CURRENT_TILE, currentTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the specified element be added to the
|
* Requests that the specified entry be added to the
|
||||||
* <code>piecens</code> set.
|
* <code>piecens</code> set. The set will not change until the event is
|
||||||
|
* actually propagated through the system.
|
||||||
*/
|
*/
|
||||||
public void addToPiecens (DSet.Element elem)
|
public void addToPiecens (DSet.Entry elem)
|
||||||
{
|
{
|
||||||
requestElementAdd(PIECENS, elem);
|
requestEntryAdd(PIECENS, elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the element matching the supplied key be removed from
|
* Requests that the entry matching the supplied key be removed from
|
||||||
* the <code>piecens</code> set.
|
* the <code>piecens</code> set. The set will not change until the
|
||||||
|
* event is actually propagated through the system.
|
||||||
*/
|
*/
|
||||||
public void removeFromPiecens (Object key)
|
public void removeFromPiecens (Object key)
|
||||||
{
|
{
|
||||||
requestElementRemove(PIECENS, key);
|
requestEntryRemove(PIECENS, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the specified element be updated in the
|
* Requests that the specified entry be updated in the
|
||||||
* <code>piecens</code> set.
|
* <code>piecens</code> set. The set will not change until the event is
|
||||||
|
* actually propagated through the system.
|
||||||
*/
|
*/
|
||||||
public void updatePiecens (DSet.Element elem)
|
public void updatePiecens (DSet.Entry elem)
|
||||||
{
|
{
|
||||||
requestElementUpdate(PIECENS, elem);
|
requestEntryUpdate(PIECENS, elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the <code>piecens</code> field be set to the
|
||||||
|
* specified value. Generally one only adds, updates and removes
|
||||||
|
* entries of a distributed set, but certain situations call for a
|
||||||
|
* complete replacement of the set value. The local value will be
|
||||||
|
* updated immediately and an event will be propagated through the
|
||||||
|
* system to notify all listeners that the attribute did
|
||||||
|
* change. Proxied copies of this object (on clients) will apply the
|
||||||
|
* value change when they received the attribute changed notification.
|
||||||
|
*/
|
||||||
|
public void setPiecens (DSet piecens)
|
||||||
|
{
|
||||||
|
this.piecens = piecens;
|
||||||
|
requestAttributeChange(PIECENS, piecens);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the <code>scores</code> field be set to the specified
|
* Requests that the <code>scores</code> field be set to the specified
|
||||||
* value.
|
* value. The local value will be updated immediately and an event
|
||||||
|
* will be propagated through the system to notify all listeners that
|
||||||
|
* the attribute did change. Proxied copies of this object (on
|
||||||
|
* clients) will apply the value change when they received the
|
||||||
|
* attribute changed notification.
|
||||||
*/
|
*/
|
||||||
public void setScores (int[] value)
|
public void setScores (int[] scores)
|
||||||
{
|
{
|
||||||
requestAttributeChange(SCORES, value);
|
this.scores = scores;
|
||||||
|
requestAttributeChange(SCORES, scores);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
/**
|
||||||
protected void toString (StringBuffer buf)
|
* Requests that the <code>index</code>th element of
|
||||||
|
* <code>scores</code> field be set to the specified value. The local
|
||||||
|
* value will be updated immediately and an event will be propagated
|
||||||
|
* through the system to notify all listeners that the attribute did
|
||||||
|
* change. Proxied copies of this object (on clients) will apply the
|
||||||
|
* value change when they received the attribute changed notification.
|
||||||
|
*/
|
||||||
|
public void setScoresAt (int value, int index)
|
||||||
{
|
{
|
||||||
super.toString(buf);
|
this.scores[index] = value;
|
||||||
buf.append(", tiles=").append(tiles);
|
requestElementUpdate(SCORES, new Integer(value), index);
|
||||||
buf.append(", currentTile=").append(currentTile);
|
|
||||||
buf.append(", piecens=").append(piecens);
|
|
||||||
buf.append(", scores=").append(StringUtil.toString(scores));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiTile.java,v 1.13 2001/12/18 11:58:54 mdb Exp $
|
// $Id: AtlantiTile.java,v 1.14 2002/05/21 04:45:10 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -21,7 +21,6 @@ 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.tile.NoSuchTileException;
|
|
||||||
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;
|
||||||
@@ -32,7 +31,7 @@ import com.threerings.presents.dobj.DSet;
|
|||||||
* Represents a single tile in play on the Venison game board.
|
* Represents a single tile in play on the Venison game board.
|
||||||
*/
|
*/
|
||||||
public class VenisonTile
|
public class VenisonTile
|
||||||
implements DSet.Element, TileCodes, Cloneable, Comparable
|
implements DSet.Entry, TileCodes, Cloneable, Comparable
|
||||||
{
|
{
|
||||||
/** The starting tile. */
|
/** The starting tile. */
|
||||||
public static final VenisonTile STARTING_TILE =
|
public static final VenisonTile STARTING_TILE =
|
||||||
@@ -476,18 +475,7 @@ public class VenisonTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetch the tile
|
// fetch the tile
|
||||||
try {
|
return _tset.getTileImage(type-1);
|
||||||
Tile tile = _tset.getTile(type-1);
|
|
||||||
if (tile != null) {
|
|
||||||
return tile.getImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (NoSuchTileException nste) {
|
|
||||||
// fall through
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.warning("Unable to load tile image [type=" + type + "].");
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -506,14 +494,7 @@ public class VenisonTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetch the tile
|
// fetch the tile
|
||||||
try {
|
return _stset.getTileImage(0);
|
||||||
return _stset.getTileImage(0);
|
|
||||||
} catch (NoSuchTileException nste) {
|
|
||||||
// fall through
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.warning("Unable to load shield image!");
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The tile image that we use to render this tile. */
|
/** The tile image that we use to render this tile. */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Piecen.java,v 1.2 2001/10/17 23:27:52 mdb Exp $
|
// $Id: Piecen.java,v 1.3 2002/05/21 04:45:09 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ import com.threerings.presents.dobj.DSet;
|
|||||||
* points for the group.
|
* points for the group.
|
||||||
*/
|
*/
|
||||||
public class Piecen
|
public class Piecen
|
||||||
implements DSet.Element
|
implements DSet.Entry
|
||||||
{
|
{
|
||||||
/** A color constant. */
|
/** A color constant. */
|
||||||
public static final int RED = 0;
|
public static final int RED = 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AtlantiManager.java,v 1.22 2002/01/29 23:46:37 mdb Exp $
|
// $Id: AtlantiManager.java,v 1.23 2002/05/21 04:45:10 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -12,34 +12,50 @@ import java.util.List;
|
|||||||
import com.samskivert.util.HashIntMap;
|
import com.samskivert.util.HashIntMap;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.threerings.presents.dobj.ElementAddedEvent;
|
import com.threerings.presents.dobj.EntryAddedEvent;
|
||||||
import com.threerings.presents.dobj.ElementRemovedEvent;
|
import com.threerings.presents.dobj.EntryRemovedEvent;
|
||||||
import com.threerings.presents.dobj.ElementUpdatedEvent;
|
import com.threerings.presents.dobj.EntryUpdatedEvent;
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
import com.threerings.presents.dobj.SetListener;
|
import com.threerings.presents.dobj.SetListener;
|
||||||
import com.threerings.presents.dobj.MessageEvent;
|
import com.threerings.presents.dobj.MessageEvent;
|
||||||
|
|
||||||
import com.threerings.crowd.chat.ChatMessageHandler;
|
import com.threerings.presents.dobj.MessageEvent;
|
||||||
|
|
||||||
import com.threerings.crowd.chat.ChatProvider;
|
import com.threerings.crowd.chat.ChatProvider;
|
||||||
|
import com.threerings.crowd.data.PlaceObject;
|
||||||
|
|
||||||
|
import com.threerings.crowd.chat.ChatMessageHandler;
|
||||||
import com.threerings.crowd.chat.ChatService;
|
import com.threerings.crowd.chat.ChatService;
|
||||||
|
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.turn.TurnGameManager;
|
import com.threerings.parlor.turn.TurnGameManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main coordinator of the Venison game on the server side.
|
* The main coordinator of the Venison game on the server side.
|
||||||
*/
|
*/
|
||||||
public class VenisonManager
|
public class VenisonManager extends GameManager
|
||||||
extends TurnGameManager implements VenisonCodes, SetListener
|
implements TurnGameManager, VenisonCodes, SetListener
|
||||||
{
|
{
|
||||||
|
public VenisonManager ()
|
||||||
|
{
|
||||||
|
addDelegate(_delegate = new VenisonManagerDelegate(this));
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected Class getPlaceObjectClass ()
|
protected Class getPlaceObjectClass ()
|
||||||
{
|
{
|
||||||
return VenisonObject.class;
|
return VenisonObject.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTilesInBox ()
|
||||||
|
{
|
||||||
|
return _tilesInBox.size();
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected void didInit ()
|
public void didInit ()
|
||||||
{
|
{
|
||||||
super.didInit();
|
super.didInit();
|
||||||
|
|
||||||
@@ -54,7 +70,7 @@ public class VenisonManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected void didStartup ()
|
public void didStartup ()
|
||||||
{
|
{
|
||||||
super.didStartup();
|
super.didStartup();
|
||||||
|
|
||||||
@@ -98,52 +114,35 @@ public class VenisonManager
|
|||||||
_tiles.add(start);
|
_tiles.add(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void turnWillStart ()
|
// documentation inherited
|
||||||
|
public void turnWillStart ()
|
||||||
{
|
{
|
||||||
super.turnWillStart();
|
|
||||||
|
|
||||||
// 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);
|
VenisonTile tile = (VenisonTile)_tilesInBox.remove(0);
|
||||||
_venobj.setCurrentTile(tile);
|
_venobj.setCurrentTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void turnDidEnd ()
|
// documentation inherited
|
||||||
|
public void turnDidEnd ()
|
||||||
{
|
{
|
||||||
super.turnDidEnd();
|
|
||||||
|
|
||||||
// if there are no tiles left, we end the game
|
// if there are no tiles left, we end the game
|
||||||
if (_tilesInBox.size() == 0) {
|
if (_tilesInBox.size() == 0) {
|
||||||
endGame();
|
endGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Continue the game until we're out of tiles.
|
|
||||||
*/
|
|
||||||
protected void setNextTurnHolder ()
|
|
||||||
{
|
|
||||||
// if we have tiles left, we move to the next player as normal
|
|
||||||
if (_tilesInBox.size() > 0) {
|
|
||||||
super.setNextTurnHolder();
|
|
||||||
} else {
|
|
||||||
// if we don't, we ensure that a new turn isn't started by
|
|
||||||
// setting _turnIdx to -1
|
|
||||||
_turnIdx = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* At the end of the game, we need to compute the final scores.
|
* At the end of the game, we need to compute the final scores.
|
||||||
*/
|
*/
|
||||||
protected void gameDidEnd ()
|
protected void gameDidEnd ()
|
||||||
{
|
{
|
||||||
super.gameDidEnd();
|
super.gameDidEnd();
|
||||||
|
|
||||||
// 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.elements();
|
Iterator iter = _venobj.tiles.entries();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
VenisonTile tile = (VenisonTile)iter.next();
|
VenisonTile tile = (VenisonTile)iter.next();
|
||||||
scoreFeatures(tile, piecens, true);
|
scoreFeatures(tile, piecens, true);
|
||||||
@@ -165,7 +164,7 @@ public class VenisonManager
|
|||||||
{
|
{
|
||||||
// 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[_venobj.piecens.size()];
|
||||||
Iterator iter = _venobj.piecens.elements();
|
Iterator iter = _venobj.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();
|
||||||
}
|
}
|
||||||
@@ -177,7 +176,7 @@ public class VenisonManager
|
|||||||
*
|
*
|
||||||
* @param tile the tile whose features should be scored.
|
* @param tile the tile whose features should be scored.
|
||||||
* @param piecens an array of the pieces on the board which we can
|
* @param piecens an array of the pieces on the board which we can
|
||||||
* manipulate directly without having to wait for element removed
|
* manipulate directly without having to wait for entry removed
|
||||||
* events to be dispatched.
|
* events to be dispatched.
|
||||||
* @param finalTally during the final tally, we score differently and
|
* @param finalTally during the final tally, we score differently and
|
||||||
* we don't remove piecens from the board as we score them.
|
* we don't remove piecens from the board as we score them.
|
||||||
@@ -236,7 +235,8 @@ public class VenisonManager
|
|||||||
|
|
||||||
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(_venobj.getOid(), message);
|
ChatProvider.sendSystemMessage(
|
||||||
|
_venobj.getOid(), VENISON_MESSAGE_BUNDLE, message);
|
||||||
|
|
||||||
Log.info("New scores: " + StringUtil.toString(_venobj.scores));
|
Log.info("New scores: " + StringUtil.toString(_venobj.scores));
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ public class VenisonManager
|
|||||||
String message = _players[p.owner] + " scored " +
|
String message = _players[p.owner] + " scored " +
|
||||||
score + " points for " + qual + " temple.";
|
score + " points for " + qual + " temple.";
|
||||||
ChatProvider.sendSystemMessage(
|
ChatProvider.sendSystemMessage(
|
||||||
_venobj.getOid(), message);
|
_venobj.getOid(), VENISON_MESSAGE_BUNDLE, message);
|
||||||
|
|
||||||
// add the score to the owning player
|
// add the score to the owning player
|
||||||
_venobj.scores[p.owner] += score;
|
_venobj.scores[p.owner] += score;
|
||||||
@@ -413,7 +413,7 @@ public class VenisonManager
|
|||||||
int[] pcount = new int[_players.length];
|
int[] pcount = new int[_players.length];
|
||||||
int max = 0;
|
int max = 0;
|
||||||
|
|
||||||
Iterator piter = _venobj.piecens.elements();
|
Iterator piter = _venobj.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
|
||||||
@@ -456,7 +456,8 @@ public class VenisonManager
|
|||||||
_venobj.scores[i] += cityScores[i];
|
_venobj.scores[i] += cityScores[i];
|
||||||
String message = _players[i] + " scores " + cityScores[i] +
|
String message = _players[i] + " scores " + cityScores[i] +
|
||||||
" points for fisheries.";
|
" points for fisheries.";
|
||||||
ChatProvider.sendSystemMessage(_venobj.getOid(), message);
|
ChatProvider.sendSystemMessage(
|
||||||
|
_venobj.getOid(), VENISON_MESSAGE_BUNDLE, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,7 +524,7 @@ public class VenisonManager
|
|||||||
|
|
||||||
// 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.elements();
|
Iterator iter = _venobj.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) {
|
||||||
@@ -561,7 +562,7 @@ public class VenisonManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementAdded (ElementAddedEvent event)
|
public void entryAdded (EntryAddedEvent event)
|
||||||
{
|
{
|
||||||
// we react to piecen additions by potentially scoring the placed
|
// we react to piecen additions by potentially scoring the placed
|
||||||
// piecen. we allow the piecen to be added to the piecens set
|
// piecen. we allow the piecen to be added to the piecens set
|
||||||
@@ -569,7 +570,7 @@ public class VenisonManager
|
|||||||
// 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(VenisonObject.PIECENS)) {
|
||||||
Piecen piecen = (Piecen)event.getElement();
|
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());
|
VenisonTile tile = (VenisonTile)_venobj.tiles.get(piecen.getKey());
|
||||||
@@ -584,64 +585,133 @@ public class VenisonManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now that we've scored the piecen, we can end the turn
|
// now that we've scored the piecen, we can end the turn
|
||||||
endTurn();
|
_delegate.endTurn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementUpdated (ElementUpdatedEvent event)
|
public void entryUpdated (EntryUpdatedEvent event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void elementRemoved (ElementRemovedEvent event)
|
public void entryRemoved (EntryRemovedEvent event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user requests to place a tile.
|
||||||
|
*/
|
||||||
|
protected void handlePlaceTileRequest (MessageEvent event)
|
||||||
|
{
|
||||||
|
VenisonTile tile = (VenisonTile)event.getArgs()[0];
|
||||||
|
int pidx = _delegate.getTurnHolderIndex();
|
||||||
|
|
||||||
|
// make sure it's this player's turn
|
||||||
|
if (_playerOids[pidx] != event.getSourceOid()) {
|
||||||
|
Log.warning("Requested to place tile by non-turn holder " +
|
||||||
|
"[event=" + event +
|
||||||
|
", turnHolder=" + _venobj.turnHolder + "].");
|
||||||
|
|
||||||
|
// make sure this is a valid placement
|
||||||
|
} else if (TileUtil.isValidPlacement(_tiles, tile)) {
|
||||||
|
// add the tile to the list and resort it
|
||||||
|
_tiles.add(tile);
|
||||||
|
Collections.sort(_tiles);
|
||||||
|
|
||||||
|
// inherit its claim groups
|
||||||
|
TileUtil.inheritClaims(_tiles, tile);
|
||||||
|
|
||||||
|
// add the tile to the tiles set
|
||||||
|
_venobj.addToTiles(tile);
|
||||||
|
|
||||||
|
// placing a piece may have completed road or city
|
||||||
|
// features. if it did, we score them now
|
||||||
|
scoreFeatures(tile, getPiecens(), false);
|
||||||
|
|
||||||
|
Log.info("Placed tile " + tile + ".");
|
||||||
|
|
||||||
|
// if the player has no free piecens or if there are no
|
||||||
|
// unclaimed features on this tile, we end their turn
|
||||||
|
// straight away
|
||||||
|
int pcount = TileUtil.countPiecens(_venobj.piecens, pidx);
|
||||||
|
if (pcount >= PIECENS_PER_PLAYER ||
|
||||||
|
!tile.hasUnclaimedFeature()) {
|
||||||
|
_delegate.endTurn();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.warning("Received invalid placement " + event + ".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user requests to place a piecen.
|
||||||
|
*/
|
||||||
|
protected void handlePlacePiecenRequest (MessageEvent event)
|
||||||
|
{
|
||||||
|
Piecen piecen = (Piecen)event.getArgs()[0];
|
||||||
|
VenisonTile tile = (VenisonTile)_venobj.tiles.get(piecen.getKey());
|
||||||
|
int pidx = _delegate.getTurnHolderIndex();
|
||||||
|
int pcount = TileUtil.countPiecens(_venobj.piecens, pidx);
|
||||||
|
|
||||||
|
// make sure it's this player's turn
|
||||||
|
if (_playerOids[pidx] != event.getSourceOid()) {
|
||||||
|
Log.warning("Requested to place piecen by non-turn holder " +
|
||||||
|
"[event=" + event +
|
||||||
|
", turnHolder=" + _venobj.turnHolder + "].");
|
||||||
|
|
||||||
|
// do some checking before we place the piecen
|
||||||
|
} else if (pcount >= PIECENS_PER_PLAYER) {
|
||||||
|
Log.warning("Requested to place piecen for player that " +
|
||||||
|
"has all of their piecens in play " +
|
||||||
|
"[event=" + event + "].");
|
||||||
|
|
||||||
|
} else if (tile == null) {
|
||||||
|
Log.warning("Can't find tile for requested piecen " +
|
||||||
|
"placement " + piecen + ".");
|
||||||
|
|
||||||
|
} else if (tile.claims[piecen.featureIndex] != 0) {
|
||||||
|
Log.warning("Requested to place piecen on claimed feature " +
|
||||||
|
"[tile=" + tile + ", piecen=" + piecen + "].");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// otherwise stick the piece in the tile to update the
|
||||||
|
// claim groups
|
||||||
|
tile.setPiecen(piecen, _tiles);
|
||||||
|
|
||||||
|
// and add the piecen to the game object. when we receive
|
||||||
|
// the piecen added event, we'll score it and then end the
|
||||||
|
// turn
|
||||||
|
_venobj.addToPiecens(piecen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user requests to forgo their piecen placement for
|
||||||
|
* this turn.
|
||||||
|
*/
|
||||||
|
protected void handlePlaceNothingRequest (MessageEvent event)
|
||||||
|
{
|
||||||
|
int pidx = _delegate.getTurnHolderIndex();
|
||||||
|
if (_playerOids[pidx] != event.getSourceOid()) {
|
||||||
|
Log.warning("Requested to place nothing by non-turn holder " +
|
||||||
|
"[event=" + event +
|
||||||
|
", turnHolder=" + _venobj.turnHolder + "].");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// player doesn't want to place anything, so we just end
|
||||||
|
// the turn
|
||||||
|
_delegate.endTurn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Handles place tile requests. */
|
/** Handles place tile requests. */
|
||||||
protected class PlaceTileHandler implements MessageHandler
|
protected class PlaceTileHandler implements MessageHandler
|
||||||
{
|
{
|
||||||
public void handleEvent (MessageEvent event, PlaceManager pmgr)
|
public void handleEvent (MessageEvent event, PlaceManager pmgr)
|
||||||
{
|
{
|
||||||
VenisonTile tile = (VenisonTile)event.getArgs()[0];
|
handlePlaceTileRequest(event);
|
||||||
int pidx = getTurnHolderIndex();
|
|
||||||
|
|
||||||
// make sure it's this player's turn
|
|
||||||
if (_playerOids[pidx] != event.getSourceOid()) {
|
|
||||||
Log.warning("Requested to place tile by non-turn holder " +
|
|
||||||
"[event=" + event +
|
|
||||||
", turnHolder=" + _venobj.turnHolder + "].");
|
|
||||||
|
|
||||||
// make sure this is a valid placement
|
|
||||||
} else if (TileUtil.isValidPlacement(_tiles, tile)) {
|
|
||||||
// add the tile to the list and resort it
|
|
||||||
_tiles.add(tile);
|
|
||||||
Collections.sort(_tiles);
|
|
||||||
|
|
||||||
// inherit its claim groups
|
|
||||||
TileUtil.inheritClaims(_tiles, tile);
|
|
||||||
|
|
||||||
// add the tile to the tiles set
|
|
||||||
_venobj.addToTiles(tile);
|
|
||||||
|
|
||||||
// placing a piece may have completed road or city
|
|
||||||
// features. if it did, we score them now
|
|
||||||
scoreFeatures(tile, getPiecens(), false);
|
|
||||||
|
|
||||||
Log.info("Placed tile " + tile + ".");
|
|
||||||
|
|
||||||
// if the player has no free piecens or if there are no
|
|
||||||
// unclaimed features on this tile, we end their turn
|
|
||||||
// straight away
|
|
||||||
int pcount = TileUtil.countPiecens(_venobj.piecens, pidx);
|
|
||||||
if (pcount >= PIECENS_PER_PLAYER ||
|
|
||||||
!tile.hasUnclaimedFeature()) {
|
|
||||||
endTurn();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.warning("Received invalid placement " + event + ".");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,41 +720,7 @@ public class VenisonManager
|
|||||||
{
|
{
|
||||||
public void handleEvent (MessageEvent event, PlaceManager pmgr)
|
public void handleEvent (MessageEvent event, PlaceManager pmgr)
|
||||||
{
|
{
|
||||||
Piecen piecen = (Piecen)event.getArgs()[0];
|
handlePlacePiecenRequest(event);
|
||||||
VenisonTile tile = (VenisonTile)_venobj.tiles.get(piecen.getKey());
|
|
||||||
int pidx = getTurnHolderIndex();
|
|
||||||
int pcount = TileUtil.countPiecens(_venobj.piecens, pidx);
|
|
||||||
|
|
||||||
// make sure it's this player's turn
|
|
||||||
if (_playerOids[pidx] != event.getSourceOid()) {
|
|
||||||
Log.warning("Requested to place piecen by non-turn holder " +
|
|
||||||
"[event=" + event +
|
|
||||||
", turnHolder=" + _venobj.turnHolder + "].");
|
|
||||||
|
|
||||||
// do some checking before we place the piecen
|
|
||||||
} else if (pcount >= PIECENS_PER_PLAYER) {
|
|
||||||
Log.warning("Requested to place piecen for player that " +
|
|
||||||
"has all of their piecens in play " +
|
|
||||||
"[event=" + event + "].");
|
|
||||||
|
|
||||||
} else if (tile == null) {
|
|
||||||
Log.warning("Can't find tile for requested piecen " +
|
|
||||||
"placement " + piecen + ".");
|
|
||||||
|
|
||||||
} else if (tile.claims[piecen.featureIndex] != 0) {
|
|
||||||
Log.warning("Requested to place piecen on claimed feature " +
|
|
||||||
"[tile=" + tile + ", piecen=" + piecen + "].");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// otherwise stick the piece in the tile to update the
|
|
||||||
// claim groups
|
|
||||||
tile.setPiecen(piecen, _tiles);
|
|
||||||
|
|
||||||
// and add the piecen to the game object. when we receive
|
|
||||||
// the piecen added event, we'll score it and then end the
|
|
||||||
// turn
|
|
||||||
_venobj.addToPiecens(piecen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,20 +729,13 @@ public class VenisonManager
|
|||||||
{
|
{
|
||||||
public void handleEvent (MessageEvent event, PlaceManager pmgr)
|
public void handleEvent (MessageEvent event, PlaceManager pmgr)
|
||||||
{
|
{
|
||||||
int pidx = getTurnHolderIndex();
|
handlePlaceNothingRequest(event);
|
||||||
if (_playerOids[pidx] != event.getSourceOid()) {
|
|
||||||
Log.warning("Requested to place nothing by non-turn holder " +
|
|
||||||
"[event=" + event +
|
|
||||||
", turnHolder=" + _venobj.turnHolder + "].");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// player doesn't want to place anything, so we just end
|
|
||||||
// the turn
|
|
||||||
endTurn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Our turn game delegate. */
|
||||||
|
protected VenisonManagerDelegate _delegate;
|
||||||
|
|
||||||
/** A casted reference to our Venison game object. */
|
/** A casted reference to our Venison game object. */
|
||||||
protected VenisonObject _venobj;
|
protected VenisonObject _venobj;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// $Id: AtlantiManagerDelegate.java,v 1.1 2002/05/21 04:45:10 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.venison;
|
||||||
|
|
||||||
|
import com.threerings.parlor.turn.TurnGameManagerDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the turn-based gameplay.
|
||||||
|
*/
|
||||||
|
public class VenisonManagerDelegate extends TurnGameManagerDelegate
|
||||||
|
implements VenisonCodes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructs the delegate and prepares it for operation.
|
||||||
|
*/
|
||||||
|
public VenisonManagerDelegate (VenisonManager vmgr)
|
||||||
|
{
|
||||||
|
super(vmgr);
|
||||||
|
_vmgr = vmgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continue the game until we're out of tiles.
|
||||||
|
*/
|
||||||
|
protected void setNextTurnHolder ()
|
||||||
|
{
|
||||||
|
// if we have tiles left, we move to the next player as normal
|
||||||
|
if (_vmgr.getTilesInBox() > 0) {
|
||||||
|
super.setNextTurnHolder();
|
||||||
|
} else {
|
||||||
|
// if we don't, we ensure that a new turn isn't started by
|
||||||
|
// setting _turnIdx to -1
|
||||||
|
_turnIdx = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The manager for whom we're delegating. */
|
||||||
|
protected VenisonManager _vmgr;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: PiecenUtil.java,v 1.1 2001/12/18 11:59:09 mdb Exp $
|
// $Id: PiecenUtil.java,v 1.2 2002/05/21 04:45:09 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -8,7 +8,6 @@ import java.awt.Image;
|
|||||||
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.media.tile.NoSuchTileException;
|
|
||||||
|
|
||||||
public class PiecenUtil
|
public class PiecenUtil
|
||||||
{
|
{
|
||||||
@@ -28,11 +27,7 @@ public class PiecenUtil
|
|||||||
// fetch the tile images
|
// fetch the tile images
|
||||||
_images = new Image[PIECEN_TYPES];
|
_images = new Image[PIECEN_TYPES];
|
||||||
for (int i = 0; i < PIECEN_TYPES; i++) {
|
for (int i = 0; i < PIECEN_TYPES; i++) {
|
||||||
try {
|
_images[i] = piecenSet.getTileImage(i);
|
||||||
_images[i] = piecenSet.getTileImage(i);
|
|
||||||
} catch (NoSuchTileException nste) {
|
|
||||||
Log.warning("Unable to obtain piecen tile [id=" + i + "].");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileUtil.java,v 1.15 2001/11/08 08:00:22 mdb Exp $
|
// $Id: TileUtil.java,v 1.16 2002/05/21 04:45:09 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -571,7 +571,7 @@ public class TileUtil implements TileCodes
|
|||||||
public static int countPiecens (DSet piecens, int playerIndex)
|
public static int countPiecens (DSet piecens, int playerIndex)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
Iterator iter = piecens.elements();
|
Iterator iter = piecens.entries();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
if (((Piecen)iter.next()).owner == playerIndex) {
|
if (((Piecen)iter.next()).owner == playerIndex) {
|
||||||
count++;
|
count++;
|
||||||
|
|||||||
Reference in New Issue
Block a user