(group *WeaponAttackMessageGroup)
| 184 | } |
| 185 | |
| 186 | func 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 | |
| 207 | func extractCombatComments(path string) map[string][]string { |
| 208 | comments := make(map[string][]string) |
no test coverage detected