(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)
| 277 | } |
| 278 | |
| 279 | func (m *StorageModule) storageCommand(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error) { |
| 280 | |
| 281 | if !roomIsStorage(room) { |
| 282 | user.SendText(`You are not at a storage location.` + term.CRLFStr) |
| 283 | |
| 284 | if len(room.Containers) > 0 { |
| 285 | cName := `` |
| 286 | for k := range room.Containers { |
| 287 | cName = k |
| 288 | break |
| 289 | } |
| 290 | user.SendText(fmt.Sprintf(`Maybe you meant to use the <ansi fg="command">put</ansi> command to <ansi fg="command">put</ansi> something into the <ansi fg="container">%s</ansi>?`, cName) + term.CRLFStr) |
| 291 | } |
| 292 | |
| 293 | return true, nil |
| 294 | } |
| 295 | |
| 296 | data := m.storage[user.UserId] |
| 297 | itemsInStorage := data.getItems() |
| 298 | |
| 299 | if rest == `` || rest == `remove` { |
| 300 | |
| 301 | itemNames := []string{} |
| 302 | for _, item := range itemsInStorage { |
| 303 | itemNames = append(itemNames, item.NameComplex()) |
| 304 | } |
| 305 | |
| 306 | storageTxt := buildStorageText(itemNames) |
| 307 | user.SendText(storageTxt) |
| 308 | |
| 309 | return true, nil |
| 310 | } |
| 311 | |
| 312 | if rest == `add` || rest == `remove` { |
| 313 | user.SendText(fmt.Sprintf(`%s what?%s`, rest, term.CRLFStr)) |
| 314 | return true, nil |
| 315 | } |
| 316 | |
| 317 | args := util.SplitButRespectQuotes(strings.ToLower(rest)) |
| 318 | |
| 319 | if len(args) < 2 || (args[0] != `add` && args[0] != `remove`) { |
| 320 | user.SendText(`Try <ansi fg="command">help storage</ansi> for more information about storage.` + term.CRLFStr) |
| 321 | return true, nil |
| 322 | } |
| 323 | |
| 324 | action := args[0] |
| 325 | itemName := strings.Join(args[1:], ` `) |
| 326 | |
| 327 | if action == `add` { |
| 328 | |
| 329 | spaceLeft := maxItems - len(itemsInStorage) |
| 330 | if spaceLeft < 1 { |
| 331 | user.SendText(fmt.Sprintf(`You can have %d objects in storage`, maxItems)) |
| 332 | return true, nil |
| 333 | } |
| 334 | |
| 335 | if itemName == `all` { |
| 336 | for _, itm := range user.Character.GetAllBackpackItems() { |
nothing calls this directly
no test coverage detected