API Docs for:
Show:

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 Int

    the height of the map measured in pixels

  • hexDim Int

    the height of the map measured in hexes

Methods

addHex

(
  • loc
  • type
  • [noDraw]
)

This adds a hex to the board.

Parameters:

  • loc HexLocation

    The location to put the hex. This should only be called at most once per hex location

  • type String

    The type of the hex: a resource("wood","brick","sheep","wheat","ore"), "desert", or "water"

  • [noDraw] Boolean optional

    Optional - if omitted or false, the view is not redrawn.

addNumber

(
  • loc
  • number
  • [noDraw]
)

This adds a number to the board.

Parameters:

  • loc HexLocation

    The location to put the number. This should only be called at most once per hex location

  • number Integer

    The number to put on the map

  • [noDraw] Boolean optional

    Optional - if omitted or false, the view is not redrawn.

addPort

(
  • loc
  • type
  • [noDraw]
)

This adds a port to the board.

Parameters:

  • loc PortLoc

    The location to put the port. This should only be called only once per port

  • type String

    The port type: a resource("wood","brick","sheep","wheat","ore"), or "three"

  • [noDraw] Boolean optional

    Optional - 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 VertexLoc

    The location to put the city.

  • playerColor String

    The player color

  • [noDraw] Boolean optional

    Optional - if omitted or false, the view is not redrawn.

placeRoad

(
  • loc
  • playerColor
  • [noDraw]
)

This adds a road to the board.

Parameters:

  • loc EdgeLoc

    The location to put the road.

  • playerColor String

    The player color

  • [noDraw] Boolean optional

    Optional - 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 HexLocation

    The location to put the robber.

  • [noDraw] Boolean optional

    Optional - if omitted or false, the view is not redrawn.

placeSettlement

(
  • loc
  • playerColor
  • [noDraw]
)

This adds a settlement to the board.

Parameters:

  • loc VertexLoc

    The location to put the settlement.

  • playerColor String

    The player color

  • [noDraw] Boolean optional

    Optional - 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 String

    The type of piece to be placed ("city","settlement","road","robber")

  • color String

    The color of the piece you want to place. (Omit for "robber".)

Properties

controller

MapController