QuickJack, as the name implies, is a quick game of blackjack against the computer which is played by triggering touch-only events: no textboses, no dialogs, etc… It is a minimalist version of blackjack lacking the ace (the ace is considered to have the value 1).
Simply dump the script below into a primitive and you are ready to go.
The goal of the game is to draw as many cards as necessary in order to reach a value as close as possible to 21 but without going over that value. If a player draws too many cards and they add up to a value over 21 then that player is considered busted and they lose the game. The gamble is to stop as close as possible to the value of 21 and hope that the other player (the computer in this script's case) gets busted trying to reach a value higher than the first player.
As you might have guessed, the cards you can draw have special values. The numeric cards:
❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿
have the values that you see.
However, the special cards:
♠ ♣ ♥ ♦
all have a value of 10.
////////////////////////////////////////////////////////// // WaS (c) grimore.org - 2012, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // ////////////////////////////////////////////////////////// list cGraphics = ["❶","❷","❸","❹","❺","❻","❼","❽","❾","❿","♠","♣","♥","♦"]; list cValues = [1,2,3,4,5,6,7,8,9,10,10,10,10,10]; integer player_amount = 0; integer house_amount = 0; string player_hand = ""; string house_hand = ""; string player_name = ""; default { state_entry() { llSetText("✪ Touch to play Quickjack! ✪", <1,1,1>, 1); } touch_start(integer num) { player_name = llDetectedName(0); state player; } } state player { state_entry() { integer rnd = (integer)llFrand(llGetListLength(cGraphics)); player_amount += llList2Integer(cValues, rnd); if(player_amount > 21) { llSay(0, player_name + " is busted."); llResetScript(); } player_hand += llList2String(cGraphics, rnd); llSetText(player_name + "'s hand is: " + player_hand, <1,1,1>, 1); llSetTimerEvent(10); } touch_start(integer total_number) { if(llDetectedName(0) != player_name) return; integer rnd = (integer)llFrand(llGetListLength(cGraphics)); player_amount += llList2Integer(cValues, rnd); if(player_amount > 21) { llSetText(player_name + " is busted: " + (string)player_amount + "!", <1,1,1>, 1); state busted; } player_hand += llList2String(cGraphics, rnd); llSetText(player_name + "'s hand is: " + player_hand, <1,1,1>, 1); llSetTimerEvent(10); } timer() { state player_house; } } state player_house { state_entry() { llSetTimerEvent(1+llFrand(4)); } timer() { integer rnd = (integer)llFrand(llGetListLength(cGraphics)); house_amount += llList2Integer(cValues, rnd); if(house_amount > 21) { llSetText("House is busted: " + (string)house_amount + "!", <1,1,1>, 1); state busted; } if(house_amount >= player_amount) state score; house_hand += llList2String(cGraphics, rnd); llSetText(player_name + "'s hand is: " + player_hand + "\nHouse hand is: " + house_hand, <1,1,1>, 1); } } state score { state_entry() { if(player_amount <= house_amount) { llSetText("House wins with: " + (string)house_amount, <1,1,1>, 1); llSetTimerEvent(10); return; } llSetText(player_name + " wins with: " + (string)house_amount, <1,1,1>, 1); llSetTimerEvent(10); return; } timer() { llResetScript(); } } state busted { state_entry() { llSetTimerEvent(10); } timer() { llResetScript(); } }