Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Glorida
Newbie


Joined: 10 Mar 2006
Posts: 7

PostPosted: Fri Mar 10, 2006 8:13 am   

Blackjack Script: Complete Dealer vs Player gambling
 
Code:

#CLASS {blackjack|hit}
#TRIGGER {@player tells the group, 'hit'} {#alarm +1 {#class hit 0;#class hit1 1};gt Hitting...;hit}
#CLASS 0
#CLASS {blackjack|hit1}
#TRIGGER {@player tells the group, 'hit'} {#alarm +1 {#class hit1 0;#class hit2 1};gt Hitting...;hit1}
#CLASS 0
#CLASS {blackjack|hit2}
#TRIGGER {@player tells the group, 'hit'} {;#alarm +1 {#class hit2 0;#class hit3 1};gt Hitting...;hit2}
#CLASS 0
#CLASS {blackjack|initial}
#TRIGGER {You have %1 gold coins.} {#var goldi {%1};#alarm +1 {#class initial 0;#class step 1;gold}}
#CLASS 0
#CLASS {blackjack|step}
#TRIGGER {^You have %1 gold coins.} {#var goldn {%1};#alarm +1 {#class step 0;#class add 1;accept}}
#CLASS 0
#CLASS {blackjack|add}
#ALIAS shuffle {#math check {@golda-@goldn};#IF (@check != @bet) {gt You have been warned, do not try to emote bets again!;#class add 0;#class step 1;gold} {#IF (@bet > 5000 OR @bet < 5) {give @bet gold @player;gt The bets must between 5 and 5000 gold coins} {deal}}}
#TRIGGER {^You have %1 gold coins.} {#var golda {%1}}
#TRIGGER {@player gives you %1 gold coins.} {#var bet {%1};gold;#alarm +2 {shuffle}}
#CLASS 0
#CLASS {blackjack|stay}
#TRIGGER {^@player tells the group, 'stay'} {#class hit 0;#class hit1 0;#class hit2 0;#class stay 0;stay}
#CLASS 0
#ALIAS deal {#class stay 1;#var p3 0;#var p4 0;#var p5 0;#var p6 0;#var total 0;#var total1 0;#var total2 0;#var total3 0;#var stay 0;gt Dealing....;#var p1 %random( 1, 52);#var d1 %random( 1, 52);#while (@p1 = @d1) {#var d1 %random( 1, 52)};#var p2 %random( 1, 52);#while (@p2 = @d1 OR @p2 = @p1) {#var p2 %random( 1, 52)};#var d2 %random( 1, 52);#while (@d2 = @p2 OR @d2 = @p1 OR @d2 = @d1) {#var d2 %random( 1, 52)};#additem dealt @p1;#additem dealt @p2;#additem dealt @d1;#additem dealt @d2;convert p1;convert p2;convert d1;convert d2;#var p1N1 0;#var p1N11 0;#var p2N1 0;#var p2N11 0;#var d1N1 0;#var d1N11 0;#var d2N1 0;#var d2N11 0;#FORALL @p1N {#IF (%i = 1) {#var p1N1 1} {#IF (%i = 11) {#var p1N11 1}}};#FORALL @p2N {#IF (%i = 1) {#var p2N1 1} {#IF (%i = 11) {#var p2N11 1}}};#FORALL @d1N {#IF (%i = 1) {#var d1N1 1} {#IF (%i = 11) {#var d1N11 1}}};#FORALL @d2N {#IF (%i = 1) {#var d2N1 1} {#IF (%i = 11) {#var d2N11 1}}};#IF (@p1N1 = 1) {#IF (@p2N1 = 1) {#math total {1+1};#math total1 {1+11};gt Player's Hand: @p1T || @p2T Total: @total OR @total1.} {#math total {1+@p2N};#math total1 {11+@p2N};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T~~G Total: @total} {gt Player's Hand: ~~H~~Y@p1T || @p2T~~G Total: @total or @total1}}} {#IF (@p2N1 = 1) {#math total {1+@p1N};#math total1 {11+@p1N};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T ~~GTotal: @total} {gt Player's Hand: ~~H~~Y@p1T || @p2T~~G Total: @total or @total1}} {#math total {@p1N+@p2N};gt Player's Hand: ~~H~~Y@p1T || @p2T ~~GTotal: @total}};#IF (@total = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {#IF (@total1 = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {#class hit 1;#class hit1 0;#class hit2 0;gt Dealer is showing: ~~H~~Y@d2T~~G;gt Would you like to 'hit' or 'stay' ?}}} "blackjack"
#ALIAS convert {#var blarg {%1};#var convert {@@blarg};#IF (@convert = 1) {#var newT AH;#var newN 1|11} {#IF (@convert = 2) {#var newT 2H;#var newN 2} {#IF (@convert = 3) {#var newT 3H;#var newN 3} {#IF (@convert = 4) {#var newT 4H;#var newN 4} {#IF (@convert = 5) {#var newT 5H;#var newN 5} {#IF (@convert = 6) {#var newT 6H;#var newN 6} {#IF (@convert = 7) {#var newT 7H;#var newN 7} {#IF (@convert = 8) {#var newT 8H;#var newN 8} {#IF (@convert = 9) {#var newT 9H;#var newN 9} {#IF (@convert = 10) {#var newT 10H;#var newN 10} {#IF (@convert = 11) {#var newT JH;#var newN 10} {#IF (@convert = 12) {#var newT QH;#var newN 10} {#IF (@convert = 13) {#var newT KH;#var newN 10} {#IF (@convert = 14) {#var newT AS;#var newN 1|11} {#IF (@convert = 15) {#var newT 2S;#var newN 2} {#IF (@convert = 16) {#var newT 3S;#var newN 3} {#IF (@convert = 17) {#var newT 4S;#var newN 4} {#IF (@convert = 18) {#var newT 5S;#var newN 5} {#IF (@convert = 19) {#var newT 6S;#var newN 6} {#IF (@convert = 20) {#var newT 7S;#var newN 7} {#IF (@convert = 21) {#var newT 8S;#var newN 8} {#IF (@convert = 22) {#var newT 9S;#var newN 9} {#IF (@convert = 23) {#var newT 10S;#var newN 10} {#IF (@convert = 24) {#var newT JS;#var newN 10} {#IF (@convert = 25) {#var newT QS;#var newN 10} {#IF (@convert = 26) {#var newT KS;#var newN 10} {#IF (@convert = 27) {#var newT AD;#var newN 1|11} {#IF (@convert = 28) {#var newT 2D;#var newN 2} {#IF (@convert = 29) {#var newT 3D;#var newN 3} {#IF (@convert = 30) {#var newT 4D;#var newN 4} {#IF (@convert = 31) {#var newT 5D;#var newN 5} {#IF (@convert = 32) {#var newT 6D;#var newN 6} {#IF (@convert = 33) {#var newT 7D;#var newN 7} {#IF (@convert = 34) {#var newT 8D;#var newN 8} {#IF (@convert = 35) {#var newT 9D;#var newN 9} {#IF (@convert = 36) {#var newT 10D;#var newN 10} {#IF (@convert = 37) {#var newT JD;#var newN 10} {#IF (@convert = 38) {#var newT QD;#var newN 10} {#IF (@convert = 39) {#var newT KD;#var newN 10} {#IF (@convert = 40) {#var newT AC;#var newN 1|11} {#IF (@convert = 41) {#var newT 2C;#var newN 2} {#IF (@convert = 42) {#var newT 3C;#var newN 3} {#IF (@convert = 43) {#var newT 4C;#var newN 4} {#IF (@convert = 44) {#var newT 5C;#var newN 5} {#IF (@convert = 45) {#var newT 6C;#var newN 6} {#IF (@convert = 46) {#var newT 7C;#var newN 7} {#IF (@convert = 47) {#var newT 8C;#var newN 8} {#IF (@convert = 48) {#var newT 9C;#var newN 9} {#IF (@convert = 49) {#var newT 10C;#var newN 10} {#IF (@convert = 50) {#var newT JC;#var newN 10} {#IF (@convert = 51) {#var newT QC;#var newN 10} {#IF (@convert = 52) {#var newT KC;#var newN 10}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}};#IF (%1 = p1) {#var p1T @newT;#var p1N @newN} {#IF (%1 = d1) {#var d1T @newT;#var d1N @newN} {#IF (%1 = p2) {#var p2T @newT;#var p2N @newN} {#IF (%1 = p3) {#var p3T @newT;#var p3N @newN} {#IF (%1 = p4) {#var p4T @newT;#var p4N @newN} {#IF (%1 = p5) {#var p5T @newT;#var p5N @newN} {#IF (%1 = d2) {#var d2T @newT;#var d2N @newN} {#IF (%1 = d3) {#var d3T @newT;#var d3N @newN} {#IF (%1 = d4) {#var d4T @newT;#var d4N @newN} {#IF (%1 = d5) {#var d5T @newT;#var d5N @newN}}}}}}}}}}} "blackjack"
#ALIAS hit {#var p3 %random( 1, 52);#while (@p3 = @p1 OR @p3 = @p2 OR @p3 = @d1 OR @p3 = @d2) {#var p3 %random( 1, 52)};convert p3;#var p3N1 0;#FORALL @p3N {#IF (%i = 1) {#var p3N1 1} {#IF (%i = 11) {#var p3N11 1}}};#IF (@p3N1 = 1) {#IF (@total1 = 0) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total OR @total1}} {#IF (@total1 > 21) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total}}} {#math total {@total+1};#math total2 {@total1+1};#math total3 {@total1+11};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total} {#IF (@total2 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total OR @total1} {#IF (@total3 > 21) {Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total OR @total1 OR @total2}}{Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total OR @total1 OR @total2 OR @total3}}}} {#IF (@total1 = 0) {#math total {@total+@p3N};#IF (@total > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total;gt Player Busts, You lose!;dwin} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total}} {#math total {@total+@p3N};#math total1 {@total1+@p3N};#IF (@total > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total;gt Player Busts, You lose!;dwin} {#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T~~G Total: @total OR @total1}}}};#IF (@total > 21) {} {#IF (@total = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {#IF (@total1 = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {#IF (@total2 = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {gt Dealer is showing: ~~H~~Y@d2T~~G;gt Would you like to 'hit' or 'stay' ?}}}}} "blackjack"
#ALIAS hit1 {#var p4 %random( 1, 52);#while (@p4 = @p1 OR @p4 = @p2 OR @p4 = @p3 OR @p4 = @d1 OR @p4 = @d2) {#var p4 %random( 1, 52)};convert p4;#var p4N1 0;#FORALL @p4N {#IF (%i = 1) {#var p4N1 1} {#IF (%i = 11) {#var p4N11 1}}};#IF (@p4N1 = 1) {#IF (@total1 = 0) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total OR @total1}} {#IF (@total1 > 21) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total}}} {#math total {@total+1};#math total2 {@total1+1};#math total3 {@total1+11};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total} {#IF (@total2 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total OR @total1} {#IF (@total3 > 21) {Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total OR @total1 OR @total2}}{Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total OR @total1 OR @total2 OR @total3}}}} {#IF (@total1 = 0) {#math total {@total+@p4N};#IF (@total > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total;gt Player Busts, You lose!;dwin} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total}} {#math total {@total+@p4N};#math total1 {@total1+@p4N};#IF (@total > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total;gt Player Busts, You lose!;dwin} {#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T~~G Total: @total} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || ~~G@p4T Total: @total OR @total1}}}};#IF (@total > 21) {} {#IF (@total = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {#IF (@total1 = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {#IF (@total2 = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {gt Dealer is showing: ~~H~~Y@d2T~~G;gt Would you like to 'hit' or 'stay' ?}}}}} "blackjack"
#ALIAS hit2 {#var p5 %random( 1, 52);#while (@p5 = @p1 OR @p5 = @p2 OR @p5 = @p3 OR @p5 = @p4 OR @p5 = @d1 OR @p5 = @d2) {#var p5 %random( 1, 52)};convert p5;#var p5N1 0;#FORALL @p5N {#IF (%i = 1) {#var p5N1 1} {#IF (%i = 11) {#var p5N11 1}}};#IF (@p5N1 = 1) {#IF (@total1 = 0) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total OR @total1}} {#IF (@total1 > 21) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total}}} {#math total {@total+1};#math total2 {@total1+1};#math total3 {@total1+11};#math total1 {@total+11};#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total} {#IF (@total2 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total OR @total1} {#IF (@total3 > 21) {Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total OR @total1 OR @total2}}{Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total OR @total1 OR @total2 OR @total3}}}} {#IF (@total1 = 0) {#math total {@total+@p5N};#IF (@total > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total;gt Player Busts, You lose!;dwin} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total}} {#math total {@total+@p5N};#math total1 {@total1+@p5N};#IF (@total > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total;gt Player Busts, You lose!;dwin} {#IF (@total1 > 21) {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total} {gt Player's Hand: ~~H~~Y@p1T || @p2T || @p3T || @p4T || @p5T~~G Total: @total OR @total1}}}};#IF (@total > 21) {} {#IF (@total = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {#IF (@total1 = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {#IF (@total2 = 21) {gt ~~RBLACKJACK~~G You win!;pwin} {gt 5 card charlie, you win!!;charlie}}}}} "blackjack"
#ALIAS stay {#IF (@total3 != 0 AND @total3 < 21) {#var stay @total3} {#IF (@total2 != 0 AND @total3 < 21) {#var stay @total2} {#IF (@total1 !=0 AND @total1 < 21) {#var stay @total1} {#var stay @total}}};#wait 1000;gt Ok, @player, You're staying on @stay;#wait 1000;reveal} "blackjack"
#ALIAS reveal {gt The Dealer turns over his hidden card!;#var total 0;#var total1 0;#wait 1000;#IF (@d1N1 = 1) {#IF (@d2N1 = 1) {#math total {1+1};#math total1 {1+11};gt Dealer's Hand: @d1T || @d2T Total: @total OR @total1.} {#math total {1+@d2N};#math total1 {11+@d2N};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T~~G Total: @total} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T~~G Total: @total or @total1}}} {#IF (@d2N1 = 1) {#math total {1+@d1N};#math total1 {11+@d1N};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T ~~GTotal: @total} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T~~G Total: @total or @total1}} {#math total {@d1N+@d2N};gt Dealer's Hand: ~~H~~Y@d1T || @d2T ~~GTotal: @total}};#IF (@total1 = 21) {gt Dealer ~~H~~RBLACKJACK~~G, You lose!;dwin} {#IF (@total1 != 0) {#IF (@total1 < 21) {#IF (@total1 > 16) {#wait 1000;gt Dealer will stay on @total1;#var dealer @total1;compare} {#wait 1000;gt Dealer will hit;dhit}}} {#IF (@total > 16) {#wait 1000;gt Dealer will stay on @total;#var dealer @total;compare} {#wait 1000;gt Dealer will hit;dhit}}}} "blackjack"
#ALIAS dhit {#var d3 %random( 1, 52);#while (@d3 = @p1 OR @d3 = @p2 OR @d3 = @p3 OR @d3 = @p4 OR @d3 = @p5 OR @d3 = @p6 OR @d3 = @d1 OR @d3 = @d2) {#var d3 %random( 1, 52)};convert d3;#var d3N1 0;#FORALL @d3N {#IF (%i = 1) {#var d3N1 1} {#IF (%i = 11) {#var d3N11 1}}};#IF (@d3N1 = 1) {#IF (@total1 = 0) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total OR @total1}} {#IF (@total1 > 21) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total}}} {#math total {@total+1};#math total2 {@total1+1};#math total3 {@total1+11};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total} {#IF (@total2 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total OR @total1} {#IF (@total3 > 21) {Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total OR @total1 OR @total2}}{Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total OR @total1 OR @total2 OR @total3}}}} {#IF (@total1 = 0) {#math total {@total+@d3N};#IF (@total > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total;gt Dealer Busts, You win!;pwin} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total}} {#math total {@total+@d3N};#math total1 {@total1+@d3N};#IF (@total > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total;gt Dealer Busts, You win!;pwin} {#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T~~G Total: @total OR @total1}}}};#IF (@total < 22) {#IF (@total3 != 0 AND @total3 > 16 AND @total3 < 22) {gt Dealer will stay on @total3.;#var dealer @total3;compare} {#IF (@total2 != 0 AND @total2 > 16 AND @total2 < 22) {gt Dealer will stay on @total2.;#var dealer @total2;compare} {#IF (@total1 != 0 AnD @total1 > 16 AND @total1 < 22) {gt Dealer will stay on @total1.;#var dealer @total1;compare} {#IF (@total > 16) {gt Dealer will stay at @total.;#var dealer @total;compare} {gt Dealer will hit.;dhit1}}}}}} "blackjack"
#ALIAS dhit1 {#var d4 %random( 1, 52);#while (@d4 = @p1 OR @d4 = @p2 OR @d4 = @p3 OR @d4 = @p4 OR @d4 = @p5 OR @d4 = @p6 OR @d4 = @d1 OR @d4 = @d2 OR @d4 = @d3) {#var d4 %random( 1, 52)};convert d4;#var p4N1 0;#FORALL @d4N {#IF (%i = 1) {#var d4N1 1} {#IF (%i = 11) {#var =d4N11 1}}};#IF (@d4N1 = 1) {#IF (@total1 = 0) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total OR @total1}} {#IF (@total1 > 21) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total}}} {#math total {@total+1};#math total2 {@total1+1};#math total3 {@total1+11};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total} {#IF (@total2 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total OR @total1} {#IF (@total3 > 21) {Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total OR @total1 OR @total2}}{Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total OR @total1 OR @total2 OR @total3}}}} {#IF (@total1 = 0) {#math total {@total+@d4N};#IF (@total > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total;gt Dealer Busts, You win!;pwin} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total}} {#math total {@total+@d4N};#math total1 {@total1+@d4N};#IF (@total > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total;gt Dealer Busts, You win!;pwin} {#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T~~G Total: @total} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || ~~G@d4T Total: @total OR @total1}}}};#IF (@total < 22) {#IF (@total3 != 0 AND @total3 > 16 AND @total3 < 22) {gt Dealer will stay on @total3.;#var dealer @total3;compare} {#IF (@total2 != 0 AND @total2 > 16 AND @total2 < 22) {gt Dealer will stay on @total2.;#var dealer @total2;compare} {#IF (@total1 != 0 AND @total1 > 16 AND @total1 < 22) {gt Dealer will stay on @total1.;#var dealer @total1;compare} {#IF (@total > 16) {gt Dealer will stay at @total.;#var dealer @total;compare} {gt Dealer will hit.;dhit2}}}}}} "blackjack"
#ALIAS compare {#alarm +1 {gt Player stayed at: @stay;gt Dealer stayed at: @dealer;#IF (@stay > @dealer) {gt You win!;pwin} {#IF (@stay = @dealer) {gt Player and Dealer Tie!;tie} {gt Dealer wins!;dwin}}}} "blackjack"
#ALIAS pwin {#class stay 0;#add pwin 1;#class hit 0;#class hit1 0;#class hit2 0;#IF (@p1N = 1 OR @p1N = 14 OR @p1N = 27 OR @p1N = 40) {#IF (@p2N = 11 OR @p2N = 24 OR @p2N = 37 OR @p2N = 50) {#var multi 2.5} {#IF (@total2 = 21 OR @total1 = 21 OR @total = 21) {#var multi 2} {#var multi 2}}} {#IF (@p1N = 11 OR @p1N = 24 OR @p1N = 37 OR @p1N = 50) {#IF (@p2N = 1 OR @p2N = 14 OR @p2N = 27 OR @p2N = 40) {#var multi 2.5} {#IF (@total2 = 21 OR @total1 = 21 OR @total = 21) {#var multi 2} {#var multi 2}}} {#IF (@total2 = 21 OR @total1 = 21 OR @total = 21) {#var multi 2} {#var multi 2}}};#math win {@bet*@multi};gt Congratulations, you have won @win gold coins!;#FILE 1 blackjack;#write 1 {Player won @win off a @bet bet.};#close 1;#alarm +1 {give @win gold @player;#class add 0;#class step 1;#alarm +1 {gold}}} "blackjack"
#ALIAS charlie {#class hit 0;#class hit1 0;#class hit2 0;#var multi 3;#math win {@bet*@multi};gt Congratulations, you have won @win gold coins!;#FILE 1 blackjack;#write 1 {Player won @win off a @bet bet. CHARLIE};#close 1;#alarm +1 {give @win gold @player;#class add 0;#class step 1;#alarm +1 {gold}}} "blackjack"
#ALIAS dwin {#class stay 0;#add dwin 1;#FILE 1 blackjack;#write 1 {Dealer won off a @bet bet.};#close 1;#alarm +1 {#class add 0;#class step 1;gold}} "blackjack"
#ALIAS dhit2 {#var d5 %random( 1, 52);#while (@d5 = @p1 OR @d5 = @p2 OR @d5 = @p3 OR @d5 = @p4 OR @d5 = @p5 OR @d5 = @p6 OR @d5 = @d1 OR @d5 = @d2 OR @d5 = @d3 OR @d5 = @d4) {#var d4 %random( 1, 52)};convert d5;#var d5N1 0;#FORALL @d5N {#IF (%i = 1) {#var d5N1 1} {#IF (%i = 11) {#var p5N11 1}}};#IF (@d5N1 = 1) {#IF (@total1 = 0) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total OR @total1}} {#IF (@total1 > 21) {#math total {@total+1};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total}}} {#math total {@total+1};#math total2 {@total1+1};#math total3 {@total1+11};#math total1 {@total+11};#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total} {#IF (@total2 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total OR @total1} {#IF (@total3 > 21) {Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total OR @total1 OR @total2}}{Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total OR @total1 OR @total2 OR @total3}}}} {#IF (@total1 = 0) {#math total {@total+@d5N};#IF (@total > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total;gt Dealer Busts, You win!;pwin} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total}} {#math total {@total+@d5N};#math total1 {@total1+@d5N};#IF (@total > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total;gt Dealer Busts, You win!;pwin} {#IF (@total1 > 21) {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total} {gt Dealer's Hand: ~~H~~Y@d1T || @d2T || @d3T || @d4T || @d5T~~G Total: @total OR @total1}}}};#IF (@total < 22) {#IF (@total3 != 0 AND @total3 > 16 AND @total3 < 22) {gt Dealer will stay on @total3.;#var dealer @total3;compare} {#IF (@total2 != 0 AND @total2 > 16 AND @total2 < 22) {gt Dealer will stay on @total2.;#var dealer @total2;compare} {#IF (@total1 != 0 AND @total1 > 16 AND @total1 < 22) {gt Dealer will stay on @total1.;#var dealer @total1;compare} {#IF (@total > 20) {gt Dealer will stay at @total.;#var dealer @total;compare} {gt Dealer has a 5 card charlie, You lose!;dwin}}}}}} "blackjack"
#ALIAS accept {#var random %random( 1, 20);#IF (@random = 1) {gt Now Accepting Bids!} {#IF (@random = 2) {gt Now Accepting Bets!} {#IF (@random = 3) {gt Bids Are Now Being Accepted!} {#IF (@random = 4) {gt You may now place your bid!} {#IF (@random = 5) {gt Please place a bid!} {#IF (@random = 6) {gt Bid Now!} {#IF (@random = 7) {gt Feel Free to Bet!} {#IF (@random = 8) {gt Betting Time!} {#IF (@random = 9) {gt Go Ahead!!} {#IF (@random = 10) {gt Bet whenever!} {#IF (@random = 11) {gt You are now able to bet!} {#IF (@random = 12) {gt Continue to Bet!} {#IF (@random = 13) {gt Betting is now Allowed!} {#IF (@random = 14) {gt Bettin' Time!} {#IF (@random = 15) {gt Bet Away!} {#IF (@random = 16) {gt Bets' will now be accepted!} {#IF (@random = 17) {gt Go @player, Bet away!!} {#IF (@random = 18) {gt Go whenever!} {#IF (@random = 19) {gt Biddin' Time!} {#IF (@random = 20) {gt Now Ready to Bet!}}}}}}}}}}}}}}}}}}}}} "blackjack"
#ALIAS tie {#add tie 1;#FILE 1 blackjack;#write 1 {TIE.};#close 1;#alarm +1 {give @bet gold @player;#class add 0;#class step 1;#alarm +1 {gold}}} "blackjack"
#ALIAS net {#math gain {@goldi-@goldn};#echo You have won '@gain' gold coins} "blackjack"
#VAR tie {0} {_nodef} "blackjack"
#VAR dwin {0} {_nodef} "blackjack"
#VAR pwin {0} {_nodef} "blackjack"
#TRIGGER {^@player tells the group, 'help'} {#wait 1000;gt Ok, @player, this game is Blackjack;#wait 1000;gt I'll briefly explain the rules associated with this particular version, if you're unfamiliar with blackjack as a game in general, read up on the internet before playing.;#wait 1000;gt The player must give a bet to me, Casino, and then the cards will be shuffled, and dealt.;#wait 1000;gt The player will be dealt 2 cards, face up, and the dealer will reveal 1 of his cards, the other stays face down until the player is done playing.;#wait 1000;gt The player will either 'hit' which means ask for another card to be added to their total, or 'stay' where their current highest total without going over 21 will be saved.;#wait 1000;gt When the player has completed by staying or going over 21, the dealer will reveal his hidden card;#wait 1000;gt The deal is forced to 'hit' if his total is under 17, and is forced to stay if his total is 17 or higher.;#wait 1000;gt CURRENTLY YOU CANNOT SPLIT, this function will be added later, once Blackjack is confirmed to be bug-free.;#wait 1000;gt The allowed bets are from 5 to 5000. This means any bet from 5 to 5000 may be used.;#wait 1000;gt Winning Payouts: If you win: 2.0x bet, if you win with a TRUE blackjack, (ie. Ace - Jack) :2.5x bet, and if you get a 5 card charlie: 3.0x bet (5 card charlie is having 5 cards that add up to less than 21)} "blackjack"
#TRIGGER {^@player tells the group, 'odds'} {math @dwin/@pwin} "blackjack"
#TRIGGER {Result was: %1} {gt The current wins are: Dealer: @dwin || Players: @pwin || Ties: @tie With a house to player ratio of: %1} "blackjack"


This bot is completely automatic on the dealer side. You don't have to press any buttons, type any aliases, etc. You simply need a player who gives you cash and likes to play cards.


How it works:
Essentially Shuffles before dealing each card, never deals the same card twice. The player can hit or stay on any number under 21, automatically wins on a 21. Automatically loses over 21. The dealer must hit below 17, and must stay on 17 or higher. The game is completely tested and I'm pretty sure this is all the code for it. There are some triggers I didn't include, like defining who @player was. But basically I just did it on whomever followed me, I grouped them, and they said blackjack, put them as variable @player.


Things you'll need to change (mud specific).
-The string of when someone gives you gold
Mine is %1 gives you %d gold coins.
-The string of checking your gold.
Everytime someone gives me gold, I record and check the value of my current gold coins, and subtract it from the last known value, to make sure the person didn't emote giving me money. No clue if this is possible on your mud, but it is on mine, so it's in there for a reason.
-The whole odds command probably won't work on any other mud than Alter Aeon, we have a math command, that does simple calculations. The reason I didn't use the Zmud's math command is because anything under 1 is automatically zero, it doesn't give .83 and such.
-The group tell string: mine is %1 tells the group, '%2'
-The colour system of your mud: mine is a tilde: hence anytime you see ~~H~~R it means I'm colouring it highlight red

If you need further explanation of what everything does, I'll explain otherwise I won't waste the energy

If I think of anything else I'll post...Any questions email me at jason@pchop.com



****Currently Blackjack is a SINGLE PLAYER game****
I haven't had the time or energy to make it a multiplayer game, however, I have some of the code written, just never finished....If there's a need for it and I receive some incentive, I'll finish it.


Cloak/Glorida
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net