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

Method onLookInput

modules/gambling/gambling.go:97–129  ·  view source on GitHub ↗

onLookInput intercepts look commands directed at gambling fixtures before the engine's look handler runs. If the target matches a fixture present in the room, it sends the description directly and cancels the event so the engine does not process it further.

(e events.Event)

Source from the content-addressed store, hash-verified

95// room, it sends the description directly and cancels the event so the engine
96// does not process it further.
97func (g *GamblingModule) onLookInput(e events.Event) events.ListenerReturn {
98 evt, ok := e.(events.Input)
99 if !ok || evt.UserId == 0 {
100 return events.Continue
101 }
102
103 target := parseLookTarget(evt.InputText)
104 if target == "" {
105 return events.Continue
106 }
107
108 user := users.GetByUserId(evt.UserId)
109 if user == nil {
110 return events.Continue
111 }
112
113 room := rooms.LoadRoom(user.Character.RoomId)
114 if room == nil {
115 return events.Continue
116 }
117
118 if _, c := util.FindMatchIn(target, `slot machine`, `slots`, `slot`); c != `` && roomHasSlots(room) {
119 g.sendLookDescription(user, room, `slot machine`, g.slotMachineNounDesc(room.RoomId))
120 return events.Cancel
121 }
122
123 if _, c := util.FindMatchIn(target, `claw machine`, `claw`); c != `` && roomHasClaw(room) {
124 g.sendLookDescription(user, room, `claw machine`, g.clawMachineNounDesc())
125 return events.Cancel
126 }
127
128 return events.Continue
129}
130
131// sendLookDescription sends a noun look response matching the framing used by
132// the core look command: blank line, "You look at the <noun>:", blank line,

Callers

nothing calls this directly

Calls 9

sendLookDescriptionMethod · 0.95
slotMachineNounDescMethod · 0.95
clawMachineNounDescMethod · 0.95
GetByUserIdFunction · 0.92
LoadRoomFunction · 0.92
FindMatchInFunction · 0.92
roomHasSlotsFunction · 0.85
roomHasClawFunction · 0.85
parseLookTargetFunction · 0.70

Tested by

no test coverage detected