(mobInstanceId int, inputText string)
| 602 | } |
| 603 | |
| 604 | func (w *World) processMobInput(mobInstanceId int, inputText string) { |
| 605 | // No need to select the channel this way |
| 606 | |
| 607 | mob := mobs.GetInstance(mobInstanceId) |
| 608 | if mob == nil { // Something went wrong. User not found. |
| 609 | if !mobs.RecentlyDied(mobInstanceId) { |
| 610 | mudlog.Error("Mob not found", "mobId", mobInstanceId, "where", "processMobInput()") |
| 611 | } |
| 612 | return |
| 613 | } |
| 614 | |
| 615 | command := "" |
| 616 | remains := "" |
| 617 | |
| 618 | handled := false |
| 619 | var err error |
| 620 | |
| 621 | if len(inputText) > 0 { |
| 622 | |
| 623 | if index := strings.Index(inputText, " "); index != -1 { |
| 624 | command, remains = strings.ToLower(inputText[0:index]), inputText[index+1:] |
| 625 | } else { |
| 626 | command = inputText |
| 627 | } |
| 628 | |
| 629 | //mudlog.Info("World received mob input", "InputText", (inputText)) |
| 630 | |
| 631 | handled, err = mobcommands.TryCommand(command, remains, mobInstanceId) |
| 632 | if err != nil { |
| 633 | mudlog.Warn("mob-TryCommand", "command", command, "remains", remains, "error", err.Error()) |
| 634 | } |
| 635 | |
| 636 | } |
| 637 | |
| 638 | if !handled { |
| 639 | if len(command) > 0 { |
| 640 | mob.Command(fmt.Sprintf(`emote looks a little confused (%s %s).`, command, remains)) |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | } |
| 645 | |
| 646 | func (w *World) UpdateStats() { |
| 647 | s := web.GetStats() |
no test coverage detected