func (g Game) checkWords(pn player.Name) ([]string, error) {
	p := g.players[pn]
	usedWords := p.Board.UsedTileWords()
	var invalidWords []string
	uniqueWords := make(map[string]struct{}, len(usedWords))
	var err error
	for _, w := range usedWords {
		if _, ok := uniqueWords[w]; g.Config.ProhibitDuplicates && ok {
			err = fmt.Errorf("duplicate words are prohibited")
			break
		}
		uniqueWords[w] = struct{}{}
		if len(w) < g.Config.MinLength {
			err = fmt.Errorf("short word detected, all must be at least %v characters", g.Config.MinLength)
			break
		}
		if !g.WordValidator.Validate(w) {
			invalidWords = append(invalidWords, w)
		}
	}
	if len(invalidWords) > 0 {
		err = fmt.Errorf("invalid words: %v", invalidWords)
	}
	if err != nil {
		return nil, err
	}
	return usedWords, nil
}
// checkWords returns the used words from the game and an error if the game board is not valid.
checkWords returns the used words from the game and an error if the game board is not valid.
// checkWords returns the used words from the game and an error if the game board is not valid .
func (g Game) checkWords(pn player.Name) ([]string, error) {
	p := g.players[pn]
	usedWords := p.Board.UsedTileWords()
	var invalidWords []string
	uniqueWords := make(map[string]struct{}, len(usedWords))
	var err error
	for _, w := range usedWords {
		if _, ok := uniqueWords[w]; g.Config.ProhibitDuplicates && ok {
			err = fmt.Errorf("duplicate words are prohibited")
			break
		}
		uniqueWords[w] = struct{}{}
		if len(w) < g.Config.MinLength {
			err = fmt.Errorf("short word detected, all must be at least %v characters", g.Config.MinLength)
			break
		}
		if !g.WordValidator.Validate(w) {
			invalidWords = append(invalidWords, w)
		}
	}
	if len(invalidWords) > 0 {
		err = fmt.Errorf("invalid words: %v", invalidWords)
	}
	if err != nil {
		return nil, err
	}
	return usedWords, nil
}
func ( g Game ) checkWords ( pn player . Name ) ( [ ] string , error ) { p := g . players [ pn ] usedWords := p . Board . UsedTileWords ( ) var invalidWords [ ] string uniqueWords := make ( map [ string ] struct { } , len ( usedWords ) ) var err error for _ , w := range usedWords { if _ , ok := uniqueWords [ w ] ; g . Config . ProhibitDuplicates && ok { err = fmt . Errorf ( " " ) break } uniqueWords [ w ] = struct { } { } if len ( w ) < g . Config . MinLength { err = fmt . Errorf ( " " , g . Config . MinLength ) break } if ! g . WordValidator . Validate ( w ) { invalidWords = append ( invalidWords , w ) } } if len ( invalidWords ) > 0 { err = fmt . Errorf ( " " , invalidWords ) } if err != nil { return nil , err } return usedWords , nil }
checkWords returns the used words from the game and an error if the game board is not valid.
checkWords returns the used words from the game and an error if the game board is not valid .