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

Function SaveAttackMessageGroup

internal/items/admin.go:186–205  ·  view source on GitHub ↗
(group *WeaponAttackMessageGroup)

Source from the content-addressed store, hash-verified

184}
185
186func SaveAttackMessageGroup(group *WeaponAttackMessageGroup) error {
187 basePath := util.FilePath(configs.GetFilePathsConfig().DataFiles.String() + `/combat-messages/`)
188 filePath := basePath + group.Filepath()
189
190 sectionComments := extractCombatComments(filePath)
191
192 bytes, err := yaml.Marshal(group)
193 if err != nil {
194 return fmt.Errorf("marshaling attack messages: %w", err)
195 }
196
197 bytes = insertCombatComments(bytes, sectionComments)
198
199 if err := util.WriteFile(filePath, bytes, 0644); err != nil {
200 return fmt.Errorf("writing attack messages file: %w", err)
201 }
202
203 attackMessages[group.OptionId] = group
204 return nil
205}
206
207func extractCombatComments(path string) map[string][]string {
208 comments := make(map[string][]string)

Callers 3

AddAttackMessageFunction · 0.85
UpdateAttackMessageFunction · 0.85
DeleteAttackMessageFunction · 0.85

Calls 7

FilePathFunction · 0.92
GetFilePathsConfigFunction · 0.92
WriteFileFunction · 0.92
extractCombatCommentsFunction · 0.85
insertCombatCommentsFunction · 0.85
StringMethod · 0.65
FilepathMethod · 0.65

Tested by

no test coverage detected