Instructions

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

MUSHCode for Bridge Table

@create Bridge Parent
@lock/Basic Bridge Parent==me
@lset Bridge Parent/Basic=no_inherit
@set Bridge Parent = !NO_COMMAND
&AUTHOR Bridge Parent=Walker and Javelin @ M*U*S*H
&AUTHORS Bridge Parent=Walker and Javelin @ M*U*S*H
&CMD.BID Bridge Parent=$^\+bid ([1-7])(c|d|h|s|nt)$:think u(fun.bid,last(%0))
@set Bridge Parent/CMD.BID=regexp
&CMD.BOOT Bridge Parent=$+boot:think u(fun.boot)
&CMD.CLEAR Bridge Parent=$+clear:think u(fun.clear)
&CMD.DEAL Bridge Parent=$+deal:think u(fun.deal)
&CMD.DPLAY Bridge Parent=$^\+dplay ([2-9jqka]|10)[shdc]:think u(fun.dplay,rest(%0))
@set Bridge Parent/CMD.DPLAY=regexp
&CMD.DUMMY Bridge Parent=$+dummy:think u(fun.dummy)
&CMD.DUNDO Bridge Parent=$+dundo:think u(fun.dundo)
&CMD.HAND Bridge Parent=$+hand:@pemit %#=[u(d.long_hand)]
&CMD.KIBITZ Bridge Parent=$+kibitz:think u(fun.kibitz)
&CMD.KIBITZER Bridge Parent=$+kibitz *:think u(fun.kibitzer,%0)
&CMD.PEEK Bridge Parent=$+peek:think u(h.setup)[if(not(%qs),pemit(%#,You are not seated),pemit(%#,u(d.hand)))]
&CMD.PLAY Bridge Parent=$^\+play ([2-9jqka]|10)[shdc]:think u(fun.play,rest(%0))
@set Bridge Parent/CMD.PLAY=regexp
&CMD.RANDOMSEAT Bridge Parent=$+random * * * *:think u(fun.randomseat,%0,%1,%2,%3)
&CMD.REDEAL Bridge Parent=$+redeal:think u(fun.redeal)
&CMD.SHOWALL Bridge Parent=$+showall:think u(fun.showall)
&CMD.SIT Bridge Parent=$+sit *:think u(fun.sit,%0)
&CMD.STAND Bridge Parent=$+stand:think u(fun.stand)
&CMD.SWAP Bridge Parent=$+swap * *:think u(fun.swap,%0,%1)
&CMD.T Bridge Parent=$t:@pemit %#=[u(describe)]
&CMD.TABLE Bridge Parent=$+table:@pemit %#=[u(describe)]
&CMD.TRICK Bridge Parent=$+trick:think u(fun.trick)
&CMD.UNDO Bridge Parent=$+undo:think u(fun.undo)
&D.BID Bridge Parent=High Bid: [v(play.bid)]
&D.DUMMY Bridge Parent=[iter(v(hand.[v(play.dummy)]),switch(right(##,1),s,setq(0,squish(%q0%b##)),h,setq(1,squish(%q1%b##)),d,setq(2,squish(%q2%b##)),c,setq(3,squish(%q3%b##))))]%rDummy:%b[v(play.dummy)]%r%b%b[iter(lnum(1,max(words(%q0),words(%q1),words(%q2),words(%q3))),[ljust(ansi(rh,extract(%q2,#@,1)),4)][ljust(ansi(h,extract(%q3,#@,1)),4)][ljust(ansi(rh,extract(%q1,#@,1)),4)][ljust(ansi(h,extract(%q0,#@,1)),4)],%b,%r%b%b)]%r
&D.HAND Bridge Parent=[u(h.setup)][if(%qs,%rYour hand:[if(eq(words(%qh),13),%b%bBidding Points: [u(h.hand,%qh)] %([u(h.hand.nt,%qh)] Notrump points%))]%r%b%b%b[u(h.ansify,%qh)])
&D.LONG_HAND Bridge Parent=u(h.setup)[iter(%qh,switch(right(##,1),s,setq(0,squish(%q0%b##)),h,setq(1,squish(%q1%b##)),d,setq(2,squish(%q2%b##)),c,setq(3,squish(%q3%b##))))]%r%b%b[iter(lnum(1,max(words(%q0),words(%q1),words(%q2),words(%q3))),[ljust(ansi(rh,extract(%q2,#@,1)),4)][ljust(ansi(h,extract(%q3,#@,1)),4)][ljust(ansi(rh,extract(%q1,#@,1)),4)][ljust(ansi(h,extract(%q0,#@,1)),4)],%b,%r%b%b)]%r
&D.SUIT Bridge Parent=[ansi(switch(%1,h,hr,d,hr,h),[ucstr(%1)]: [edit(graball(%0,*%1),%1,)])]
&D.TABLE Bridge Parent=[switch(%0,*north*,[iter(s h c d,[space(20)][u(d.suit,v(hand.north),##)],%b,%r)]%r)][space(20)][before(u(h.show_player,north),|)]%r[space(20)][after(u(h.show_player,north),|)]%r[if(cor(match(%0,*west*),match(%0,*east*)),[iter(s h c d,[ljust(switch(%0,*west*,u(d.suit,v(hand.west),##),%b),30)][space(20)][switch(%0,*east*,u(d.suit,v(hand.east),##))],%b,%r)])]%r[ljust(before(u(h.show_player,west),|),50)][before(u(h.show_player,east),|)]%r[ljust(after(u(h.show_player,west),|),50)][after(u(h.show_player,east),|)]%r[switch(%0,*south*,iter(s h c d,[space(20)][u(d.suit,v(hand.south),##)],%b,%r))]%r[space(20)][before(u(h.show_player,south),|)]%r[space(20)][after(u(h.show_player,south),|)]
&D.TABLEALL Bridge Parent=[iter(north east south west,u(h.showplayer,##),%b,%r)]
&DESCRIBE Bridge Parent=[u(h.setup)][u(d.table,if(hasattr(me,play.showall),north south east west,%qd [v(play.dummy)]))]%r[space(3)][u(d.bid)][switch(words(%qh),13,%r%b%b%bBidding points: [u(h.hand,%qh)] at a suit contract\, [u(h.hand.nt,%qh)] at notrump,%bNorth-South: [u(h.showcards,v(score.ns))][space(3)]West-East: [u(h.showcards,v(score.we))])]
@set Bridge Parent/DESCRIBE=no_command visual public nearby
&FUN.BID Bridge Parent=u(h.setup)[if(%qs,u(h.emit,%N sets the bid at %0 for [setq(0,switch(%qd,north,North-South,south,North-South,west,West-East,east,West-East))]%q0.)[set(me,play.bid:%q0 for %0)][set(me,play.the_bid:%0)],pemit(%#,You are not seated))]
&FUN.BOOT Bridge Parent=u(fun.clear)[u(h.emit,%N draws a gun poker-style on all the players at [name(me)] and shoots them\, clearing the space for a new game. Viva la bridge!)][set(me,seated:north:#0 south:#0 west:#0 east:#0)]
&FUN.CLEAR Bridge Parent=wipe(me/hand.*)[wipe(me/play.*)][set(me,score.ns:0)][set(me,score.we:0)][u(h.emit,%N clears the table%, gathering the cards up into a deck.)]
&FUN.DEAL Bridge Parent=u(h.setup)[if(%qs,[u(fun.clear)][setq(0,shuffle(v(i.deck)))][iter(south west north east,set(me,hand.##:[extract(%q0,add(mul(sub(#@,1),13),1),13,%b)])[u(h.sort,##)])][u(h.emit,%N shuffles%, cuts%, and deals the cards.)][iter(north south east west,set(me,old.##:[v(hand.##)]))],pemit(%#,You are not seated and cannot deal.)
&FUN.DPLAY Bridge Parent=u(h.setup)[switch(0,%qs,pemit(%#,you are not seated),strlen(grab(north:south south:north east:west west:east,%qd:[v(play.dummy)])),pemit(%#,You are not the dummy's partner.),not(hasattr(me,play.[v(play.dummy)])),pemit(%#,Dummy has already played),match(lcstr(v(hand.[v(play.dummy)])),lcstr(%0)),pemit(%#,Dummy doesn't have that card.),[setq(d,v(play.dummy))][setq(h,v(hand.%qd))][set(me,hand.%qd:[squish(edit(%qh,capstr(lcstr(%0)),))])][set(me,play.%qd:[capstr(lcstr(%0))])][u(h.emit,%N plays [u(h.ansify,capstr(lcstr(%0)))] from Dummy's hand.)][if(not(hasattr(me,play.first)),set(me,play.first:[lcstr(%0)]))][u(h.turn)])
&FUN.DUMMY Bridge Parent=u(h.setup)[if(%qs,set(me,play.dummy:%qd)[u(h.emit,%N has set %oself as dummy.)],pemit(%#,You are not seated!))]
&FUN.DUNDO Bridge Parent=[u(h.setup)][if(not(%qs),pemit(%#,You are not seated.),if(neq(comp(%qd,switch(v(play.dummy),north,south,south,north,west,east,east,west)),0),pemit(%#,You are not the Dummy's partner),setq(d,switch(%qd,north,south,south,north,west,east,east,west))[setq(h,v(hand.%qd))][if(not(hasattr(me,play.%qd)),pemit(%#,You haven't played),[set(me,hand.%qd:[munge(i.deck,%qh [v(play.%qd)],%qh [v(play.%qd)])])][wipe(me/play.%qd)][u(h.emit,%N undoes the Dummy's play)]))])]
&FUN.KIBITZ Bridge Parent=[u(h.setup)][if(%qs,emit(%N, a player, has tried to +kibitz!),pemit(%#,u(h.kibitz)))]
&FUN.KIBITZER Bridge Parent=[u(h.setup)][if(%qs,emit(%N tried to kibitz.),if(match(north south east west,%0),pemit(%#,u(h.kibitzer,%0)),pemit(%#,Invalid Direction)))]
&FUN.PLAY Bridge Parent=u(h.setup)[switch(0,%qs,pemit(%#,You are not seated.),not(hasattr(me,play.%qd)),pemit(%#,You have already played%, use +trick to clear and add to your score.),match(lcstr(%qh),lcstr(%0)),pemit(%#,You do not have that card.),set(me,hand.%qd:[squish(edit(%qh,capstr(lcstr(%0)),))])[set(me,play.%qd:[capstr(lcstr(%0))])][u(h.emit,%n plays [u(h.ansify,capstr(lcstr(%0)))] from %p hand)][if(not(hasattr(me,play.first)),set(me,play.first:[lcstr(%0)]))][u(h.turn)])
&FUN.RANDOMSEAT Bridge Parent=switch(0,eq(words(%0 %1 %2 %3),4),pemit(%#,You need 4 players!),t(num(%0)),pemit(%#,Can't find %0),t(num(%1)),pemit(%#,Can't find %1),t(num(%2)),pemit(%#,Can't find %2),t(num(%3)),pemit(%#,Can't find %3),setq(0,num(%0))[setq(1,num(%1))][setq(2,num(%2))][setq(3,num(%3))][if(neq(words(setunion(%q0 %q1 %q2 %q3,%q0 %q1 %q2 %q3)),4),pemit(%#,You need 4 different players!),set(me,seated:[iter(shuffle(north south east west),##:[r(sub(#@,1))])])[emit([name(%q0)]\, [name(%q1)]\, [name(%q2)]\, and [name(%q3)] take a seat at the table.)]
&FUN.REDEAL Bridge Parent=[u(h.setup)][u(fun.clear)][if(not(%qs),pemit(%#,You are not seated),[iter(north south east west,set(me,hand.##:[v(old.##)]))][u(h.emit,%N Redeals the old cards)]
&FUN.SHOWALL Bridge Parent=[u(h.emit,%N forces everone's hand onto the table.)][set(me,play.showall:1)]
&FUN.SIT Bridge Parent=u(h.setup)[if(%qs,pemit(%#,You are already seated.),switch(grab(v(seated),%0*:*),*:#0,set(me,seated:[edit(v(seated),#$,[before(#$,:)]:%#)])[u(h.setup)][emit(%N has taken the %qd seat.)],*:*,pemit(%#,name(after(#$,:)) is seated there.),pemit(%#,Which seat?)))]
&FUN.STAND Bridge Parent=u(h.setup)[if(not(%qs),pemit(%#,You are not seated.),set(me,seated:[edit(v(seated),%qd:%#,%qd:#0)])[emit(%N stands up from the table%, leaving the %qd seat vacated.)]
&FUN.SWAP Bridge Parent=u(h.setup)[setq(0,grab(north south east west,lcstr(%0)*))][setq(1,grab(north south east west,lcstr(%1)*))][switch(0,%qs,pemit(%#,You are not seated.),comp(%q0,%q1),pemit(%#,You can't swap the same direction.),mul(strlen(%q0),strlen(%q1)),pemit(%#,Which directions?),edit(v(seated),%q0,%q1,%q1,%q0)[setq(2,v(hand.%q0))][setq(3,v(hand.%q1))][set(me,hand.%q0:%q3)][set(me,hand.%q1:%q2)][pemit(%#,%q0 and %q1 swapped)])]
&FUN.TRICK Bridge Parent=u(h.setup)[switch(0,%qs,pemit(%#,You are not seated.),cand(hasattr(me,play.north),hasattr(me,play.south),hasattr(me,play.west),hasattr(me,play.east)),pemit(%#,Not everyone has played.),[setq(1,u(h.high_card))][u(h.emit,%q1 takes the trick.)][set(me,play.tricker:%q1)][wipe(me/play.west)][wipe(me/play.first)][wipe(me/play.east)][wipe(me/play.north)][wipe(me/play.south)][u(h.tturn)][setq(0,switch(%q1,north,ns,south,ns,west,we,east,we))][set(me,score.%q0:[add(v(score.%q0),1)])])
&FUN.UNDO Bridge Parent=[u(h.setup)][if(not(%qs),pemit(%#,You are not seated.),if(not(hasattr(me,play.%qd)),pemit(%#,You haven't played),[set(me,hand.%qd:[munge(i.deck,%qh [v(play.%qd)],%qh [v(play.%qd)])])][wipe(me/play.%qd)][u(h.emit,%N undoes %p play)]))]
&H.ANSIFY Bridge Parent=iter(%0,switch(right(##,1),s,ansi(h,##),c,ansi(h,##),ansi(hr,##))
&H.CARDRANKS Bridge Parent=u(suit.[right(v(play.first),1)])%b[u(suit.trump)]
&H.EMIT Bridge Parent=emit(TABLE: %0)
&H.HAND Bridge Parent=[lmath(add,iter(s h c d,u(h.onesuit,graball(%0,*##))))]
&H.HAND.NT Bridge Parent=[lmath(add,iter(s h c d,u(h.onesuit.nt,graball(%0,*##))))]
&H.HIGH_CARD Bridge Parent=last(munge(h.cardranks,lcstr([v(play.south)] [v(play.north)] [v(play.east)] [v(play.west)]),south north east west))
&H.KIBITZ Bridge Parent=[u(h.setup)][u(d.table,north south east west)]%r[space(3)][u(d.bid)][switch(words(%qh),13,%r%b%b%bBidding points: [u(h.hand,%qh)] at a suit contract\, [u(h.hand.nt,%qh)] at notrump,%bNorth-South: [u(h.showcards,v(score.ns))][space(3)]West-East: [u(h.showcards,v(score.we))])]
&H.KIBITZER Bridge Parent=[setq(h,v(hand.%0))]%0's hand:[if(eq(words(%qh),13),%b%bBidding Points: [u(h.hand,%qh)] %([u(h.hand.nt,%qh)] Notrump points%))]%r%b%b%b[u(h.ansify,%qh)]
&H.ONESUIT Bridge Parent=[add(mul(4,strmatch(%0,*A*)),switch(words(%0),0,3,1,add(2,strmatch(%0,*K*)),2,add(1,mul(3,strmatch(%0,*K*)),strmatch(%0,*Q*)),add(mul(3,strmatch(%0,*K*)),mul(2,strmatch(%0,*Q*)),strmatch(%0,*J*))))]
&H.ONESUIT.NT Bridge Parent=[add(mul(4,strmatch(%0,*A*)),switch(words(%0),0,0,1,strmatch(%0,*K*),2,add(mul(3,strmatch(%0,*K*)),strmatch(%0,*Q*)),add(mul(3,strmatch(%0,*K*)),mul(2,strmatch(%0,*Q*)),strmatch(%0,*J*))))]
&H.SETUP Bridge Parent=setq(s,gt(strlen(grab(v(seated),*:%#)),0))[setq(d,before(grab(v(seated),*:%#),:))][setq(h,v(hand.%qd))][setq(t,not(comp(v(play.turn),%qd)))][setq(b,switch(v(play.bid),bid,0,game,1,2))][setq(m,not(comp(v(play.dummy),%qd)))]
&H.SHOWCARDS Bridge Parent=%0
&H.SHOWPLAYER Bridge Parent=ljust(u(h.ansify,v(play.%0)),5)[ljust(left(switch(after(grab(v(seated),%0:*),:),#0,capstr(%0),name(#$)),15),15)][u(h.ansify,v(hand.%0))]
&H.SHOW_PLAYER Bridge Parent=center(if(eq(0,comp(%0,v(play.tricker))),\*%b)[left(switch(after(grab(v(seated),%0:*),:),#0,capstr(lcstr(%0)),name(#$)),20)],20)|[center(switch(v(play.%0),*c,ansi(h,#$),*s,ansi(h,#$),ansi(rh,#$)),20)]
&H.SORT Bridge Parent=set(me,hand.%0:[munge(i.deck,v(hand.%0),v(hand.%0))])
&H.TTURN Bridge Parent=[setq(5,v(play.tricker))][if(not(comp(%q5,v(play.dummy))),setq(6,switch(%q5,south,north,north,south,west,east,east,west))[setq(7,Dummy's)],[setq(6,%q5)][setq(7,Your)])][pemit(after(grab(v(seated),%q6:*),:),TABLE: It is %q7 turn.)]
&H.TURN Bridge Parent=[setq(5,switch(%qd,south,west,west,north,north,east,east,south))][if(not(comp(%q5,v(play.dummy))),setq(6,switch(%q5,south,north,north,south,west,east,east,west))[setq(7,Dummy's)],[setq(6,%q5)][setq(7,Your)])][if(not(hasattr(me,play.%q5)),pemit(after(grab(v(seated),%q6:*),:),TABLE: It is %q7 turn.))]
&H.TURN2 Bridge Parent=[setq(0,switch(%qd,north,east,east,south,south,west,west,north))][if(not(hasattr(me,play.%q0)),pemit(after(grab(v(seated),%q0:*),:),ansi(bh,TABLE: Your Turn)))]
&I.BIDRANK Bridge Parent=1C 1D 1H 1S 1NT 2C 2D 2H 2S 2NT 3C 3D 3H 3S 3NT 4C 4D 4H 4S 4NT 5C 5D 5H 5S 5NT 6C 6D 6H 6S 6NT 7C 7D 7H 7S 7NT
&I.CARDRANK Bridge Parent=A K Q J 10 9 8 7 6 5 4 3 2
&I.DECK Bridge Parent=Ad Kd Qd Jd 10d 9d 8d 7d 6d 5d 4d 3d 2d Ac Kc Qc Jc 10c 9c 8c 7c 6c 5c 4c 3c 2c Ah Kh Qh Jh 10h 9h 8h 7h 6h 5h 4h 3h 2h As Ks Qs Js 10s 9s 8s 7s 6s 5s 4s 3s 2s
&I.PLAY Bridge Parent=south west north east south
&LOCK.CANUSE Bridge Parent=[u(h.setup)][cor(%qs,not(comp(first(%c),with)))]
&SEATED Bridge Parent=north:#0 south:#0 west:#0 east:#0
&SUIT.C Bridge Parent=2c 3c 4c 5c 6c 7c 8c 9c 10c jc qc kc ac
&SUIT.D Bridge Parent=2d 3d 4d 5d 6d 7d 8d 9d 10d jd qd kd ad
&SUIT.H Bridge Parent=2h 3h 4h 5h 6h 7h 8h 9h 10h jh qh kh ah
&SUIT.S Bridge Parent=2s 3s 4s 5s 6s 7s 8s 9s 10s js qs ks as
&SUIT.TRUMP Bridge Parent=v(suit.[right(v(play.the_bid),1)])
&TYPE Bridge Parent=Parent game
&UFAIL Bridge Parent=u(use)
@set Bridge Parent/UFAIL=no_command
&USE Bridge Parent=Bridge Table by [v(author):%r[ansi(h,with [name(me)]=+sit <direction>)] - Sit at specified location.%r[ansi(h,+stand)] - Stand up%r[ansi(h,+hand)] or [ansi(h,+peek)] - See your hand (also in table description)%r[ansi(h,+clear)] - clear the table.%r[ansi(h,+deal)] - Deal 13 cards to all locations%r[ansi(h,+bid)] - Set the bid for the table info only, it doesn't check.%r[ansi(h,+dummy)] - Set yourself as dummy so others can see your cards.%r[ansi(h,+showall)] - Everyone shows their cards.%r[ansi(h,+play <card>)] - Play <card> from your hand.%r[ansi(h,+undo)] - Take the card you played back into your hand.%r[ansi(h,+dplay <card>)] - play <card> from the Dummy's hand.%r[ansi(h,+dundo)] - Put the dummy's card back in Dummy's hand.%r[ansi(h,+trick)] - Take the trick and add to your points%r[ansi(h,+redeal)] - Show the cards that were dealt last game%r[ansi(h,with [name(me)]=+kibitz \[direction\])] - Kibitz!%r[ansi(h,+boot)] - Remove everyone currently sitting at the table so new players can take a seat.%r[ansi(h,+swap <direction> <direction>)] - Swap the two seated players.%r[ansi(h,+random <player> <player> <player> <player>)] - all 4 players sit randomly.
@set Bridge Parent/USE=no_command