blob: d4d2e726ab7faa40aaac95f68176530b7bcf2d92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package game
import (
"fmt"
"strings"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
)
func (g *Game) doSearch(sess *net.Session, input string) {
p := sess.Player.(*player.Player)
g.CancelAction(p)
lower := strings.ToLower(strings.TrimSpace(input))
if lower == "" {
sess.WriteLine("Search what?")
return
}
matches := g.findInventoryMatches(lower, p)
if len(matches) == 0 {
sess.WriteLine(fmt.Sprintf("You don't have any '%s' to search.", input))
return
}
unique := uniqueItemNames(matches)
if len(unique) > 1 {
sess.WriteLine("Which one?")
for _, name := range unique {
sess.WriteLine(fmt.Sprintf(" - %s", name))
}
return
}
itemID := matches[0].ID
slotIdx := matches[0].Slot
g.startSearch(sess, p, itemID, slotIdx)
}
|