ch.sahits.game.graphic.display.model
Class CityPlayerProxy

java.lang.Object
  extended by ch.sahits.game.graphic.display.model.CityPlayerProxy
All Implemented Interfaces:
ch.sahits.game.event.IEventListener

public class CityPlayerProxy
extends Object
implements ch.sahits.game.event.IEventListener

The CityView is a view model of a city. It provides access to the city model as well as player specific aspects of the city, for example buildings, ships and so forth.

Author:
Andi Hotz, (c) Sahits GmbH, 2011 Created on Nov 19, 2011

Field Summary
private  ch.sahits.game.openpatrician.model.ship.IShip activeShip
          Reference the active ship of the player
private  ch.sahits.game.openpatrician.model.city.ICity city
           
private  ch.sahits.game.openpatrician.model.IPlayer player
           
private  List<ch.sahits.game.openpatrician.model.ship.IShip> playerShips
          List holding all ships owned by the player currently present in the city
private  List<ch.sahits.game.openpatrician.model.ship.IShip> shipList
          List holding all ships currently present in the city
 
Constructor Summary
CityPlayerProxy(ch.sahits.game.openpatrician.model.city.ICity city, ch.sahits.game.openpatrician.model.IPlayer player)
          Constructor initializing the city and the player
CityPlayerProxy(ch.sahits.game.openpatrician.model.city.ICity city, ch.sahits.game.openpatrician.model.IPlayer player, ch.sahits.game.openpatrician.model.ship.IShip activeShip)
          Constructor initializing the city and the player with one ship in port.
 
Method Summary
 void activateShip(ch.sahits.game.openpatrician.model.ship.IShip ship)
          Activate a ship.
 void arrive(ch.sahits.game.openpatrician.model.ship.IShip ship)
          A ship arrives in the city
 void gameUpdate(ch.sahits.game.event.Event e, Object eventNotice)
          Handle all the events that are generated from outside (not by the player).
 ch.sahits.game.openpatrician.model.ship.IShip getActiveShip()
          Retrieve the players active ship
 ch.sahits.game.openpatrician.model.city.ICity getCity()
           
 ch.sahits.game.openpatrician.model.IPlayer getPlayer()
           
 List<ch.sahits.game.openpatrician.model.ship.IShip> getPlayersShips()
          Retrieve the list of all ships of the player currently in the port.
 void leave(ch.sahits.game.openpatrician.model.ship.IShip ship)
          Ship leave the city
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

city

private final ch.sahits.game.openpatrician.model.city.ICity city

player

private final ch.sahits.game.openpatrician.model.IPlayer player

shipList

private List<ch.sahits.game.openpatrician.model.ship.IShip> shipList
List holding all ships currently present in the city


playerShips

private List<ch.sahits.game.openpatrician.model.ship.IShip> playerShips
List holding all ships owned by the player currently present in the city


activeShip

private ch.sahits.game.openpatrician.model.ship.IShip activeShip
Reference the active ship of the player

Constructor Detail

CityPlayerProxy

public CityPlayerProxy(ch.sahits.game.openpatrician.model.city.ICity city,
                       ch.sahits.game.openpatrician.model.IPlayer player)
Constructor initializing the city and the player

Parameters:
city -
player -

CityPlayerProxy

public CityPlayerProxy(ch.sahits.game.openpatrician.model.city.ICity city,
                       ch.sahits.game.openpatrician.model.IPlayer player,
                       ch.sahits.game.openpatrician.model.ship.IShip activeShip)
Constructor initializing the city and the player with one ship in port.

Parameters:
city -
player -
activeShip -
Method Detail

getActiveShip

public ch.sahits.game.openpatrician.model.ship.IShip getActiveShip()
Retrieve the players active ship

Returns:

activateShip

public void activateShip(ch.sahits.game.openpatrician.model.ship.IShip ship)
Activate a ship. If the ship is not one of the players or not in port an IllegalArgumentException will be thrown

Parameters:
ship -
Throws:
IllegalArgumentException - if the ship cannot be activated due to its non existence

getPlayersShips

public List<ch.sahits.game.openpatrician.model.ship.IShip> getPlayersShips()
Retrieve the list of all ships of the player currently in the port. The list is unmodifiable.

Returns:
unmodifiable list of the players ships

gameUpdate

public void gameUpdate(ch.sahits.game.event.Event e,
                       Object eventNotice)
Handle all the events that are generated from outside (not by the player). Such events are arriving/leaving ships, price changes.

Specified by:
gameUpdate in interface ch.sahits.game.event.IEventListener

arrive

public void arrive(ch.sahits.game.openpatrician.model.ship.IShip ship)
A ship arrives in the city

Parameters:
ship -

leave

public void leave(ch.sahits.game.openpatrician.model.ship.IShip ship)
Ship leave the city

Parameters:
ship -

getCity

public ch.sahits.game.openpatrician.model.city.ICity getCity()

getPlayer

public ch.sahits.game.openpatrician.model.IPlayer getPlayer()


Copyright © 2011 Sahits GmbH. All Rights Reserved.