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

Function extractCombatComments

internal/items/admin.go:207–238  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

205}
206
207func extractCombatComments(path string) map[string][]string {
208 comments := make(map[string][]string)
209
210 data, err := os.ReadFile(path)
211 if err != nil {
212 return comments
213 }
214
215 lines := strings.Split(string(data), "\n")
216 var pending []string
217
218 for _, line := range lines {
219 trimmed := strings.TrimSpace(line)
220
221 if trimmed == "" || strings.HasPrefix(trimmed, "#") {
222 pending = append(pending, line)
223 continue
224 }
225
226 if len(line) > 0 && line[0] != ' ' && line[0] != '\t' && strings.Contains(line, ":") {
227 key := strings.TrimSpace(line[:strings.Index(line, ":")])
228 if len(pending) > 0 {
229 comments[key] = append([]string{}, pending...)
230 pending = nil
231 }
232 } else {
233 pending = nil
234 }
235 }
236
237 return comments
238}
239
240func insertCombatComments(data []byte, comments map[string][]string) []byte {
241 if len(comments) == 0 {

Callers 1

SaveAttackMessageGroupFunction · 0.85

Calls 1

ReadFileMethod · 0.45

Tested by

no test coverage detected