Exemple #1
0
func run() {

	nightclub.Capacity = 20

	console := console.GetPtr()
	console.AddInt("capacity", &nightclub.Capacity)

	console.Printf("-------------------------------")
	console.Printf("Night club v1.0")
	console.Printf("-------------------------------")
	console.Printf("Use help command for more info")
	console.Printf("First your need open club")

	console.AddCommand("exit", exit)
	console.AddCommand("club", openClose)
	console.AddCommand("ct", currentTrack)
	console.AddCommand("status", getHumanStatus)
	console.AddCommand("people", people)

	go func() {
		c := time.Tick(1 * time.Second)
		for now := range c {
			nightclub.DjUpdate(now)
		}
	}()

	for {
		reader := bufio.NewReader(os.Stdin)
		fmt.Print("#~: ")
		str, _ := reader.ReadString('\n')
		console.Exec(strings.Split(str, "\n")[0])

		if quit {
			break
		}
	}
}
Exemple #2
0
func (n *Nightclub) Open() {
	if n.isOpen {
		return
	}

	n.timeOpen = time.Now()
	n.trackSwitch = time.Now()
	n.curTrack = 0
	n.isOpen = true

	makePlaylist := func() {
		rap := &Music{Type: "rap", Duration: 2 * time.Minute, Name: "Wakedafucup Intro", Group: "Onyx", Album: "Wakedafucup"}
		rap2 := &Music{Type: "rap", Duration: 3 * time.Minute, Name: "Fight The Power", Group: "Public Enemy", Album: "Power To The People And The Beats - Public Enemy's Greatest Hits"}
		hiphop := &Music{Type: "hiphop", Duration: 40 * time.Second, Name: "Peter Piper", Group: "Run-D.M.C.", Album: "Raising Hell"}
		hiphop2 := &Music{Type: "hiphop", Duration: 120 * time.Second, Name: "It's Tricky", Group: "Run-D.M.C.", Album: "Raising Hell"}
		pop := &Music{Type: "pop", Duration: 70 * time.Second, Name: "Stonemilker", Group: "bjork", Album: "Vulnicura"}
		pop2 := &Music{Type: "pop", Duration: 300 * time.Second, Name: "Lionsong", Group: "bjork", Album: "Vulnicura"}
		house := &Music{Type: "house", Duration: 200 * time.Second, Name: "Give Life Back to Music", Group: "Daft Punk", Album: "Random Access Memories"}
		house2 := &Music{Type: "house", Duration: 250 * time.Second, Name: "The Game of Love", Group: "Daft Punk", Album: "Random Access Memories"}

		n.PushMusicTrack(rap)
		n.PushMusicTrack(rap2)
		n.PushMusicTrack(hiphop)
		n.PushMusicTrack(hiphop2)
		n.PushMusicTrack(pop)
		n.PushMusicTrack(pop2)
		n.PushMusicTrack(house)
		n.PushMusicTrack(house2)

		_, err := n.GenPlaylist()
		if err != nil {
			console := console.GetPtr()
			console.Printf(err.Error())
		}
	}

	makeDance := func(musicType string) (dance *Dance) {

		dance = new(Dance)
		dance.Name = musicType
		dance.MusicType = []string{musicType}

		switch musicType {
		case "hiphop":
			dance.Motions = []string{"покачивания телом вперед и назад", "ноги в полу-присяде", "руки согнуты в локтях", "головой вперед-назад"}
		case "rap":
			dance.Motions = []string{"покачивания телом вперед и назад", "ноги в полу-присяде", "руки согнуты в локтях", "головой вперед-назад"}
		case "pop":
			dance.Motions = []string{"покачивания телом вперед и назад", "ноги в полу-присяде", "руки согнуты в локтях", "головой вперед-назад"}
		case "house":
			dance.Motions = []string{"покачивания телом вперед и назад", "ноги в полу-присяде", "руки согнуты в локтях", "головой вперед-назад"}
		}

		return
	}

	makePeople := func() {
		musicTypes := []string{"rap", "hiphop", "pop", "house"}
		musicTypes_length := len(musicTypes)
		nameGen := new(vydumschik.Name)
		//		console := console.GetPtr()

		capacity := n.Capacity
		for capacity > 0 {
			gender := RandomGender()
			human := new(Human)
			human.Name = nameGen.Full_name(gender)
			human.Gender = gender
			type_size := Random(1, musicTypes_length)
			for type_size > 0 {
				musicType := musicTypes[Random(0, musicTypes_length)]
				human.PushDance(makeDance(musicType))
				type_size--
			}

			if ok := n.PushHuman(human); ok {
				//				console.Printf("added human: %s", human.Name)
			}
			capacity--
		}
	}

	makePlaylist()
	makePeople()
}