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

Function spell_Create

internal/usercommands/admin.spell.go:133–346  ·  view source on GitHub ↗
(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)

Source from the content-addressed store, hash-verified

131}
132
133func spell_Create(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error) {
134
135 var newSpell = spells.SpellData{}
136
137 if len(rest) > 0 {
138 if spellId := spells.FindSpell(rest); spellId != `` {
139 newSpell = *(spells.GetSpell(spellId))
140 }
141 }
142
143 // Get if already exists, otherwise create new
144 cmdPrompt, isNew := user.StartPrompt(`spell create`, rest)
145
146 if isNew {
147 user.SendText(``)
148 user.SendText(fmt.Sprintf(`Lets get a little info first.%s`, term.CRLFStr))
149 }
150
151 //
152 // Name Selection
153 //
154 {
155 question := cmdPrompt.Ask(`What will the spell be called?`, []string{newSpell.Name}, newSpell.Name)
156 if !question.Done {
157 return true, nil
158 }
159
160 if question.Response == `` {
161 user.SendText("Aborting...")
162 user.ClearPrompt()
163 return true, nil
164 }
165
166 newSpell.Name = question.Response
167 }
168
169 //
170 // Id Selection
171 //
172 {
173 question := cmdPrompt.Ask(`What will the spell's unique id be (single-word)? This can also be used as an alias to cast the spell.`, []string{newSpell.SpellId}, newSpell.SpellId)
174 if !question.Done {
175 return true, nil
176 }
177
178 if question.Response == `` {
179 user.SendText("Aborting...")
180 user.ClearPrompt()
181 return true, nil
182 }
183
184 newSpell.SpellId = question.Response
185 }
186
187 //
188 // Description
189 //
190 {

Callers 1

SpellFunction · 0.85

Calls 12

FindSpellFunction · 0.92
GetSpellFunction · 0.92
ProcessFunction · 0.92
SpellTypeTypeAlias · 0.92
CreateNewSpellFileFunction · 0.92
StartPromptMethod · 0.80
AskMethod · 0.80
ClearPromptMethod · 0.80
RejectResponseMethod · 0.80
FilepathMethod · 0.65
SendTextMethod · 0.45
GetScriptPathMethod · 0.45

Tested by

no test coverage detected