(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)
| 131 | } |
| 132 | |
| 133 | func 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 | { |
no test coverage detected