de.spieleck.game.base
Class GamePlaceBase

java.lang.Object
  |
  +--de.spieleck.game.base.GamePlaceBase
All Implemented Interfaces:
GamePlace, GameSpectator, PlayerCollection, ReadablePlayerCollection, ReadableSpectatorCollection, Spectable, SpectatorCollection
Direct Known Subclasses:
GameRoomBase, GameTableBase

public abstract class GamePlaceBase
extends java.lang.Object
implements GamePlace, Spectable, SpectatorCollection, PlayerCollection

A default implementation for GamePlace


Constructor Summary
GamePlaceBase()
           
 
Method Summary
 boolean canWatch(GameSpectator s)
          can join, can be matter rights, roles, game rules or whatever.
 void dispatchUpdateMessage(UpdateMessage msg)
          A Spectable can be made responsible to distribute certain Events to it's Spectators.
 GamePlace getParent()
          Get the Places parent Place.
 java.lang.String getPlaceName()
          Every GamePlace should have a name.
 int getPlayerCount()
          Return the number of players currently in the game
 java.util.Iterator getPlayers()
          GameState API.
 java.lang.String getSpectatorName()
           
 java.util.Iterator getSpectators()
          get Spectators
 int getSpectatorsCount()
          Return the number of Spectators currently in the collection
 boolean isIn(GamePlayer p)
          GameState API.
 boolean isWatching(GameSpectator s)
          Check weather a certain Spectator is in the collection.
 void join(GamePlayer p)
          add a new Player if joining is not allowed, an Exception is thrown
 void leave(GamePlayer p)
          removes the given player from the players list
 void setParent(GamePlace parentPlace)
          We use a Parent link at times.
protected  void setPlayers(PlayerCollection players)
          Since we want to manage Players we use a PlayerCollection
protected  void setSpectators(SpectatorCollection spectators)
          Since we want to manage Players we use a PlayerCollection
 void turnAway(GameSpectator s)
          removes the given Spectator from the spectators list
 void watch(GameSpectator s)
          add a new Spectator if joining is not allowed, an Exception is thrown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.spieleck.game.base.GamePlace
getPlaceLocalName
 
Methods inherited from interface de.spieleck.game.base.GameSpectator
notifyUpdate
 
Methods inherited from interface de.spieleck.game.base.PlayerCollection
canJoin, canLeave
 

Constructor Detail

GamePlaceBase

public GamePlaceBase()
Method Detail

setSpectators

protected void setSpectators(SpectatorCollection spectators)
Since we want to manage Players we use a PlayerCollection

setPlayers

protected void setPlayers(PlayerCollection players)
Since we want to manage Players we use a PlayerCollection

getPlaceName

public java.lang.String getPlaceName()
Every GamePlace should have a name.
Specified by:
getPlaceName in interface GamePlace

getSpectatorName

public java.lang.String getSpectatorName()
Specified by:
getSpectatorName in interface GameSpectator

setParent

public void setParent(GamePlace parentPlace)
We use a Parent link at times.
Specified by:
setParent in interface GamePlace

getParent

public GamePlace getParent()
Get the Places parent Place.
Specified by:
getParent in interface GamePlace

watch

public void watch(GameSpectator s)
           throws GameException
Description copied from interface: SpectatorCollection
add a new Spectator if joining is not allowed, an Exception is thrown
Specified by:
watch in interface SpectatorCollection

turnAway

public void turnAway(GameSpectator s)
              throws GameException
Description copied from interface: SpectatorCollection
removes the given Spectator from the spectators list
Specified by:
turnAway in interface SpectatorCollection

isWatching

public boolean isWatching(GameSpectator s)
                   throws GameException
Description copied from interface: ReadableSpectatorCollection
Check weather a certain Spectator is in the collection.
Specified by:
isWatching in interface ReadableSpectatorCollection

join

public void join(GamePlayer p)
          throws GameException
Description copied from interface: PlayerCollection
add a new Player if joining is not allowed, an Exception is thrown
Specified by:
join in interface PlayerCollection

leave

public void leave(GamePlayer p)
           throws GameException
Description copied from interface: PlayerCollection
removes the given player from the players list
Specified by:
leave in interface PlayerCollection

getPlayerCount

public int getPlayerCount()
Description copied from interface: ReadablePlayerCollection
Return the number of players currently in the game
Specified by:
getPlayerCount in interface ReadablePlayerCollection

getSpectators

public java.util.Iterator getSpectators()
get Spectators
Specified by:
getSpectators in interface ReadableSpectatorCollection

getPlayers

public java.util.Iterator getPlayers()
GameState API.
Specified by:
getPlayers in interface ReadablePlayerCollection

isIn

public boolean isIn(GamePlayer p)
GameState API.
Specified by:
isIn in interface ReadablePlayerCollection

getSpectatorsCount

public int getSpectatorsCount()
Description copied from interface: ReadableSpectatorCollection
Return the number of Spectators currently in the collection
Specified by:
getSpectatorsCount in interface ReadableSpectatorCollection

canWatch

public boolean canWatch(GameSpectator s)
Description copied from interface: SpectatorCollection
can join, can be matter rights, roles, game rules or whatever.
Specified by:
canWatch in interface SpectatorCollection

dispatchUpdateMessage

public void dispatchUpdateMessage(UpdateMessage msg)
A Spectable can be made responsible to distribute certain Events to it's Spectators.
Specified by:
dispatchUpdateMessage in interface Spectable


gameframe project