generator

package
v0.0.0-...-fe4d5e4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 8 Imported by: 0

README

Generator Function

  • Generate folders based on Species keys
  • Create text file if they DNE (example)
  • Once the structure for all species and genders are created, parse all text files according to the species in the yaml file.
  • Some species might have 'special names' - I'm thinking Tabaxi Clans - there might be others - another example could be other species from specific areas 'Alice Doe of Baulder's Gate' (of Baulders Gate) could be a special name. These names would appear after last names.

This has been updated - special names will be used for tabaxi and tiefling. I'm sure there are other species that might have special names, but "of Baulder's Gate" will come from a location.yaml file. This way DMs can customize NPC names based on locations in their own world!

  • I need to scrape - or scour the internet for more names to add to the various species text files.
  • Contributing Guidelines - I'm thinking if someone wants to add a new species to the list, they need to provide some minimum number of names for the species in the pull request. 300 minimum per gender before merging with master branch. It's not enough to add a species and leave out data that is usable.
  • Write code to generate GoLang Species DataTypes, per Species based on the Species yaml keys in generator/names.yaml
  • I may want to have an generator/output.yaml -for after parsing all the text files - for debugging when creating GoLang Structs (generated code)
  • figure out how to create a template that can be used in the cmd package that will automatically add new species as flags for cobra/viper (this will be challenging). I might just have to do this manually, though it would be really nice to have this be an automated, generated task. I need to read more docs on Go Templates. This would need to modify the cmd/root.go - or generate the init function, which might need to move to another seperate go file (cmd/init.go) - this might not be so tough.
  • The output will be an joined string array ["First - Gendered", "Last", "Special"]. Think about how I could merge species, for example:
# proof of concept
dnd-names species dragonborn male --number 20;
  • Special Names should be specified in the CLI. It's not a priority right now. if --male --dragonborn is picked, Asume --last --dragonborn.
  • Last, but not least, perhaps i can look into creating a web assembly module for node or vinalla JS integration. o.O

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnableDebug bool
View Source
var NamesList = []string{} // List of names for DnD characters

/* 7727 elements not displayed */

Functions

func AlphabetizeAndTrimFile

func AlphabetizeAndTrimFile(filepath string, species SpeciesInfo) ([]string, error)

AlphabetizeAndTrimFile reads a text file, sorts lines alphabetically, trims whitespace, and rewrites the file and returns the sorted species data as a slice of strings

func Generate

func Generate(enableDebug bool) error

Generate the names.go file by reading names from a file

func GenerateSpecies

func GenerateSpecies(speciesStructure []SpeciesInfo) error

Generate cmd/species/species.go file species template files

Types

type Names

type Names struct {
	PackageName string
	Names       []string
}

Names represents the data used for generating the file

type NamesTypes

type NamesTypes struct {
	FirstFNames  []string `yaml:"FirstFNames,omitempty"`  // Field for list
	FirstMNames  []string `yaml:"FirstMNames,omitempty"`  // Field for list
	FirstNBNames []string `yaml:"FirstNBNames,omitempty"` // Field for list
	Special      []string `yaml:"Special,omitempty"`      // Field for list
	Last         []string `yaml:"Last,omitempty"`         // Field for list
}

type SpeciesData

type SpeciesData struct {
	// Other fields in the struct (if any)
	Species                 *[]SpeciesInfo `yaml:"Species"`                           // Assuming data comes from a YAML file
	GenericSpeciesInterface string         `yaml:"GenericSpeciesInterface,omitempty"` // Field for generic species interface
}

type SpeciesInfo

type SpeciesInfo struct {
	NameOfSpecies      string     `yaml:"NameOfSpecies"`             // Field for species name
	GlobalVariableName string     `yaml:"GlobalVariableName"`        // Field for global variable name
	NameOrder          []string   `yaml:"NameOrder,omitempty"`       // Field for order of names
	Variable           string     `yaml:"Variable,omitempty"`        // Field for your string value
	CommandVariable    string     `yaml:"CommandVariable,omitempty"` // Field for your string value
	TextFileNames      []string   `yaml:"TextFileNames,omitempty"`   // Field for list of text files
	Names              NamesTypes `yaml:"Names,omitempty"`           // Field for list of names

}

func OrgnaizeSpeciesData

func OrgnaizeSpeciesData(speciesStructure []SpeciesInfo) ([]SpeciesInfo, error)

OrgnaizeSpeciesData function organizes an array of SpeciesInfo structs by looping throught each SpeciesInfo.TextFileNames and passing the files to AlphabetizeAndTrimFile

func ProcessSpeciesDataForFolderStructredTextData

func ProcessSpeciesDataForFolderStructredTextData(speciesMap map[string]interface{}) (speciesStructure []SpeciesInfo, error error)

ProcessSpeciesData function processes the provided YAML data and creates folders and text files

func ProcessYAMLAndCreateFiles

func ProcessYAMLAndCreateFiles(filePath string) (SpeciesStructure []SpeciesInfo, error error)

ProcessYAMLAndCreateFiles function opens, parses YAML data and creates folders/files

Jump to

Keyboard shortcuts

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