Dvorak Engine source
From Dvorak - A Blank-Card Game
Jump to navigationJump to search
This is the MUSH source code for the Dvorak Engine, written by Kevan Davis in 2000. Anyone's welcome to reuse it or improve it.
@create Dvorak Engine=10 &READ Dvorak Engine=$readcard *:@pemit %#=%b%b[u(card,%0,2)] <[switch([u(card,%0,3)],A,Action,Thing)]>[switch([u(card,%0,4)],,,%r%b%b[u(card,%0,4)])][switch([u(card,%0,5)],,,%r%b%b(Status : [u(card,%0,5)]))] &DRAW Dvorak Engine=$drawcard:setq(1,parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],Draw,##)]));setq(0,[extract(%q1,[add(1,rand(words(%q1)))],1)]);@switch %q0=,{@emit [name(%#)] attempts to draw a card - draw pile empty...;@fo me=shuffle},{@emit [name(%#)] draws a card.;@pemit %#=You draw - [u(card,%q0,2)] (%q0);@trigger me/submove=%q0,%#} &RANDRAW Dvorak Engine=[setq(0,add(1,rand([u(cards)])))][switch([extract([u(card%q0)],1,1,~)],Draw,%q0,[u(randraw)])] &DISCARD Dvorak Engine=$discard *:@switch [extract([u(card%0)],1,1,~)]=%#,{@emit [name(%#)] discards [extract([u(card%0)],2,1,~)] (%0);@trigger me/submove=%0,Discard;},@pemit %#=You don't have that card. &PLAYCARD Dvorak Engine=$playcard *:@switch %0=* *,,{@switch [extract([u(card%0)],1,1,~)]=%#,{@emit [name(%#)] [switch([u(card,%0,3)],A,plays,puts)] [extract([u(card%0)],2,1,~)] (%0)[switch([u(card,%0,3)],T,%binto play)];@trigger me/submove=%0,[switch([u(card,%0,3)],A,Discard,P%#)]},@pemit %#=You don't have that card.;} &DESTROY Dvorak Engine=$destroy *:@switch [extract([u(card%0)],1,1,~)]=P*,{@emit [name(%#)] destroys [extract([u(card%0)],2,1,~)] (%0);&card%0 #7753=P%#~[u(card,%0,2)]~[u(card,%0,3)]~[u(card,%0,4)]~;@trigger me/submove=%0,Discard},@pemit %#=That card is not in play. &NEWCARD Dvorak Engine=$newcard */*/*:@emit [name(%#)] proposes a new card ([add([u(cards)],1)]): %0 ([switch(%1,A,Action,Thing)]) %2;&cards me=[add([u(cards)],1)];&card[u(cards)] me = Vote~%0~%1~%2~ &APPROVE Dvorak Engine=$approve *:@switch [extract([u(card%0)],1,1,~)]=Vote,{@emit [name(%#)] approves [extract([u(card%0)],2,1,~)] (%0);@trigger me/submove=%0,Draw},@pemit %#=That card is not in the voting pile. @Desc Dvorak Engine=An engine allowing online play of Dvorak, the Nomic card game.%r%rFor an abridged list of commands, type 'dvcommands' - for the full lot, visit http://dvorakgame.co.uk/engine.html &VIEWDISC Dvorak Engine=$viewdisc:@pemit %#=squish(%b[parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],Discard,## - [u(card,##,2)] <[switch([u(card,##,3)],A,Action,Thing)]>%r)])]) &VIEWHAND Dvorak Engine=$viewhand:@pemit %#=switch(u(handsize,%#),0,Your hand is empty.,squish(%b[parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],%#,## - [u(card,##,2)] <[switch([u(card,##,3)],A,Action,Thing)]>%r)] )])) &VIEWPLAY Dvorak Engine=$viewplay:setq(0,squish(%b[parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],P*,[name([delete([u(card,##,1)],0,1)])] - [u(card,##,2)] (##)[switch([u(card,##,5)],,,%b([u(card,##,5)]))]%r)])]));@pemit %#=[switch(trim(%q0),,No cards in play.,%q0)][switch([u(me/notes)],,,%rNotes : [u(me/notes)])] &SHUFFLE Dvorak Engine=$shuffle:@emit [name(%#)] shuffles the discard pile into the draw pile.;@dolist lnum(1,[u(cards)])=@switch [u(card,##,1)]=Discard,{@trigger me/submove=##,Draw;} &VIEWVOTE Dvorak Engine=$viewvote:@pemit %#=switch(floor(u(cards)),0,There are no cards in the deck.,squish(%b[parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],Vote,## - [u(card,##,2)] <[switch([u(card,##,3)],A,Action,Thing)]>%r)])])) &GIVETHING Dvorak Engine=$givething * to *:@emit [name(%#)] gives control of [u(card,%0,2)] (%0) to %1;@trigger me/submove=%0,P[num(*%1)] &COINTOSS Dvorak Engine=$toss:@emit [switch(rand(2),1,Heads - you may draw a card,Tails - you may not draw)]. &VIEWALL Dvorak Engine=$viewall:@pemit %#=switch(floor(u(cards)),0,There are no cards in the deck.,squish(%b[parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],Vote,,Repeal,,## - [u(card,##,2)] <[switch([u(card,##,3)],A,Action,Thing)]>%r)])])) &LOGCARDS Dvorak Engine=$logcards:@dolist lnum(1,[u(cards)])=@pemit %#=[switch([u(card,##,1)],[switch([u(card,##,1)],Repeal,(##),Vote,-##-,##)] - [u(card,##,2)] <[switch([u(card,##,3)],A,Action,Thing)]> [u(card,##,4)])] &DRAWPILE Dvorak Engine=iter(lnum(1,[u(cards)]),[switch([u(card,##,1)],Draw,##,)]) &VIEWDRAW Dvorak Engine=$viewdraw:@emit [name(%#)] looks through the draw pile.;@pemit %#=squish(%b[parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],Draw,## - [u(card,##,2)] <[switch([u(card,##,3)],A,Action,Thing)]>%r)])]) &COUNT Dvorak Engine=$count *:@pemit %#=[switch(u(handsize,*%0),-1,Can't find player '*%0'.,Cards in [name(num(*%0))]'s hand: [u(handsize,*%0)])] &COUNTDRAW Dvorak Engine=$countdraw:setq(1,parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],Draw,##)]));@pemit %#=Cards in draw pile: [words(%q1)] &REPEAL Dvorak Engine=$repeal *:@switch [extract([u(card%0)],1,1,~)]=Repeal,@pemit %#=That card has already been repealed.,{@emit [name(%#)] repeals [extract([u(card%0)],2,1,~)] (%0);&card%0 me=Repeal~[extract([u(card%0)],2,1,~)]~[extract([u(card%0)],3,1,~)]~[extract([u(card%0)],4,1,~)]} &VIEWREP Dvorak Engine=$viewrep:@pemit %#=squish(%b[parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],Repeal,## - [u(card,##,2)] <[switch([u(card,##,3)],A,Action,Thing)]>%r)])]) &EDIT Dvorak Engine=$editcard *=*/*/*:@emit [name(%#)] edits [u(card,%0,2)] (%0) from%r[u(card,%0,2)] <[u(card,%0,3)]> [u(card,%0,4)]%rto%r%1 <%2> %3;&card%0 me=[u(card,%0,1)]~%1~%2~%3~ &SETNOTES Dvorak Engine=$setnotes *:¬es me=%0;@emit [name(%#)] sets the Notes to "%0". &CLEARNOTES Dvorak Engine=$setnotes:¬es me=;@emit [name(%#)] clears the Notes. &DRAWVIS Dvorak Engine=$drawvis:setq(1,parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],Draw,##)]));setq(0,[extract(%q1,[add(1,rand(words(%q1)))],1)]);@switch %q0=,{@emit [name(%#)] attempts to draw a card - draw pile empty...;@fo me=shuffle},{@emit [name(%#)] draws [u(card,%q0,2)] (%q0) and reveals it to all Players.;&card%q0 me=%#~[u(card,%q0,2)]~[u(card,%q0,3)]~[u(card,%q0,4)]} &NEWDVORAK Dvorak Engine=$newdvorak:@emit [name(%#)] shuffles all the Dvorak cards back together.;@dolist lnum(1,[u(cards)])=@switch [u(card,##,1)]=Vote,,Repeal,,{&card## me=Draw~[u(card,##,2)]~[u(card,##,3)]~[u(card,##,4)]} &RENAME Dvorak Engine=$rename *=*:@emit [name(%#)] renames [u(card,%0,2)] (%0) to %1;&card%0 me=[u(card,%0,1)]~%1~[u(card,%0,3)]~[u(card,%0,4)]~[u(card,%0,5)] &VIEW2 Dvorak Engine=$viewhand *:@emit [name(%#)] looks at [name([num(*%0)])]'s hand.;@pemit %#=squish(%b[parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],[num(*%0)],## - [u(card,##,2)] <[switch([u(card,##,3)],A,Action,Thing)]>%r)] )]) &DISCRAND Dvorak Engine=$discrand:setq(2,u(randomcard,%#));@switch %q2=,@pemit %#=You have no cards to discard.,{@emit [name(%#)] discards a card at random - [u(card,%q2,2)] (%q2);@trigger me/submove=%q2,Discard} &GIVECARD Dvorak Engine=$givecard * to *:@emit [name(%#)] gives [u(card,%0,2)] (%0) to %1;@trigger me/submove=%0,[num(*%1)] &COMMANDS Dvorak Engine=$dvcommands:@pemit %#=drawcard - Draw a card.%rdrawvis - Draw a card and show it to all Players.%rplaycard # - Play a specified card from your hand%rreadcard # - Read a specified card.%rdiscard # - Discard a specified card from your hand.%rdestroy # - Destroy a specified card in play.%rgivecard # to (player) - Give a specified card to a specified player.%rgivething # to (player) - Give control a specified Thing to a specified player.%rshuffle - Shuffle the discard pile into the draw pile.%r%rviewhand - View cards in your hand.%rviewplay - View cards in play.%rviewdisc - View contents of discard pile.%rcount (player) - Count the number of cards in a specified Player's hand.%rcountdraw - Count the number of cards in the draw pile.%r%rnewcard name/(A or T)/text - Propose a new card%r%b%b%b%b(eg. "newcard Armageddon/A/Destroy all Things.")%rapprove # - Approve a proposed card.%reditcard #=name/(A or T)/text - Edit an existing card.%rrepeal # - Remove a card from the game. &SAVE Dvorak Engine=$savedeck *:@dolist lnum(1,[u(cards)])=&back%0## [u(deckholder)]=[v(card##)]; &back%0cards [u(deckholder)]=[u(cards)]; &list [u(deckholder)]=setunion(u([u(deckholder)]/list),[ucstr(%0)]); @emit [name(%#)] saves the current game as "%0". &LOAD Dvorak Engine=$loaddeck *:&cards me=[u([u(deckholder)]/back%0cards)]; @dolist lnum(1,[u(cards)])=&card## me=[get([u(deckholder)]/back%0##)]; @emit [name(%#)] loads an old game - "%0". &CLEAR Dvorak Engine=$cleardeck:&cards me=0;@emit [name(%#)] clears the current Dvorak deck. &SHUFCARD Dvorak Engine=$shufcard *:@emit [name(%#)] shuffles [extract([u(card%0)],2,1,~)] (%0) into the draw pile.;&card%0 me=Draw~[extract([u(card%0)],2,1,~)]~[extract([u(card%0)],3,1,~)]~[extract([u(card%0)],4,1,~)] &HANDSIZE Dvorak Engine=setq(1,parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],[num(%0)],##)]))[switch(num(%0),#-1,-1,[words(%q1)])] &RANDOMCARD Dvorak Engine=setq(1,parse(lnum(1,[u(cards)]),[switch([u(card,##,1)],[num(%0)],##)]))[extract(%q1,[add(1,rand(words(%q1)))],1)] &MOVECARD Dvorak Engine=$submovecard * *:&card%0 #7753=%1~[extract([u(card%0)],2,1,~)]~[extract([u(card%0)],3,1,~)]~[extract([u(card%0)],4,1,~)] &SUBMOVE Dvorak Engine=&card%0 me=%1~[extract([u(card%0)],2,1,~)]~[extract([u(card%0)],3,1,~)]~[extract([u(card%0)],4,1,~)]~[extract([u(card%0)],5,1,~)] &STATUS Dvorak Engine=$status *=*:@emit [name(%#)] changes the status of [u(card,%0,2)] (%0)[switch([u(card,%0,5)],,,%bfrom "[u(card,%0,5)]")] to "%1";&card%0 me=[u(card,%0,1)]~[u(card,%0,2)]~[u(card,%0,3)]~[u(card,%0,4)]~%1 &PLAYONTO Dvorak Engine=$playcard * onto *:@switch [u(card,%0,3)][u(card,%0,1)]=T%#,{@emit [name(%#)] puts [u(card,%0,2)] (%0) into play on [u(card,%1,2)] (%1);&card%0 me=P%#~[u(card,%0,2)]~[u(card,%0,3)]~[u(card,%0,4)]~on [u(card,%1,2)][switch([u(card,%0,5)],,,%b- [u(card,%0,5)])]},@pemit %#=Either you don't have that card, or it's not a Thing. &CARDBACK Dvorak Engine=[extract([u(card%0)],%1,1,~)] &DECKHOLDER Dvorak Engine=#10031 &LIST Dvorak Engine=$listdecks:@pemit %#=Saved Dvorak decks: [u(u(deckholder)/list)] &CARD Dvorak Engine=[extract(u(card%0),%1,1,~)] &DELETEDECK Dvorak Engine=$deletedeck *:@dolist lnum(1,u([u(deckholder)]/back%0cards))=&back%0## [u(deckholder)]=; &back%0cards [u(deckholder)]=; &list [u(deckholder)]=setdiff(u([u(deckholder)]/list),[ucstr(%0)]); @emit [name(%#)] erases the saved deck "%0". &LOADCARD Dvorak Engine=$loadcard */*/*:&cards me=[add([u(cards)],1)];&card[u(cards)] me = Draw~%0~%1~%2~ @set Dvorak Engine=COMMANDS