<commit_before>package moves

import (
	"github.com/jkomoros/boardgame"
	"github.com/jkomoros/boardgame/moves/auto"
)

//Combine takes a series of lists of moveTypeConfigs and flattens them into a
//single list, appropraite for being retunrned from delegate.ConfigureMoves().
func Combine(moves ...[]*boardgame.MoveTypeConfig) []*boardgame.MoveTypeConfig {

	var result []*boardgame.MoveTypeConfig

	for _, list := range moves {
		result = append(result, list...)
	}

	return result

}

//Add is designed to be used inside of Combine. It is a parallel of
//AddForPhase and AddOrderedForPhase. It doesn't actually do any processing,
//and is effectively equivalent to wrapping your config bundles in
//[]*boardgame.MoveTypeConfig{}.
func Add(moves ...*boardgame.MoveTypeConfig) []*boardgame.MoveTypeConfig {
	return moves
}

//AddForPhase is designed to be used within Combine. It calls
//WithLegalPhases() on the config for each config passed in. It's a
//convenience to make it less error-prone and more clear what the intent is
//for phase-locked moves.
func AddForPhase(phase int, moves ...*boardgame.MoveTypeConfig) []*boardgame.MoveTypeConfig {

	phaseInstaller := WithLegalPhases(phase)

	for _, move := range moves {
		phaseInstaller(move.CustomConfiguration)
	}

	return moves

}

//AddOrderedForPhase is designed to be used within Combine. It calls
//WithLegalPhases() and also WithLegalMoveProgression() on the config for each
//config passed in. It's a convenience to make it less error-prone and more
//clear what the intent is for phase-locked, ordered moves. All moveTypes
//passed must be legal auto-configurable moves.
func AddOrderedForPhase(phase int, moves ...*boardgame.MoveTypeConfig) []*boardgame.MoveTypeConfig {

	progression := make([]string, len(moves))

	for i, move := range moves {

		autoConfigMove, ok := move.MoveConstructor().(auto.AutoConfigurableMove)

		autoConfigMove.SetTopLevelStruct(autoConfigMove)

		if !ok {
			//Fail catastrophically so otheres are more likely to notice.
			return nil
		}

		progression[i] = autoConfigMove.MoveTypeName()

	}

	installer := WithLegalMoveProgression(progression)

	for _, move := range moves {
		installer(move.CustomConfiguration)
	}

	return AddForPhase(phase, moves...)

}<commit_msg>Made AddOrderedForPhase not rely on figuring out the name itself, but rather just using MoveTypeConfig that was passed to it. part of #633.<commit_after>package moves

import (
	"github.com/jkomoros/boardgame"
)

//Combine takes a series of lists of moveTypeConfigs and flattens them into a
//single list, appropraite for being retunrned from delegate.ConfigureMoves().
func Combine(moves ...[]*boardgame.MoveTypeConfig) []*boardgame.MoveTypeConfig {

	var result []*boardgame.MoveTypeConfig

	for _, list := range moves {
		result = append(result, list...)
	}

	return result

}

//Add is designed to be used inside of Combine. It is a parallel of
//AddForPhase and AddOrderedForPhase. It doesn't actually do any processing,
//and is effectively equivalent to wrapping your config bundles in
//[]*boardgame.MoveTypeConfig{}.
func Add(moves ...*boardgame.MoveTypeConfig) []*boardgame.MoveTypeConfig {
	return moves
}

//AddForPhase is designed to be used within Combine. It calls
//WithLegalPhases() on the config for each config passed in. It's a
//convenience to make it less error-prone and more clear what the intent is
//for phase-locked moves.
func AddForPhase(phase int, moves ...*boardgame.MoveTypeConfig) []*boardgame.MoveTypeConfig {

	phaseInstaller := WithLegalPhases(phase)

	for _, move := range moves {
		phaseInstaller(move.CustomConfiguration)
	}

	return moves

}

//AddOrderedForPhase is designed to be used within Combine. It calls
//WithLegalPhases() and also WithLegalMoveProgression() on the config for each
//config passed in. It's a convenience to make it less error-prone and more
//clear what the intent is for phase-locked, ordered moves. All moveTypes
//passed must be legal auto-configurable moves.
func AddOrderedForPhase(phase int, moves ...*boardgame.MoveTypeConfig) []*boardgame.MoveTypeConfig {

	progression := make([]string, len(moves))

	for i, move := range moves {

		progression[i] = move.Name

	}

	installer := WithLegalMoveProgression(progression)

	for _, move := range moves {
		installer(move.CustomConfiguration)
	}

	return AddForPhase(phase, moves...)

}
{'fraction_non_alphanumeric': 0.09750514991989014, 'fraction_numerical': 0.000686655985351339, 'mean_word_length': 4.435323383084577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5789227', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1267, 'n_words': 456}