Placing tokens on the Ludo Board

TL;DR

We extend the low-level interface, making tokens change their state when they enter the board. We turn this into an example method (a test).

Placing tokens

We continue to prototype our ideas in the Playground.

We place tokens on the board, changing their state from #start to #play.

board := GtLudoBoardExamples new emptyBoard.
playerA := board players first.
board enterPlayTokenFor: playerA.
playerB := board players second.
board enterPlayTokenFor: playerB.
board
  

Inspect this and go to the Players view. You will see that two of the tokens have changed state.

Note that this is just the low-level interface. We will need the board Game object to manage the rules of the game.

Promoting a snippet to an example

We turn this into an example with tests. Note how we have embellished the snippet with assertions.

boardWith2PlayingPlayers
	<gtExample>
	
	| board playerA playerB |
	board := self emptyBoard.
	
	playerA := board players first.
	playerA tokens do: [ :token | self assert: token isInStartState ].
	board enterPlayTokenFor: playerA.
	self assert: playerA tokens first isInPlay.
	self assert: playerA tokens second isInStartState.
	
	playerB := board players second.
	playerB tokens do: [ :token | self assert: token isInStartState ].
	board enterPlayTokenFor: playerB.
	self assert: playerB tokens first isInPlay.
	self assert: playerB tokens second isInStartState.
	
	^ board