map.MapView Class
You need to pass in how many pixels tall/wide the map is and how many hexes tall/wide the map is (the hex dim can be calculated from the client model)
Constructor
map.MapView
-
pixelDim
-
hexDim
Parameters:
-
pixelDim
Intthe height of the map measured in pixels
-
hexDim
Intthe height of the map measured in hexes
Item Index
Methods
Properties
Methods
addHex
-
loc
-
type
-
[noDraw]
This adds a hex to the board.
Parameters:
-
loc
HexLocationThe location to put the hex. This should only be called at most once per hex location
-
type
StringThe type of the hex: a resource("wood","brick","sheep","wheat","ore"), "desert", or "water"
-
[noDraw]
Boolean optionalOptional - if omitted or false, the view is not redrawn.
addNumber
-
loc
-
number
-
[noDraw]
This adds a number to the board.
Parameters:
-
loc
HexLocationThe location to put the number. This should only be called at most once per hex location
-
number
IntegerThe number to put on the map
-
[noDraw]
Boolean optionalOptional - if omitted or false, the view is not redrawn.
addPort
-
loc
-
type
-
[noDraw]
This adds a port to the board.
Parameters:
-
loc
PortLocThe location to put the port. This should only be called only once per port
-
type
StringThe port type: a resource("wood","brick","sheep","wheat","ore"), or "three"
-
[noDraw]
Boolean optionalOptional - if omitted or false, the view is not redrawn.
cancelDrop
()
This cancels the piece placement process.
drawPieces
()
This causes the pieces on the board to be drawn.
placeCity
-
loc
-
playerColor
-
[noDraw]
This adds a city to the board.
Parameters:
-
loc
VertexLocThe location to put the city.
-
playerColor
StringThe player color
-
[noDraw]
Boolean optionalOptional - if omitted or false, the view is not redrawn.
placeRoad
-
loc
-
playerColor
-
[noDraw]
This adds a road to the board.
Parameters:
-
loc
EdgeLocThe location to put the road.
-
playerColor
StringThe player color
-
[noDraw]
Boolean optionalOptional - if omitted or false, the view is not redrawn.
placeRobber
-
loc
-
[noDraw]
This places the robber on the board. Subsequent calls move the robber.
Parameters:
-
loc
HexLocationThe location to put the robber.
-
[noDraw]
Boolean optionalOptional - if omitted or false, the view is not redrawn.
placeSettlement
-
loc
-
playerColor
-
[noDraw]
This adds a settlement to the board.
Parameters:
-
loc
VertexLocThe location to put the settlement.
-
playerColor
StringThe player color
-
[noDraw]
Boolean optionalOptional - if omitted or false, the view is not redrawn.
startDrop
-
objectType
-
color
This starts the piece placement process - it has no knowledge of the model, so you must tell it the piece type and color. Color can be omitted and has no effect if it's the robber After calling this, the view will use the controller's "onDrag" and "onDrop" methods to check whether a piece can be placed.
Parameters:
-
objectType
StringThe type of piece to be placed ("city","settlement","road","robber")
-
color
StringThe color of the piece you want to place. (Omit for "robber".)