Natalia's Card Table

A multiplayer card table.

Category: Games
Features: color substitutions.
Compatibility: TinyMUX.

Instructions

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

MUSHCode for Natalia's Card Table

@create Cards Parent
@lock Cards Parent==me
&DECK Cards Parent=Kc Qc Jc 10c 9c 8c 7c 6c 5c 4c 3c 2c Ac Ks Qs Js 10s 9s 8s 7s 6s 5s 4s 3s 2s As Kd Qd Jd 10d 9d 8d 7d 6d 5d 4d 3d 2d Ad Kh Qh Jh 10h 9h 8h 7h 6h 5h 4h 3h 2h Ah Jj JJ
&NJ_DECK Cards Parent=Kc Qc Jc 10c 9c 8c 7c 6c 5c 4c 3c 2c Ac Ks Qs Js 10s 9s 8s 7s 6s 5s 4s 3s 2s As Kd Qd Jd 10d 9d 8d 7d 6d 5d 4d 3d 2d Ad Kh Qh Jh 10h 9h 8h 7h 6h 5h 4h 3h 2h Ah
&JOKERS Cards Parent=$+jokers:@switch [match([num(%n)],[u(dealer)])]=0,{@pemit *%n=[u(n_cards)]},{@pemit/contents here=%N makes certain that there are jokers in the deck.;&card_no me=54;&use_deck me=[u(deck)]}
&N_CARDS Cards Parent=You don't have the cards! Type: chelp
&USE_DECK Cards Parent=Kc Qc Jc 10c 9c 8c 7c 6c 5c 4c 3c 2c Ac Ks Qs Js 10s 9s 8s 7s 6s 5s 4s 3s 2s As Kd Qd Jd 10d 9d 8d 7d 6d 5d 4d 3d 2d Ad Kh Qh Jh 10h 9h 8h 7h 6h 5h 4h 3h 2h Ah
&DEALER_N Cards Parent=$+dealer:@pemit/contents here=%N collects the cards and prepares to deal.;@pemit *%n=The default deck has no jokers. Type +jokers before you shuffle to add jokers.;&shuffled me=1;&card_no me=52;@dolist [u(players)]=&b[##] me;@dolist [u(players)]=&t[##] me;@dolist [u(players)]=&wc[##] me;@dolist [u(players)]=&rc[##] me;@dolist [u(players)]=&bc[##] me;&players me;&use_deck me=[u(nj_deck)];&dealer me=[num(%n)]
&SHUFFLE Cards Parent=$shuffle:@switch [match([num(%n)],[u(dealer)])]=0,{@pemit *%n=[u(n_cards)]},{@pemit/contents here=%N shuffles the cards.;&shuffled me=0;&use_deck me=[shuffle([u(use_deck)])]}
&DEALER Cards Parent=#802
&CARD_NO Cards Parent=52
&DEAL_TO Cards Parent=$deal * to *:@switch [match([num(%n)],[u(dealer)])]=0,{@pemit *%n=[u(n_cards)]},{@switch [and(match(loc(me),loc(%1)),hasflag(%1,connect))]=0,{@pemit *%n=There is no %1 here.},{@switch [and(isnum(%0), lte(u(shuffled),0),gte([u(card_no)],%0))]=0,{@pemit *%n=[u(card_no)] card(s) remain. Either your input is wrong or you didn't shuffle before dealing.},{@switch [match(%0,1)]=1,{@switch [member([u(players)],[num(%n)])]=0,{&players me=[u(players)] [num(%1)];&t[num(%1)] me=[extract([u(use_deck)],1,1)];&card_no me=[add([u(card_no)],-1)];&use_deck me=[extract([u(use_deck)],2,100)];@switch [match([u(dealer)],[num(%1)])]=1, {@pemit/contents here=%N takes a card from the deck for [%o]self.},{@pemit/contents here=%N deals a card to [capstr(%1)].}},{&t[num(%1)] me=[u(t[num(%1)])] [extract([u(use_deck)],1,1)];&card_no me=[add([u(card_no)],-1)];&use_deck me=[extract([u(use_deck)],2,100)];@switch [match([u(dealer)],[num(%1)])]=1, {@pemit/contents here=%N takes a card from the deck for [%o]self.},{@pemit/contents here=%N deals a card to [capstr(%1)].}}},{@switch [member([u(players)],[num(%n)])]=0,{&players me=[u(players)] [num(%1)];&t[num(%1)] me=[extract([u(use_deck)],1,[%0])];&card_no me=[add([u(card_no)],-[%0])];&use_deck me=[extract([u(use_deck)],[add([%0],1)],100)];@switch [match([u(dealer)],[num(%1)])]=1,{@pemit/contents here=%N takes %0 cards from the deck for [%o]self.},{@pemit/contents here=%N deals %0 cards to [capstr(%1)].}},{&t[num(%1)] me=[u(t[num(%1)])] [extract([u(use_deck)],1,[%0])];&card_no me=[add([u(card_no)],-[%0])];&use_deck me=[extract([u(use_deck)],[add([%0],1)],100)];@switch [match([u(dealer)],[num(%1)])]=1,{@pemit/contents here=%N takes %0 cards from the deck for [%o]self.},{@pemit/contents here=%N deals %0 cards to [capstr(%1)].}}}}}}
&OUT_MSG Cards Parent=You haven't been dealt into the game. Type: chelp
&LO_TBL Cards Parent=$tbl:@pemit *%n=Cards on Table;@dolist [u(players)]=@pemit *%n=[name(##)]'s cards: [u(b[##])]
&CL_TBL Cards Parent=$cl tbl:@switch [match([u(players)],[num(%n)])]=0,{@pemit *%n=Only players may clear the table. Type: chelp.},{@dolist [u(players)]=&b[##] me;@pemit/contents here=%N clears all of the cards off the table.}
&GT_TBL Cards Parent=$gt * tbl:@switch [member([u(players)],[num(%n)])]=0,{@pemit *%n=[u(out_msg)]},{@switch [member([u(b[num(%n)])],%0)]=0,{@pemit *%n=You have no "[%0]" on the table.},{&b[num(%n)] me=[remove([u(b[num(%n)])],%0)];&t[num(%n)] me=[u(t[num(%n)])] %0;@pemit/contents here=%N takes %p %0 from the table.}}
&GT_ALL Cards Parent=$gt all:@switch [member([u(players)],[num(%n)])]=0,{@pemit *%n=[u(out_msg)]},{&t[num(%n)] me=[u(t[num(%n)])] [u(b[num(%n)])];@pemit/contents here=%N gets all of %p cards from the table: [u(b[num(%n)])];&b[num(%n)] me}
&PT_ALL Cards Parent=$pt all:@switch [member([u(players)],[num(%n)])]=0,{@pemit *%n=[u(out_msg)]},{&b[num(%n)] me=[u(b[num(%n)])] [u(t[num(%n)])];@pemit/contents here=%N puts all of %p cards on the table: [u(t[num(%n)])];&t[num(%n)] me}
&CHAND Cards Parent=$hand:@switch [member([u(players)],[num(%n)])]=0,{@pemit *%n=[u(out_msg)]},{@pemit *%n=Cards in hand: [u(t[num(%n)])]}
&DIS_CARD Cards Parent=$dis *:@switch [member([u(players)],[num(%n)])]=0,{@pemit *%n=[u(out_msg)]},{@switch [member([u(t[num(%n)])],%0)]=0,{@pemit *%n=You don't have a "[%0]" in your hand.},{&t[num(%n)] me=[remove([u(t[num(%n)])],%0)];@pemit/contents here=%N discards.}}
&DLR_CMDS Cards Parent=$dealer cmds:@pemit *%n=%rThe person who types "+dealer" becomes the dealer.%r%rCommands restricted to the dealer...%r+jokers[repeat(.,28)]Used before "shuffle" to add jokers.%rshuffle[repeat(.,28)]Randomizes the deck.%rdeal <no. of cards> to <player>....Example "deal 2 to Martin"%r[repeat(_,80)]
&PLR_CMDS Cards Parent=$player cmds:@pemit *%n=%rCommands with a ** by them may be used by anyone.%rPlayer commands...%rhand[repeat(.,36)]Displays your cards to you.%rtbl[repeat(.,37)]Displays the cards on the table.**%rdis <card>[repeat(.,30)]Exa: "dis Kc" discards the Kc.%rpt all[repeat(.,34)]Puts all cards in hand on the table.%rgt all[repeat(.,34)]Gets all of your cards from the table.%rpt <card> tbl[repeat(.,27)]Exa: "pt Kc tbl" puts Kc on the table.%rgt <card> tbl[repeat(.,27)]Exa: "gt Kc tbl" gets Kc from table.%rgt <player>'s <card>[repeat(.,20)]Exa: "gt Martin's Jj"%rcl tbl[repeat(.,34)]Clears everyone's cards from the table.%r[repeat(_,80)]
&PT_TBL Cards Parent=$pt * tbl:@switch [member([u(players)],[num(%n)])]=0,{@pemit *%n=[u(out_msg)]},{@switch [member([u(t[num(%n)])],%0)]=0,{@pemit *%n=You don't have a "[%0]" in your hand.},{&b[num(%n)] me=[u(b[num(%n)])] %0;&t[num(%n)] me=[remove([u(t[num(%n)])],%0)];@pemit/contents here=%N places a %0 on the table.}}
&NOTATE Cards Parent=$notation:@pemit *%n=The cards are notated very simply. The first position indicates the value of the card, while the second position defines the suite of the card.%r%rA-Ace, K-King, Q-Queen, J-Jack, 10-ten... and so forth.%rc-clubs, d-diamonds, s-spades and h-hearts%r%rSo for example a "Jc" would be a Jack of clubs and an "Ah" would be an Ace of hearts.%rSpecial case: JJ & Jj are jokers.%r[repeat(_,80)]
&CHELP Cards Parent=$chelp:@pemit *%n=Here are the various commands for help...%rnotation%rdealer cmds%rplayer cmds%rcredits%r%rTo start a game type +dealer. Please don't do this in the middle of someone else's game.
@Desc Cards Parent=This is a standard deck of cards sitting on a table. Type: %chchelp%cn
&DEAL_BAK Cards Parent=$TTT@switch [match([num(%n)],[u(dealer)])]=0,{@pemit *%n=[u(n_cards)]},{@switch [and(match(loc(me),loc(%1)),hasflag(%1,connect))]=0,{@pemit *%n=There is no %1 here.},{@switch [and(isnum(%0),gte([u(card_no)],%0))]=0,{@pemit *%n=[u(card_no)] card(s) remain. Check your input.},{@switch [match(%0,1)]=1,{@switch [member([u(players)],[num(%n)])]=0,{&players me=[u(players)] [num(%1)];&t[num(%1)] me=[extract([u(use_deck)],1,1)];&card_no me=[add([u(card_no)],-1)];&use_deck me=[extract([u(use_deck)],2,100)];@switch [match([u(dealer)],[num(%1)])]=1, {@pemit/contents here=%N takes a card from the deck for [%o]self.},{@pemit/contents here=%N deals a card to [capstr(%1)].}},{&t[num(%1)] me=[u(t[num(%1)])] [extract([u(use_deck)],1,1)];&card_no me=[add([u(card_no)],-1)];&use_deck me=[extract([u(use_deck)],2,100)];@switch [match([u(dealer)],[num(%1)])]=1, {@pemit/contents here=%N takes a card from the deck for [%o]self.},{@pemit/contents here=%N deals a card to [capstr(%1)].}}},{@switch [member([u(players)],[num(%n)])]=0,{&players me=[u(players)] [num(%1)];&t[num(%1)] me=[extract([u(use_deck)],1,[%0])];&card_no me=[add([u(card_no)],-[%0])];&use_deck me=[extract([u(use_deck)],[add([%0],1)],100)];@switch [match([u(dealer)],[num(%1)])]=1,{@pemit/contents here=%N takes %0 cards from the deck for [%o]self.},{@pemit/contents here=%N deals %0 cards to [capstr(%1)].}},{&t[num(%1)] me=[u(t[num(%1)])] [extract([u(use_deck)],1,[%0])];&card_no me=[add([u(card_no)],-[%0])];&use_deck me=[extract([u(use_deck)],[add([%0],1)],100)];@switch [match([u(dealer)],[num(%1)])]=1,{@pemit/contents here=%N takes %0 cards from the deck for [%o]self.},{@pemit/contents here=%N deals %0 cards to [capstr(%1)].}}}}}}
&SHUFFLED Cards Parent=1
&GT_PLYR_TBL Cards Parent=$gt *'s *:@switch [member([u(players)],[num(%n)])]=0,{@pemit *%n=[u(out_msg)]},{@switch [member([u(b[num(%0)])],%1)]=0,{@pemit *%n=[capstr(%0)] isn't part of the game or doesn't have a "[%1]" on the table.},{&t[num(%n)] me=[u(t[num(%n)])] [%1];&b[num(%0)] me=[remove([u(b[num(%0)])],%1)];@pemit/contents here=%N takes [capstr(%0)]'s %1 from the table.}}
&CREDITS Cards Parent=$credits:@pemit *%n=%chCards coded by Natalia@Full Circle%cn

think Change the DEALER attribute.