MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / onGetFormattedName

Method onGetFormattedName

modules/elections/elections.go:998–1018  ·  view source on GitHub ↗

onGetFormattedName appends the player's title (if any) to their formatted name.

(f characters.FormattedName)

Source from the content-addressed store, hash-verified

996
997// onGetFormattedName appends the player's title (if any) to their formatted name.
998func (m *ElectionsModule) onGetFormattedName(f characters.FormattedName) characters.FormattedName {
999 if f.Type != `username` {
1000 return f
1001 }
1002
1003 for _, w := range m.state.Winners {
1004 if strings.EqualFold(w.CharacterName, f.Name) {
1005 color := m.titleColor()
1006 if len(color) > 0 {
1007 if num, err := strconv.Atoi(color); err == nil {
1008 f.Title = fmt.Sprintf(`<ansi fg="%d">%s</ansi>`, num, w.Title)
1009 } else {
1010 f.Title = colorpatterns.ApplyColorPattern(w.Title, color)
1011 }
1012 }
1013 return f
1014 }
1015 }
1016
1017 return f
1018}

Callers

nothing calls this directly

Calls 2

titleColorMethod · 0.95
ApplyColorPatternFunction · 0.92

Tested by

no test coverage detected