github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/assets/how-to-guides/simple-library/tapas.gno (about)

     1  package tapas
     2  
     3  import "std"
     4  
     5  // List of tapas suggestions
     6  var listOfTapas = []string{
     7  	"Patatas Bravas",
     8  	"Gambas al Ajillo",
     9  	"Croquetas",
    10  	"Tortilla Española",
    11  	"Pimientos de Padrón",
    12  	"Jamon Serrano",
    13  	"Boquerones en Vinagre",
    14  	"Calamares a la Romana",
    15  	"Pulpo a la Gallega",
    16  	"Tostada con Tomate",
    17  	"Mejillones en Escabeche",
    18  	"Chorizo a la Sidra",
    19  	"Cazón en Adobo",
    20  	"Banderillas",
    21  	"Espárragos a la Parrilla",
    22  	"Huevos Rellenos",
    23  	"Tuna Empanada",
    24  	"Sardinas a la Plancha",
    25  }
    26  
    27  // GetTapaSuggestion randomly selects and returns a tapa suggestion
    28  func GetTapaSuggestion(userInput string) string {
    29  
    30  	// Create a random number depending on the block height.
    31  	// We get the block height using std.GetHeight(), which is from an imported Gno library, "std"
    32  	// Note: this value is not fully random and is easily guessable
    33  	randomNumber := int(std.GetHeight()) % len(listOfTapas)
    34  
    35  	// Return the random suggestion
    36  	return listOfTapas[randomNumber]
    37  }