pokesay

package
v0.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Rand rand.Source = rand.NewSource(time.Now().UnixNano())
)

Functions

func ChooseByCategory added in v0.11.0

func ChooseByCategory(category string, categoryDir []fs.DirEntry, categoryFiles embed.FS, categoryRootDir string, metadataFiles embed.FS, metadataRootDir string) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping)

ChooseByCategory chooses a pokemon via a requested category 1. It loads the category search structure and finds the name of a random Pokemon matching the entry e.g. if given the category "small", this function might pick the file `1.cat` in - categories/

  • small/
  • 1.cat
  • 44.cat

This file contains entries representing the <pokemon metadata index>/<the pokemon entry index>, e.g. "4/1" would represent 4.metadata, and the 2nd entry in that file 2. Using the indexes, load the corresponding metadata file and entry, and then return it

func ChooseByName added in v0.11.0

func ChooseByName(names map[string][]int, nameToken string, metadataFiles embed.FS, metadataRootDir string) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping)

func ChooseByNameAndCategory added in v0.12.2

func ChooseByNameAndCategory(names map[string][]int, nameToken string, metadataFiles embed.FS, metadataRootDir string, category string) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping)

func ChooseByRandomIndex added in v0.11.0

func ChooseByRandomIndex(totalInBytes []byte) (int, int)

func ListNames added in v0.11.3

func ListNames(names map[string][]int) []string

func Print added in v0.11.0

func Print(args Args, choice int, names []string, categories []string, cows embed.FS)

The main print function! This uses a chosen pokemon's index, names and categories, and an embedded filesystem of cowfile data 1. The text received from STDIN is printed inside a speech bubble 2. The cowfile data is retrieved using the matching index, decompressed (un-gzipped), 3. The pokemon is printed along with the name & category information

func RandomInt

func RandomInt(n int) int

Types

type Args added in v0.11.0

type Args struct {
	Width          int
	NoWrap         bool
	TabSpaces      string
	NoTabSpaces    bool
	NoCategoryInfo bool
	ListCategories bool
	ListNames      bool
	Category       string
	NameToken      string
	JapaneseName   bool
	BoxCharacters  *BoxCharacters
	DrawInfoBorder bool
	Help           bool
	Verbose        bool
}

type BoxCharacters added in v0.12.0

type BoxCharacters struct {
	HorizontalEdge    string
	VerticalEdge      string
	TopRightCorner    string
	TopLeftCorner     string
	BottomRightCorner string
	BottomLeftCorner  string
	BalloonString     string
	Separator         string
	RightArrow        string
	CategorySeparator string
}
var (
	AsciiBoxCharacters *BoxCharacters = &BoxCharacters{
		HorizontalEdge:    "-",
		VerticalEdge:      "|",
		TopRightCorner:    "\\",
		TopLeftCorner:     "/",
		BottomRightCorner: "/",
		BottomLeftCorner:  "\\",
		BalloonString:     "\\",
		Separator:         "|",
		RightArrow:        ">",
		CategorySeparator: "/",
	}
	UnicodeBoxCharacters *BoxCharacters = &BoxCharacters{
		HorizontalEdge:    "─",
		VerticalEdge:      "│",
		TopRightCorner:    "╮",
		TopLeftCorner:     "╭",
		BottomRightCorner: "╯",
		BottomLeftCorner:  "╰",
		BalloonString:     "╲",
		Separator:         "│",
		RightArrow:        "→",
		CategorySeparator: "/",
	}
	SingleWidthCars map[string]bool = map[string]bool{
		"♀": true,
		"♂": true,
	}
)

func DetermineBoxCharacters added in v0.12.0

func DetermineBoxCharacters(unicodeBox bool) *BoxCharacters

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL