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.
- Alphabetic
- By Inheritance
- GameBoard
- Grid
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- 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
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- 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
- 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
- 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
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def boozeGlasses: Vector[Glass]
Returns a collection of all the booze glasses currently on the board.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- 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
- 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
- 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
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val height: Int
- Definition Classes
- Grid
- 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 newGlass
object for each location on the board. This method is automatically invoked by the superclassGrid
to initialize the contents of the grid.- returns
a collection of size
width
timesheight
that contains the initial grid elements. The first element in the collection will appear atGridPos
(0,0), the second at (1,0), and so on, filling in the first row before continuing on the second row at (1,0).
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- 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.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- 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
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val size: Int
the number of elements in this grid, in total.
the number of elements in this grid, in total. (Equals
width
timesheight
.)- Definition Classes
- Grid
- 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
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString: String
- Definition Classes
- AnyRef → Any
- 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
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- val width: Int
- Definition Classes
- Grid
Deprecated Value Members
- 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.