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

Function SaveSpellSpec

internal/spells/admin.go:12–32  ·  view source on GitHub ↗
(spec *SpellData)

Source from the content-addressed store, hash-verified

10)
11
12func SaveSpellSpec(spec *SpellData) error {
13 if spec.SpellId == "" {
14 return fmt.Errorf("cannot save spell with empty SpellId")
15 }
16
17 if err := spec.Validate(); err != nil {
18 return err
19 }
20
21 saveModes := []fileloader.SaveOption{}
22 if configs.GetFilePathsConfig().CarefulSaveFiles {
23 saveModes = append(saveModes, fileloader.SaveCareful)
24 }
25
26 if err := fileloader.SaveFlatFile[*SpellData](configs.GetFilePathsConfig().DataFiles.String()+`/spells`, spec, saveModes...); err != nil {
27 return err
28 }
29
30 allSpells[spec.SpellId] = spec
31 return nil
32}
33
34func DeleteSpellSpec(spellId string) error {
35 spec := GetSpell(spellId)

Callers 2

apiV2CreateSpellFunction · 0.92
apiV2PatchSpellFunction · 0.92

Calls 3

GetFilePathsConfigFunction · 0.92
ValidateMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected