Skip to content
Snippets Groups Projects
Commit b73030d5 authored by David Thompson's avatar David Thompson
Browse files

Add simple barista bot.

parent 73877db6
No related branches found
No related tags found
No related merge requests found
......@@ -77,19 +77,19 @@
(profile (spawn ^profile identity))
(entity (spawn ^entity profile))
(controller (spawn ^controller hub entity))
(event-handler (spawn ^event-handler controller))
(event-handler (spawn ^event-handler profile controller))
(bot (make-bot identity profile entity controller)))
($ entity 'set-event-handler event-handler)
(<-np controller 'enter room)
(add-bot! scheme-name bot))))
(define (^dice-roller _bcom controller)
(define (^dice-roller _bcom _profile controller)
(match-lambda
(('direct from 'roll-dice)
(let-on ((from-profile (<- from 'profile)))
(let ((roll-1 (+ (random 6) 1))
(roll-2 (+ (random 6) 1)))
(<-np controller 'emote "rolls the dice")
(<-np controller 'emote "rolls the dice.")
(<-np controller 'say (list from-profile " rolled a " roll-1
" and a " roll-2 ".")))))
(('direct from args ...)
......@@ -98,6 +98,34 @@
from-profile ". Try 'roll-dice'."))))
(_ #f)))
(define (^barista _bcom profile controller)
(match-lambda
(('direct from 'talk)
(let-on ((from-profile (<- from 'profile)))
(<-np controller 'emote
(list "notices " from-profile " approach the counter."))
(<-np controller 'say
(list "Hello, " from-profile ". What would you like to order today?"))
(<-np controller 'say
(list "We have coffee or tea. We're a simple shop."))))
(('direct from 'order item)
(let-on ((from-profile (<- from 'profile)))
(let ((name (match item
((or 'coffee 'Coffee 'COFFEE "coffee" "Coffee" "COFFEE")
"coffee")
((or 'tea 'Tea 'TEA "tea" "Tea" "TEA")
"tea")
(_ #f))))
(if name
(begin
(<-np controller 'say
(list "One " name " for " from-profile " coming right up!"))
(<-np controller 'emote
(list "hands " from-profile " a piping hot cup of " name "."))
(<-np controller 'say "Too bad we don't have inventory implemented or you could take that with you."))
(<-np controller 'say (list "Sorry " from-profile ", we don't have that."))))))
(_ #f)))
(define (run-server port)
(format #t "Generating TLS certs (if not present)\n")
(generate-tls-cert-maybe! tls-key-file-name tls-cert-file-name)
......@@ -116,6 +144,7 @@
(spawn ^hub lobby)))
(format #t "Spawning bots\n")
(spawn-bot! 'dice-roller "DiceRoller" ^dice-roller hub lobby)
(spawn-bot! 'barista "Barista" ^barista hub cafe)
(format #t "Spawning OCapN\n")
(define tcp-netlayer
(with-vat machine-vat
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment