public final class InternalServer extends java.lang.Object implements GameStateListener
Modifier and Type | Class and Description |
---|---|
static interface |
InternalServer.InternalServerListener
Interface that receives server events.
|
private class |
InternalServer.ServerThread
Main thread managing all connections and initially
responsible for accepting joining players.
|
Modifier and Type | Field and Description |
---|---|
private InternalServer.InternalServerListener |
handler
Listener to send server events to.
|
private InternalServer.ServerThread |
thread
Thread executing the main server logic.
|
Constructor and Description |
---|
InternalServer(InternalServer.InternalServerListener handler)
Constructs a new server with the given listener.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Called when the game is aborted (forcefully terminated).
|
void |
claim(Player player,
ConvexObject obj)
Called when a player claims a new object.
|
void |
end()
Called when the game ends.
|
void |
merge(Player player,
ConvexObject source,
ConvexObject target,
ConvexObject result,
java.util.List<ConvexObject> absorbed)
Called when a player performs a merge.
|
void |
shutdown()
Immediately shuts down this server and closes
all the connections it had open.
|
GameConstructor |
startGame(java.util.List<Player> players,
PlayfieldGenerator gen,
boolean showDecomp)
Gets the game constructor required to start
a game with the given set of players and with
the given playfield generator.
|
private InternalServer.ServerThread thread
private InternalServer.InternalServerListener handler
public InternalServer(InternalServer.InternalServerListener handler)
handler
- The event listener.public void shutdown()
public GameConstructor startGame(java.util.List<Player> players, PlayfieldGenerator gen, boolean showDecomp)
players
- The list of participating players.gen
- The playfield generator.showDecomp
- Whether to show the vertical decomposition
from the start of the game.public void claim(Player player, ConvexObject obj)
GameStateListener
claim
in interface GameStateListener
player
- The player that made the claim.obj
- The object that was claimed.public void merge(Player player, ConvexObject source, ConvexObject target, ConvexObject result, java.util.List<ConvexObject> absorbed)
GameStateListener
merge
in interface GameStateListener
player
- The player that performed the merge.source
- The object the merge was started from.target
- The target object of the merge.result
- The object resulting from the merge.absorbed
- The objects absorbed in the merge.public void end()
GameStateListener
end
in interface GameStateListener
public void abort()
GameStateListener
abort
in interface GameStateListener