func (g *Game) checkPlayerBoard(pn player.Name, checkWords bool) ([]string, error) {
	var usedWords []string
	var err error
	p := g.players[pn]
	switch {
	case len(p.Board.UnusedTiles) != 0:
		err = fmt.Errorf("not all tiles used")
	case !p.Board.CanBeFinished():
		err = fmt.Errorf("not all used tiles form a single group")
	case checkWords:
		usedWords, err = g.checkWords(pn)
	}
	if err != nil {
		errText := "invalid board: " + err.Error()
		if g.Config.Penalize && p.WinPoints > 2 {
			p.WinPoints--
			errText = errText + ", possible win points decremented"
		}
		return nil, gameWarning(errText)
	}
	return usedWords, nil
}
// checkPlayerBoard checks the player board to ensure all tiles are in a group, words are valid, and other tests prescribed by the config.
// The words and a possible game warning error are returned.
// The player's winPoints are decremented if an error is returned if and only if the config wants to.
checkPlayerBoard checks the player board to ensure all tiles are in a group, words are valid, and other tests prescribed by the config.
The words and a possible game warning error are returned.
The player's winPoints are decremented if an error is returned if and only if the config wants to.
// checkPlayerBoard checks the player board to ensure all tiles are in a group words are valid and other tests prescribed by the config . // The words and a possible game warning error are returned . // The player ' s winPoints are decremented if an error is returned if and only if the config wants to .
func (g *Game) checkPlayerBoard(pn player.Name, checkWords bool) ([]string, error) {
	var usedWords []string
	var err error
	p := g.players[pn]
	switch {
	case len(p.Board.UnusedTiles) != 0:
		err = fmt.Errorf("not all tiles used")
	case !p.Board.CanBeFinished():
		err = fmt.Errorf("not all used tiles form a single group")
	case checkWords:
		usedWords, err = g.checkWords(pn)
	}
	if err != nil {
		errText := "invalid board: " + err.Error()
		if g.Config.Penalize && p.WinPoints > 2 {
			p.WinPoints--
			errText = errText + ", possible win points decremented"
		}
		return nil, gameWarning(errText)
	}
	return usedWords, nil
}
func ( g * Game ) checkPlayerBoard ( pn player . Name , checkWords bool ) ( [ ] string , error ) { var usedWords [ ] string var err error p := g . players [ pn ] switch { case len ( p . Board . UnusedTiles ) != 0 : err = fmt . Errorf ( " " ) case ! p . Board . CanBeFinished ( ) : err = fmt . Errorf ( " " ) case checkWords : usedWords , err = g . checkWords ( pn ) } if err != nil { errText := " " + err . Error ( ) if g . Config . Penalize && p . WinPoints > 2 { p . WinPoints -- errText = errText + " " } return nil , gameWarning ( errText ) } return usedWords , nil }
checkPlayerBoard checks the player board to ensure all tiles are in a group, words are valid, and other tests prescribed by the config.
checkPlayerBoard checks the player board to ensure all tiles are in a group words are valid and other tests prescribed by the config .