BattleGround

public class BattleGround

One of the nine small grids in the larger grid. For simplicity, we refer to these small grids as BattleGrounds. Each of these grids contains a 2-D array of Tiles, which can be claimed by either player

Note

The tiles variable is mutable
  • This array contains the individual tiles in each battle ground

    Declaration

    Swift

    var tiles: [[Tile]]
  • This computed property is a 9 count array of type URLQueryItem that represents each tile in the battleground

    Declaration

    Swift

    var queryItems: [URLQueryItem]
  • This computer property stores the winner of the battleground, if there is one

    Declaration

    Swift

    var winner: Tile?
  • This initializer creates a BattleGround filled with .empty tiles

    Declaration

    Swift

    init()
  • This convenience initializer takes an array of queryItems and generates the proper tile array from them.

    Note

    The reason why this is a convenience initializer that first calls the default init() (creating a blank tile grid), and then adds in the appropriate tiles, is that this function is implemented in a way that directly accesses the array of tiles (e.g. tiles[1][2])

    Important

    The array must be of size 9, or the initializer will not work as intended

    Declaration

    Swift

    convenience init(queryItems: [URLQueryItem])