parseLookTarget extracts the target string from a look command input, stripping the leading "at " and "the " prefixes that the core look command also strips. Returns an empty string if the input is not a look command or has no target.
(inputText string)
| 73 | // the leading "at " and "the " prefixes that the core look command also strips. |
| 74 | // Returns an empty string if the input is not a look command or has no target. |
| 75 | func parseLookTarget(inputText string) string { |
| 76 | lower := strings.ToLower(strings.TrimSpace(inputText)) |
| 77 | |
| 78 | cmd, rest, _ := strings.Cut(lower, " ") |
| 79 | if cmd != `look` && cmd != `l` { |
| 80 | return "" |
| 81 | } |
| 82 | |
| 83 | rest = strings.TrimSpace(rest) |
| 84 | if strings.HasPrefix(rest, `at `) { |
| 85 | rest = rest[3:] |
| 86 | } |
| 87 | if strings.HasPrefix(rest, `the `) { |
| 88 | rest = rest[4:] |
| 89 | } |
| 90 | return strings.TrimSpace(rest) |
| 91 | } |
| 92 | |
| 93 | // onLookInput intercepts look commands directed at gambling fixtures before the |
| 94 | // engine's look handler runs. If the target matches a fixture present in the |