Dark Destiny Card Table

A multi-player card table that can be used to play poker.

Category: Games

Instructions

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

MUSHCode for Dark Destiny Card Table

@create Poker Table
@lock Poker Table==me
&SHUFFLE Poker Table=$shuffle:@pemit/list [get(me/PLAYERS)]=%N shuffles the deck. <Ready to deal>;&DECK me=2-C 3-C 4-C 5-C 6-C 7-C 8-C 9-C 91-C J-C Q-C Y-C Z-C 2-S 3-S 4-S 5-S 6-S 7-S 8-S 9-S 91-S J-S Q-S Y-S Z-S 2-D 3-D 4-D 5-D 6-D 7-D 8-D 9-D 91-D J-D Q-D Y-D Z-D 2-H 3-H 4-H 5-H 6-H 7-H 8-H 9-H 91-H J-H Q-H Y-H Z-H;@dolist [lattr(me/HAND-*)]=&## me=
&DRAWCARDS Poker Table=$draw *:@pemit/list [get(me/PLAYERS)]=%N draws %0 cards.;@switch [gte([words([v(DECK)])],%0)]=1,{@dolist [lnum(%0)]={&TEMPNUM me=[add([rand([words([v(DECK)])])],1)];&HAND-%# me=[sort([cat([v(HAND-%#)],[extract([v(DECK)],[v(TEMPNUM)],1)])])];&DECK me=[ldelete([v(DECK)],[v(TEMPNUM)])]}},{@pemit %#=Sorry, but there aren't that many cards left in the deck.}
&VIEWCARDS Poker Table=$view hand:@pemit %#=----- Your hand currently is: -----[setq(0,0)][iter([v(HAND-%#)],[setq(0,[add([r(0)],1)])]%r[r(0)]. [switch([extract(##,1,1,-)],2,Two of,3,Three of,4,Four of,5,Five of,6,Six of,7,Seven of,8,Eight of,9,Nine of,91,Ten of,J,Jack of,Q,Queen of,Y,King of,Z,Ace of)] [switch([extract(##,2,1,-)],C,Clubs,S,Spades,D,Diamonds,H,Hearts)])]%r
&TEMPNUM Poker Table=10
&DISCARD Poker Table=$discard *:@switch [lte(%0,[words([v(HAND-%#)])])]=0,{@pemit %#=You don't have that card.},{@pemit/list [get(me/PLAYERS)]=%N discards one of %p cards.;&HAND-%# me=[ldelete([v(HAND-%#)],%0)];@pemit %#=----- Your hand currently is: -----[setq(0,0)][iter([v(HAND-%#)],[setq(0,[add([r(0)],1)])]%r[r(0)]. [switch([extract(##,1,1,-)],2,Two of,3,Three of,4,Four of,5,Five of,6,Six of,7,Seven of,8,Eight of,9,Nine of,91,Ten of,J,Jack of,Q,Queen of,Y,King of,Z,Ace of)] [switch([extract(##,2,1,-)],C,Clubs,S,Spades,D,Diamonds,H,Hearts)])]%r}
&SHOWCARDS Poker Table=$show hand:@pemit/list [get(me/PLAYERS)]= ----- %N shows %p hand: -----[setq(0,0)][iter([v(HAND-%#)],[setq(0,[add([r(0)],1)])]%r[r(0)]. [switch([extract(##,1,1,-)],2,Two of,3,Three of,4,Four of,5,Five of,6,Six of,7,Seven of,8,Eight of,9,Nine of,91,Ten of,J,Jack of,Q,Queen of,Y,King of,Z,Ace of)]%B[switch([extract(##,2,1,-)],C,Clubs,S,Spades,D,Diamonds,H,Hearts)])]%r
&DECK Poker Table=2-C 3-C 4-C 5-C 6-C 7-C 8-C 9-C 91-C J-C Q-C Y-C Z-C 2-S 3-S 4-S 5-S 6-S 7-S 8-S 9-S 91-S J-S Q-S Y-S Z-S 2-D 3-D 4-D 5-D 6-D 7-D 8-D 9-D 91-D J-D Q-D Y-D Z-D 2-H 3-H 4-H 5-H 6-H 7-H 8-H 9-H 91-H J-H Q-H Y-H Z-H
&CHELP Poker Table=$card help:@pemit %#=[center(CARD HELP,78,-)]%RNEW GAME[space(12)]Clears out all old information and initiates a new game.%RADDPLAYER <player>[space(2)]Adds <player> to the game.%RREMPLAYER <player>[space(2)]Removes <player> from the game.%RSHUFFLE[space(13)]Shuffles the cards for a hand.%RDEAL/<num>[space(10)]Deals <num> cards to each player in the game.%RDRAW <# of cards>[space(3)]Draws that many cards from the deck.%RVIEW HAND[space(11)]Shows you your hand.%RDISCARD <card #>[space(4)]Discards card number <#> from your hand.%RSHOW HAND[space(11)]Shows your hand to everyone else in the game.%RBUY <# of chips>[space(4)]Buys you <#> of poker chips.%RCOUNT CHIPS[space(9)]Counts the chips you currently have.%RBET <# of chips>[space(4)]Bets <#> of chips.%RVIEW POT[space(12)]Shows you how much is in the pot%RCOLLECT POT[space(9)]You collect all the chips in the pot.%R[center(CARD HELP,78,-)]%R
&DEALCARDS Poker Table=$deal/*:@switch [gte([words([v(DECK)])],%0)]=1,{@dolist [get(me/PLAYERS)]={@dolist [lnum(%0)]={&TEMPNUM me=[add([rand([words([v(DECK)])])],1)];&HAND-[##] me=[sort([cat([v(HAND-[##])],[extract([v(DECK)],[v(TEMPNUM)],1)])])];&DECK me=[ldelete([v(DECK)],[v(TEMPNUM)])]}};@pemit/list [get(me/PLAYERS)]=%N deals out %0 cards to you.},{@pemit %#=Sorry, but there aren't that many cards left in the deck.}
&NEWGAME Poker Table=$New Game:@wipe me/PLAYERS;&PLAYERS me=[[space(1)][%#]];&CHIPS-%# me=0;@pemit %#=New card game is now set.
&ADDPLAYER Poker Table=$AddPlayer *:@pemit/list [get(me/PLAYERS)]=%0 added as a new player to the card game.;@EDIT me/PLAYERS=$,[[space(1)][num(%0)]];@pemit %0=You have been added to the card game.;&CHIPS-[num(%0)] me=0
@Desc Poker Table=%R[space(5)]A simple, round wooden table with a green felt surface, a deck of cards and several stacks of red, white and blue poker chips are on it awaiting a game.%R
@Adesc Poker Table=@pemit %#=[center(Type CARD HELP for help.,78)]
&REMPLAYER Poker Table=$RemPlayer *:@switch [strmatch(get(me/PLAYERS),*[%0]*)]=1,{@edit me/PLAYERS=%0,[space(0)];@wipe me/CHIPS-[num(%0)];@pemit/list [get(me/PLAYERS)]=%N had removed %0 from the game.;@pemit %0=You have been removed from the game.}
&BET_CHIPS Poker Table=$bet *:@switch gte([get(me/CHIPS-%#)],%0)=1,{@edit me/CHIPS-%#=[get(me/CHIPS-%#)],[sub([get(me/CHIPS-%#)],%0)];@edit me/THEPOT=[get(me/THEPOT)],[add([get(me/THEPOT)],%0)];@pemit/list [get(me/PLAYERS)]=%N bets %0 chips.},{@pemit %#=You only have [get(me/CHIPS-%#)] chips for that bet.}
&BUY_CHIPS Poker Table=$Buy *:@edit me/CHIPS-%#=[get(me/CHIPS-%#)],[add(get(me/CHIPS-%#),%0)];@pemit/list [get(me/PLAYERS)]=%N has bought [%0] chips from the table.
&COUNT_CHIPS Poker Table=$count chips:@Pemit %#=You have [get(me/CHIPS-%#)] chips before you.
&VIEW_POT Poker Table=$view pot:@Pemit %#=There are [get(me/THEPOT)] chips currently in the pot.
&THEPOT Poker Table=0
&COLLECT_CHIPS Poker Table=$collect pot:@pemit/list [get(me/PLAYERS)]=%N collects [get(me/THEPOT)] chips out of the pot.;@edit me/CHIPS-%#=[get(me/CHIPS-%#)],[add([get(me/CHIPS-%#)],[get(me/THEPOT)])];@edit me/THEPOT=[get(me/THEPOT)],0
&PLAYERS Poker Table=
@set Poker Table=INHERIT