Set and Remove Pawns
Now that the board is constructed, you will place pawns on the board, check whether a pawn exists at a particular tile coordinate, and remove a pawn from the board.
Start with the following scenario. Given a tile_coordinate, determine whether there is a pawn there, and, if there is, retrieve it. The idea is as follows:
- The board holds an array of
creative_proppawns. - Iterate through the existing pawns and obtain each pawn location as a tile coordinate.
- If there is a pawn at the given tile coordinate, retrieve it.
- If there is not, the function fails.
Determine Tile Coordinate Equality
This requires that you have the ability to test whether two tile_coordinate's are equal. This is necessary because our custom tile coordinate data type is not a subtype of Verse's built-in comparable type. As a result, you need to manually define what it means for two tile coordinates to be equal. First, create a AreTileCoordinatesEqual function in the DataTypesmodule to determine this:
| | |
| --- | --- |
| | using { /Verse.org/Simulation } |
| | |
| | DataTypes<public> := module: |
| | |
| | ... |
| | |
| | UtilityFunctions<public> := module: |
| | |
| | ... |
| | |
| | AreTileCoordinatesEqual<public>(LeftTileCoordinate:tile_coordinate, RightTileCoordinate:tile_coordinate)<decides><transacts>:void = |
| | LeftTileCoordinate.Left = RightTileCoordinate.Left |
| | LeftTileCoordinate.Forward = RightTileCoordinate.Forward |
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.