Packages

c

o1.viinaharava

GameBoard

class GameBoard extends o1.Grid[Glass]

Each instance of the class GameBoard represents a board for a game of Viinaharava. A game board is a Grid whose elements are Glass objects.

A GameBoard is first initialized with water glasses (by initialElements). However, a number of the glasses are then immediately poured full of booze while the rest keep their default content of water.

Once created, a GameBoard does not replace any of its Glass objects with another. However, the state of each individual Glass may change.

Linear Supertypes
grid.Grid[Glass], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. GameBoard
  2. Grid
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new GameBoard(width: Int, height: Int, boozeCount: Int)

    width

    the number of glasses in each row of the game board

    height

    the number of rows of glasses in the game board

    boozeCount

    the number of booze glasses on the game board. When a GameBoard object is created, it randomly chooses this many different locations on the board and pours booze in them.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def allElements: Vector[Glass]

    Returns a collection of all the elements currently in the grid.

    Returns a collection of all the elements currently in the grid.

    Definition Classes
    Grid
  5. def allPositions: Vector[grid.GridPos]

    Returns a collection of all the locations on the grid.

    Returns a collection of all the locations on the grid.

    Definition Classes
    Grid
  6. def apply(location: grid.GridPos): Glass

    Returns the element at the given pair of coordinates.

    Returns the element at the given pair of coordinates. (This does the same as elementAt.)

    location

    a location on the grid (must be within range)

    Definition Classes
    Grid
  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def boozeGlasses: Vector[Glass]

    Returns a collection of all the booze glasses currently on the board.

  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  10. def contains(location: grid.GridPos): Boolean

    Determines whether the grid contains the given pair of coordinates.

    Determines whether the grid contains the given pair of coordinates. For instance,a grid with a width and height of 5 will contain (0, 0) and (4, 4) but not (-1, -1), (4, 5) or (5, 4).

    Definition Classes
    Grid
  11. def drink(target: Glass): Unit

    Virtually drinks the contents of the given glass.

    Virtually drinks the contents of the given glass.

    For a glass of water, “drinking” it just means that the glass is emptied. (If the water glass was already empty, this method does nothing.)

    For a glass of booze, “drinking” it empties not just that glass but also all the other glasses of booze on the game board. (This ends the game of Viinaharava and all the locations of booze glasses are revealed as a result.)

    target

    a glass on this board

  12. def elementAt(location: grid.GridPos): Glass

    Returns the element at the given pair of coordinates.

    Returns the element at the given pair of coordinates. (This does the same as apply.)

    location

    a location on the grid (must be within range)

    Definition Classes
    Grid
  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  15. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  17. val height: Int
    Definition Classes
    Grid
  18. def initialElements: IndexedSeq[Glass]

    Generates the elements that initially occupy the grid.

    Generates the elements that initially occupy the grid. In the case of a GameBoard grid, this means generating a new Glass object for each location on the board. This method is automatically invoked by the superclass Grid to initialize the contents of the grid.

    returns

    a collection of size width times height that contains the initial grid elements. The first element in the collection will appear at GridPos (0,0), the second at (1,0), and so on, filling in the first row before continuing on the second row at (1,0).

    Definition Classes
    GameBoardGrid
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. def isOutOfWater: Boolean

    Determines whether all the water on the board has been drunk already.

    Determines whether all the water on the board has been drunk already. This is the case if and only if each of glasses either contains booze or is empty.

  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. def neighbors(middleLoc: grid.GridPos, includeDiagonals: Boolean): Vector[Glass]

    Returns a vector of all the neighboring elements of the indicated element.

    Returns a vector of all the neighboring elements of the indicated element. Depending on the value of the second parameter, either only the four neighbors in cardinal compass directions (north, east, south, west) are considered, or the four diagonals as well.

    Note that an element that is at the edge of the grid has fewer neighbors than one in the middle. For instance, the element at (0, 0) of a 5-by-5 grid has only three neighbors, diagonals included.

    middleLoc

    the location between the neighbors

    includeDiagonals

    true if diagonal neighbors also count (resulting in up to eight neighbors), false if only cardinal directions count (resulting in up to four)

    Definition Classes
    Grid
  23. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  25. val size: Int

    the number of elements in this grid, in total.

    the number of elements in this grid, in total. (Equals width times height.)

    Definition Classes
    Grid
  26. def swap(location1: grid.GridPos, location2: grid.GridPos): Unit

    Swaps the elements at two given locations on the grid, which must be within range.

    Swaps the elements at two given locations on the grid, which must be within range.

    Definition Classes
    Grid
  27. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  28. def toString: String
    Definition Classes
    AnyRef → Any
  29. def update(location: grid.GridPos, newElement: Glass): Unit

    Modifies the grid by replacing the existing element at the given location with the new element.

    Modifies the grid by replacing the existing element at the given location with the new element.

    location

    a location on the grid (must be within range)

    newElement

    the new element that replaces the old one at location

    Definition Classes
    Grid
  30. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  31. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  32. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  33. val width: Int
    Definition Classes
    Grid

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from grid.Grid[Glass]

Inherited from AnyRef

Inherited from Any

Ungrouped