Allow renaming of extracted stats via tag.
This commit is contained in:
		| @@ -138,6 +138,10 @@ func (s statFunc[T]) Visible() bool { | ||||
| // start of another word, if it's not at the end). To insert a space between | ||||
| // consecutive capital letters, insert an underscore (`_`). This name inference | ||||
| // trims "Stat" and "HiddenStat" off the front of method names. | ||||
| // | ||||
| // To override the name extracted from a field name, add `cardsim_name:"name"` | ||||
| // to the tag, where the name part is the name you want to use. It will not be | ||||
| // formatted further - use normal spaces, capitalization, etc. | ||||
| func ExtractStats(x any) []Stat { | ||||
| 	v := reflect.ValueOf(x) | ||||
| 	for k := v.Kind(); k == reflect.Pointer || k == reflect.Interface; k = v.Kind() { | ||||
| @@ -248,6 +252,9 @@ func ExtractStats(x any) []Stat { | ||||
| 				continue // not identifiably a stat | ||||
| 			} | ||||
| 			nm := strings.Join(explode(sf.Name), " ") | ||||
| 			if t := sf.Tag.Get("cardsim_name"); t != "" { | ||||
| 				nm = t | ||||
| 			} | ||||
| 			if known[nm] { | ||||
| 				continue | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user