Exemplo n.º 1
0
func end_stats(stats *Stats, well *Well, max_stats int, db *sql.DB) {

	fmt.Printf("score     : %d\n", stats.score)
	fmt.Printf("rows      : %d\n", stats.rows)
	fmt.Printf("top speed : %d\n", get_speed(stats))
	fmt.Printf("pieces    : %d\n", stats.p_count)
	fmt.Print("\n")

	ShowSet := pieces.SetBasic()
	if stats.piece_set["extd"] == true {
		ExtendedSet := pieces.SetExtended()
		for t_num := range ExtendedSet {
			ShowSet = append(ShowSet, ExtendedSet[t_num])
		}
	}

	for _, value := range ShowSet {
		if stats.p_types[value.Name] > 0 {
			fmt.Printf("%- 7s  : %d\n", value.Name, stats.p_types[value.Name])
		}
	}

	timenow := update_db(stats, well, max_stats, db)
	show_db_scores(stats, well, db, timenow)

}
Exemplo n.º 2
0
func rand_piece(this_piece *Tetronimo, stats *Stats) {

	rand.Seed(time.Now().Unix())

	BasicSet := pieces.SetBasic()
	ExtendedSet := pieces.SetExtended()

	FullSet := BasicSet
	for t_num := range ExtendedSet {
		FullSet = append(FullSet, ExtendedSet[t_num])
	}

	// this logic favors pieces from basic set
	ChosenSet := BasicSet
	if stats.piece_set["extd"] == true {
		rand_set := rand.Intn(2)
		if rand_set == 1 {
			ChosenSet = FullSet
		}
	}

	rand_piece := rand.Intn(len(ChosenSet))

	b_count := 4 // assume always tetro for now
	chosen_piece := ChosenSet[rand_piece]
	copy_shape(chosen_piece.Shape, this_piece.shape)

	piece_name := chosen_piece.Name

	stats.p_count += 1
	stats.b_count += b_count
	stats.t_types[rand_piece] += 1
	stats.p_types[piece_name] += 1
	stats.current = piece_name

}
Exemplo n.º 3
0
func show_stats(stats *Stats, well *Well) {

	well_depth := len(well.debris_map)
	_, term_row := tb.Size()
	vert_headroom := int((term_row-well_depth)/2) - 1

	print_tb(0, vert_headroom+0, 0, 0, fmt.Sprintf("score  : %d", stats.score))
	print_tb(0, vert_headroom+1, 0, 0, fmt.Sprintf("rows   : %d", stats.rows))
	print_tb(0, vert_headroom+2, 0, 0, fmt.Sprintf("speed  : %d", get_speed(stats)))
	print_tb(0, vert_headroom+3, 0, 0, fmt.Sprintf("pieces : %d", stats.p_count))
	print_tb(0, vert_headroom+4, 0, 0, fmt.Sprintf("blocks : %d", stats.b_count))

	ShowSet := pieces.SetBasic()
	if stats.piece_set["extd"] == true {
		ExtendedSet := pieces.SetExtended()
		for t_num := range ExtendedSet {
			ShowSet = append(ShowSet, ExtendedSet[t_num])
		}
	}

	p_row := vert_headroom + 6
	for _, value := range ShowSet {
		if p_row >= term_row {
			break
		}
		star := " "
		if stats.current == value.Name {
			star = "*"
		}
		if stats.p_types[value.Name] > 0 {
			print_tb(0, p_row, 0, 0, fmt.Sprintf("%- 7s: %d %s", value.Name, stats.p_types[value.Name], star))
			p_row += 1
		}
	}

}