public class MapController extends Controller implements IMapController
Modifier and Type | Field and Description |
---|---|
private DropObject |
dropObject |
private ModelObserver |
observer |
private java.util.List<MapObserver> |
observers |
private IMapState |
state |
Constructor and Description |
---|
MapController(IMapView view)
Creates a MapController object.
|
Modifier and Type | Method and Description |
---|---|
void |
AddMapObserver(MapObserver listener) |
void |
CancelMove() |
boolean |
CanPlaceCity(Coordinate point,
CatanColor color)
This method is called whenever the user is trying to place a city on the
map.
|
boolean |
CanPlaceRoad(Coordinate p1,
Coordinate p2,
CatanColor color)
This method is called whenever the user is trying to place a road on the
map.
|
boolean |
CanPlaceRobber(Coordinate point)
This method is called whenever the user is trying to place the robber on
the map.
|
boolean |
CanPlaceSettlement(Coordinate point,
CatanColor color)
This method is called whenever the user is trying to place a settlement
on the map.
|
private void |
EndDrag() |
DropObject |
GetDropObject() |
java.util.Iterator<Edge> |
GetEdges()
Gets all the edges in the map.
|
java.util.Iterator<Hex> |
GetHexes()
Gets all the hexes in the map.
|
IMapModel |
GetModel() |
java.util.Iterator<java.util.Map.Entry<java.lang.Integer,java.util.List<Hex>>> |
GetPips()
Gets all the pips in the map.
|
java.util.Iterator<java.util.Map.Entry<Edge,Hex>> |
GetPorts()
Gets all the ports on the map.
|
Hex |
GetRobberPlacement()
Gets the location of the robber.
|
java.util.Iterator<Vertex> |
GetVertices()
Gets all the vertices in the map.
|
IMapView |
getView()
View getter
|
boolean |
IsRobberInitialized() |
void |
MouseClick() |
void |
MouseMove(java.awt.geom.Point2D worldPoint) |
void |
PlaceCity(Coordinate point) |
void |
PlaceRoad(Coordinate p1,
Coordinate p2) |
void |
PlaceRobber(Coordinate point) |
void |
PlaceSettlement(Coordinate point) |
private void |
StartDrag(boolean allowCancel) |
private void |
StartMove(PieceType pieceType) |
private java.util.List<MapObserver> observers
private DropObject dropObject
private IMapState state
private ModelObserver observer
public MapController(IMapView view)
view
- The MapView object.robView
- The RobberView object.public IMapView getView()
IController
getView
in interface IController
getView
in class Controller
public boolean CanPlaceRoad(Coordinate p1, Coordinate p2, CatanColor color)
IMapController
CanPlaceRoad
in interface IMapController
p1
- The beginning of the road piecep2
- The end of the road piece (it's the end of the road, get it? Never mind...)color
- The color of the road being placedpublic boolean CanPlaceSettlement(Coordinate point, CatanColor color)
IMapController
CanPlaceSettlement
in interface IMapController
point
- the location of the vertexcolor
- the color of the piece being placedpublic boolean CanPlaceCity(Coordinate point, CatanColor color)
IMapController
CanPlaceCity
in interface IMapController
point
- the location of the vertexcolor
- the color of the piece being placedpublic boolean CanPlaceRobber(Coordinate point)
IMapController
CanPlaceRobber
in interface IMapController
point
- the coordinate of the hexpublic java.util.Iterator<Hex> GetHexes()
IMapController
GetHexes
in interface IMapController
public java.util.Iterator<Edge> GetEdges()
IMapController
GetEdges
in interface IMapController
public java.util.Iterator<Vertex> GetVertices()
IMapController
GetVertices
in interface IMapController
public java.util.Iterator<java.util.Map.Entry<Edge,Hex>> GetPorts()
IMapController
GetPorts
in interface IMapController
public java.util.Iterator<java.util.Map.Entry<java.lang.Integer,java.util.List<Hex>>> GetPips()
IMapController
GetPips
in interface IMapController
public Hex GetRobberPlacement() throws MapException
IMapController
GetRobberPlacement
in interface IMapController
MapException
public boolean IsRobberInitialized()
IsRobberInitialized
in interface IMapController
public DropObject GetDropObject()
GetDropObject
in interface IMapController
public void PlaceRoad(Coordinate p1, Coordinate p2)
PlaceRoad
in interface IMapController
public void PlaceSettlement(Coordinate point)
PlaceSettlement
in interface IMapController
public void PlaceCity(Coordinate point)
PlaceCity
in interface IMapController
public void PlaceRobber(Coordinate point)
PlaceRobber
in interface IMapController
public void MouseMove(java.awt.geom.Point2D worldPoint)
MouseMove
in interface IMapController
public void MouseClick()
MouseClick
in interface IMapController
public IMapModel GetModel()
GetModel
in interface IMapController
public void AddMapObserver(MapObserver listener)
AddMapObserver
in interface IMapController
public void CancelMove()
CancelMove
in interface IMapController
private void StartDrag(boolean allowCancel)
private void EndDrag()
private void StartMove(PieceType pieceType)