コード例 #1
0
ファイル: squadron.go プロジェクト: dysolution/airstrike
// AddClones creates the specified number of Planes, each armed with the
// payload described, which can be one or more weapons.
func (s *Squadron) AddClones(clones int, client sleepwalker.RESTClient, armory ordnance.Armory, weaponNames ...string) {
	for i := 1; i <= clones; i++ {
		var arsenal ordnance.Arsenal
		name := fmt.Sprintf("clone_%d_of_%d", i, clones)
		for _, weapon := range weaponNames {
			name = fmt.Sprintf("%s_%s", name, weapon)
			arsenal = append(arsenal, armory.GetWeapon(weapon))
		}
		plane := NewPlane(name, client)
		plane.Arm(arsenal)
		s.Add(plane)
	}
}
コード例 #2
0
ファイル: squadron.go プロジェクト: dysolution/airstrike
// AddChaos creates the specified number of Planes that each have their own
// random selection of n weapons, quantified by their "deadliness."
func (s *Squadron) AddChaos(clones int, deadliness int, client sleepwalker.RESTClient, armory ordnance.Armory) {
	desc := "AddChaos"
	for i := 1; i <= clones; i++ {
		name := fmt.Sprintf("chaos_%d_of_%d", i, clones)
		plane := NewPlane(name, client)

		weaponNames := armory.GetRandomWeaponNames(deadliness)
		var arsenal ordnance.Arsenal
		for _, weaponName := range weaponNames {
			log.WithFields(map[string]interface{}{
				"plane":  name,
				"weapon": weaponName,
				"msg":    "adding weapon",
			}).Debug(desc)
			arsenal = append(arsenal, armory.GetWeapon(weaponName))
		}
		plane.Arm(arsenal)
		s.Add(plane)
	}
}