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

Function insertCombatComments

internal/items/admin.go:240–260  ·  view source on GitHub ↗
(data []byte, comments map[string][]string)

Source from the content-addressed store, hash-verified

238}
239
240func insertCombatComments(data []byte, comments map[string][]string) []byte {
241 if len(comments) == 0 {
242 return data
243 }
244
245 lines := strings.Split(string(data), "\n")
246 var result []string
247
248 for _, line := range lines {
249 trimmed := strings.TrimSpace(line)
250 if len(line) > 0 && line[0] != ' ' && line[0] != '\t' && trimmed != "" && strings.Contains(line, ":") {
251 key := strings.TrimSpace(line[:strings.Index(line, ":")])
252 if commentLines, ok := comments[key]; ok {
253 result = append(result, commentLines...)
254 }
255 }
256 result = append(result, line)
257 }
258
259 return []byte(strings.Join(result, "\n"))
260}
261
262// SaveItemSpec persists an existing ItemSpec back to its data file and updates
263// the in-memory cache. The ItemId must already be set.

Callers 1

SaveAttackMessageGroupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected