Dave the Bartender

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Dave the Bartender

@create Dave the Bartender
@lock/Basic Dave the Bartender==me
@lset Dave the Bartender/Basic=no_inherit
@set Dave the Bartender = !NO_COMMAND
@set Dave the Bartender = MONITOR
&CMD_MENU Dave the Bartender=$menu:@pemit %#=[ansi(h,Drinks)]:%r[u(tabulate_menu,v(drinks))]%r%r[ansi(h,Cocktails)]:%r[u(tabulate_menu,v(cocktails))]%r%r[ansi(h,Containers)]:%r[u(tabulate_menu,v(containers))]%r%r[ansi(h,Sizes)]:%r[u(tabulate_menu,v(sizes))]%r%rTo order a drink, [ansi(h,order <drink or cocktail>)]. You can create more complex custom drinks as well, type [ansi(h,order)] with no arguments to see how.
&CMD_ORDER Dave the Bartender=$order *:@assert u(order_args,%0)=@pemit %#=That's not a valid order. To see the menu, type [ansi(h,menu)], and to learn about ordering complex drinks type [ansi(h,order)].;think setq(0,u(make_drink,%qb,%qa,%qe,%qc,%qd,%qf));say Okay, %n, I'll have your order ready in a second.;@wait 10={give %q0 to %#; @oemit %#=[name(%!)] gives [name(%q0)] to %n.; say Share and enjoy!}
&CMD_ORDER0 Dave the Bartender=$order:@pemit %#=To order a custom cocktail, [ansi(h,order <drink or cocktail1> and <drink or cocktail2>)] or [ansi(h,order <drink or cocktail1>, <drink or cocktail2>, ..., and <drink or cocktailn>)].%rTo order a cocktail without an included drink (or any of the contents of a particular cocktail), [ansi(h,order <drink or cocktail>, without <undesired drink or cocktail>)] or (for multiple undesired drinks or cocktails) [ansi(h,order <cocktail> without <drink or cocktail1>, <drink or cocktail2>, ..., or <drink or cocktailn>)].%rTo order a drink in a certain size, [ansi(h,order <size> <drink or cocktail>)].%rTo order a drink in a certain container, [ansi(h,order <container> of <drink or cocktail>)].%r To order a drink of a certain color, [ansi(h, order <color> colored <drink or cocktail>)], where [ansi(h,<color>)] is a valid [ansi(h,ANSI\(\))] code.%rYou can combine the various types of arguments as you wish. If you don't specify a size or container, by default the size and/or container of the first drink listed is used.%r%rExamples:%r%b%border small plastic cup of xb colored rum and coke%r%b%border flute of martini, brandy, sazerac and wine without gin or absinthe%r%rYou can also [ansi(h,recommend <new cocktail> using <arguments>)], where [ansi(h,<new cocktail>)] is the name of a new cocktail you want to create, and [ansi(h,<arguments>)] are the default arguments to "drink" that would create the cocktail.%r%rExample:%r%b%brecommend martini using glass of hm colored gin and vermouth
&CMD_RECOMMEND Dave the Bartender=$recommend * using *:@assert [u(valid_cocktail,%0)]=@pemit %#=Sorry, that's not a valid cocktail name.;@assert [u(order_args,%1)]=@pemit %#=That's not a valid order. To see the menu, type [ansi(h,menu)], and to learn about ordering complex drinks type [ansi(h,order)].;@set me=cocktails:[setunion(v(cocktails),squish(%0)\:%qf:%qe:%qa:%qc,|)];say Thanks for the recommendation, %n!;pose has learned a new recipe: %0.
&COCKTAILS Dave the Bartender=dry martini:hy:glass:small:gin|Irish coffee:y:glass::whiskey,coffee|Long Island Iced Tea:c:glass:tall:vodka,tequila,rum,gin,triple sec,sweet n' sour mix,soda,ice|martini:hm:glass::gin,vermouth|punch:hr:plastic cup::pink|sazerac:r:glass::rye,absinthe,pernod|wisdom:hc:glass::water
&COLORATE Dave the Bartender=letq(0,grab(%0,%1:*,|),ansi(u(menu_color,%q0),u(menu_name,%q0)))
&CONTAINERS Dave the Bartender=can:w|flute:m|glass:hc|goblet:hy|mug:h|plastic cup:br|shot:gb|snifter:hg
&DESCRIBE Dave the Bartender=A happy-go-lucky guy, he sits behind the bar and takes orders for drinks.%r%rTo see what drinks are available, type [ansi(h,menu)].
@set Dave the Bartender/DESCRIBE=no_command visual prefixmatch public nearby
&DRINKS Dave the Bartender=absinthe:g:shot|apple juice:hr:glass|beer:y:mug|brandy:hx:glass|champagne:hg:flute|cider:hg:mug|coffee:r:mug|cognac:hm:glass|coke:r:can|gin:hy:glass|ice:hw:glass|Irish cream:hx:mug|lager:r:mug|liqueur:b:shot|orange juice:hy:glass|pernod:hg:shot|pink lemonade:hm:plastic cup|Red Bull:hr:can|rum:m:shot|rye:r:glass|scotch:y:shot|soda:g:can|starfruit juice:hy:glass|sweet n' sour mix:m:glass:small|tequila:g:shot|tonic:hc:glass|triple sec:c:shot|vermouth:g:shot|vodka:g:shot|water:hc:glass|whiskey:y:glass|wine:hm:glass
&FIND_DRINK Dave the Bartender=switch(grab(v(drinks),%0:*,|),?*,%$0,grab(v(cocktails),%0:*,|))
&MAKE_DRINK Dave the Bartender=[setq(1,[if(%1,art(%1) %1%b,art(%2)%b)]%2 of %0)][setq(0,create(%q1))][setq(2,This [if(%1,[u(colorate,v(sizes),%1)]%b)][u(colorate,v(containers),%2)] is [lit([if(lt(v(charges),3),[fraction(fdiv(inc(v(charges)),4))]%b)])]full of [ansi(%5,%0)]. [if(%4,It was made without [itemize(iter(%4,u(colorate,v(drinks),%i0),\,,\,),\,,or)].)] To drink up\, type [ansi(h,use %q1)].%r%rIngredients list: [itemize(iter(%3,u(colorate,v(drinks),%i0),\,,\,),\,)].)][setq(3,You drink deeply from [if(%1,art(%1) [u(colorate,v(sizes),%1)]%b,art(%2)%b)][u(colorate,v(containers),%2)] of [ansi(%5,%0)].)][setq(4,drinks deeply from [if(%1,art(%1) [u(colorate,v(sizes),%1)]%b,art(%2)%b)][u(colorate,v(containers),%2)] of [ansi(%5,%0)].)][setq(5,@emit The empty [u(colorate,v(containers),%2)] falls to the ground and disappears.;@teleport me=%!;@recycle me)][name(%q0,%q1)][attrib_set(%q0/describe,%q2)][attrib_set(%q0/charges,3)][attrib_set(%q0/use,%q3)][attrib_set(%q0/ouse,%q4)][attrib_set(%q0/runout,%q5)][tel(%q0,me)]%q0
&MENU_COLOR Dave the Bartender=extract(%0,2,1,:)
&MENU_CONTAINER Dave the Bartender=extract(%0,3,1,:)
&MENU_DRINKS Dave the Bartender=extract(%0,5,1,:)
&MENU_NAME Dave the Bartender=before(%0,:)
&MENU_SIZE Dave the Bartender=extract(%0,4,1,:)
&ON_CONNECT Dave the Bartender=^* has connected.:say Welcome, %n!;@pemit %#=Type [ansi(h,menu)] to see what I'm offering today.
&ORDER_ARGS Dave the Bartender=setq(0,[letq(0,[map(menu_name,v(drinks),|)]|[map(menu_name,v(cocktails),|)],regmatchi(%0,^(?>([map(menu_name,v(sizes),|)])%b)?(?>([map(menu_name,v(containers),|)]) of )?(?>(\[fhuindxrgybmcwFHUIDXRGYBMCW\]+) colored )?(%q0)((?>(?>\,%b?(?>%q0))+(?>\,%b?|%b)|%b)and (?>%q0))?(?> without ((?>%q0)(?>(?>(?>\,%b?(?>%q0))+(?>\,%b?|%b)|%b)or (?>%q0))?))?$,1:a 4:b 5:c 6:d 2:e 3:f))])[if(%q0,letq(0,u(find_drink,%qb),setq(a,if(%qa,if(eq(0,comp(%qa,regular)),,%qa),u(menu_size,%q0)),b,letq(1,[if(cor(%qd,%qf),modified%b)]%qb[if(cor(%qc,%qd),%bcocktail)],[if(cor(%qc,%qd,member(v(cocktails),%q0,\,)),art(%q1)%b)]%q1),c,u(unitemize,\,%qb%qc,and),d,delete(fold(#lambda/strcat(\%0,if(not(match(\%0,\%1,\\,)),\\,\%1)),u(unitemize,\,%qd,or),,\,),0,1),e,if(%qe,%qe,u(menu_container,%q0)),f,if(%qf,%qf,u(menu_color,%q0)))))][setq(c,delete(fold(#lambda/strcat(\%0,if(ncor(match(\%0,\%1,\\,),match(\%qd,\%1,\\,)),\\,\%1)),%qc,,\,),0,1))][if(not(%qc),0,%q0)]
&SIZES Dave the Bartender=large:yh|regular|short:g|small:c|stout:y|tall:h|thin:hx|wide:r
&TABULATE_MENU Dave the Bartender=align(1 77,,table(map(#lambda/ansi(u(menu_color,\%0),u(menu_name,\%0)),%0,|),20,77,|))
&UNITEMIZE Dave the Bartender=regeditalli(%0,(?>(?>%b?\,%b?|%b)%1 |%b?\,%b?)(.*?)(?=\,|(\,%b?|%b)%1 |$),\,[switch(u(menu_drinks,u(find_drink,$1)),?*,%$0,$1)])
&VALID_COCKTAIL Dave the Bartender=cand(lt(strlen(%0),20),valid(name,%0),not(regmatchi(%0,\,|%b(and|or|using|without|of|colored)%b|^(and|or|using|without|of|colored|[map(menu_name,v(drinks),|)]|[map(menu_name,v(cocktails),|)]|[map(menu_name,v(sizes),|)]|[map(menu_name,v(containers

look Dave the Bartender