Make hat selection a variable

This commit is contained in:
Ryan Cavicchioni 2021-07-27 00:34:53 -05:00
parent df49dcb9ea
commit a35901b976
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D

View File

@ -66,6 +66,9 @@ func HatQueryToHatQueryModel(q *pb.HatQuery) HatQuery {
}
func (s *Server) MakeHat(ctx context.Context, size *pb.Size) (hat *pb.Hat, err error) {
var colors []string = []string{"white", "black", "red", "blue", "white"}
var names []string = []string{"bowler", "baseball cap", "top hat", "derby", "tricorne"}
st, _ := NewStore(s.DBPath, 0600, nil)
defer st.Close()
@ -75,8 +78,8 @@ func (s *Server) MakeHat(ctx context.Context, size *pb.Size) (hat *pb.Hat, err e
h := Hat{
Inches: size.Inches,
Color: []string{"white", "black", "red", "blue"}[rand.Intn(4)],
Name: []string{"bowler", "baseball cap", "top hat", "derby"}[rand.Intn(3)],
Color: colors[rand.Intn(len(colors))],
Name: names[rand.Intn(len(names))],
}
fmt.Printf("made hat: %+v\n", h)