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

Method processMobInput

world.go:604–644  ·  view source on GitHub ↗
(mobInstanceId int, inputText string)

Source from the content-addressed store, hash-verified

602}
603
604func (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
646func (w *World) UpdateStats() {
647 s := web.GetStats()

Callers 1

HandleInputEventsMethod · 0.95

Calls 6

GetInstanceFunction · 0.92
RecentlyDiedFunction · 0.92
ErrorFunction · 0.92
TryCommandFunction · 0.92
WarnFunction · 0.92
CommandMethod · 0.45

Tested by

no test coverage detected