entonces, para los que no saben que es contar cartas: es simplemente sumar +1, o restar -1, con ciertas cartas (2,3,4,5,6 son +1) (A,10,J,Q,K son -1) y 789 son neutros (ignoralos)
no les explico mas, si quieren mas informacion busquen en wikipedia http://en.wikipedia.org/wiki/Card_counting
el siguiente script hace lo siguiente:
-cada ves que sacas una carta, esta se saca de un maso de 52 cartas (en el blackjack usan como 6, pero para entrenar contar muchos usan solo 1)
-cada ves que saca una carta la elimina de un array
-cada ves hace una loop hasta que encuentre una carta que no habia sido sacada
-mantiene la cuenta por ti
-mantiene cuantas cartas quedan
NOTAS: todos los sprites de las cartas estan alojadas en una sola imagen, y para cambiar de cartas lo unico que hasemos es cambiar el 'background position'...
escribi en ingles las explicasiones, si no le entienden traten de traducirlo con algun traductor, y si no le entienden del verbo "entender-como-le-hisiste", preguntenme sus dudas y yo se las aclaro
PASOS PARA USAR:
1.- copien y peguen el script en bloq de notas y guardenlo como .html
2.- bajar la imagen que contiene las cartas
link imagen: [url=http://tuxedoknight.uphero.com/test/cards.png][/url]
entren y denle right click -> save as y guardenlo por ahi (si no lo guardan con el nombre "cards", modifiquen la la linea en el css donde dice "url(cards.png) no-repeat;", igual si lo guardan con otra extension, cambienle el .png)
3.- pongan la imagen en la misma ubicacion de la pagina .html
4.- abranlo y empiesen a contar cartas =0
<html>
<style type="text/css">
<!--
.sprites{
height:615px;
width: 1027px;
background: transparent url(cards.png) no-repeat;
border:0;
}
.NaN {
width: 79px;
height:123px;
background-position: -158px -492px;
}
.cAc {
width: 79px;
height:123px;
background-position: 0px 0px;
}
.c2c {
width: 79px;
height:123px;
background-position: -79px 0px;
}
.c3c {
width: 79px;
height:123px;
background-position: -158px 0px;
}
.c4c {
width: 79px;
height:123px;
background-position: -237px 0px;
}
.c5c {
width: 79px;
height:123px;
background-position: -316px 0px;
}
.c6c {
width: 79px;
height:123px;
background-position: -395px 0px;
}
.c7c {
width: 79px;
height:123px;
background-position: -474px 0px;
}
.c8c {
width: 79px;
height:123px;
background-position: -553px 0px;
}
.c9c {
width: 79px;
height:123px;
background-position: -632px 0px;
}
.cTc {
width: 79px;
height:123px;
background-position: -711px 0px;
}
.cJc {
width: 79px;
height:123px;
background-position: -790px 0px;
}
.cQc {
width: 79px;
height:123px;
background-position: -869px 0px;
}
.cKc {
width: 79px;
height:123px;
background-position: -948px 0px;
}
.dAd {
width: 79px;
height:123px;
background-position: 0px -123px;
}
.d2d {
width: 79px;
height:123px;
background-position: -79px -123px;
}
.d3d {
width: 79px;
height:123px;
background-position: -158px -123px;
}
.d4d {
width: 79px;
height:123px;
background-position: -237px -123px;
}
.d5d {
width: 79px;
height:123px;
background-position: -316px -123px;
}
.d6d {
width: 79px;
height:123px;
background-position: -395px -123px;
}
.d7d {
width: 79px;
height:123px;
background-position: -474px -123px;
}
.d8d {
width: 79px;
height:123px;
background-position: -553px -123px;
}
.d9d {
width: 79px;
height:123px;
background-position: -632px -123px;
}
.dTd {
width: 79px;
height:123px;
background-position: -711px -123px;
}
.dJd {
width: 79px;
height:123px;
background-position: -790px -123px;
}
.dQd {
width: 79px;
height:123px;
background-position: -869px -123px;
}
.dKd {
width: 79px;
height:123px;
background-position: -948px -123px;
}
.hAh {
width: 79px;
height:123px;
background-position: 0px -246px;
}
.h2h {
width: 79px;
height:123px;
background-position: -79px -246px;
}
.h3h {
width: 79px;
height:123px;
background-position: -158px -246px;
}
.h4h {
width: 79px;
height:123px;
background-position: -237px -246px;
}
.h5h {
width: 79px;
height:123px;
background-position: -316px -246px;
}
.h6h {
width: 79px;
height:123px;
background-position: -395px -246px;
}
.h7h {
width: 79px;
height:123px;
background-position: -474px -246px;
}
.h8h {
width: 79px;
height:123px;
background-position: -553px -246px;
}
.h9h {
width: 79px;
height:123px;
background-position: -632px -246px;
}
.hTh {
width: 79px;
height:123px;
background-position: -711px -246px;
}
.hJh {
width: 79px;
height:123px;
background-position: -790px -246px;
}
.hQh {
width: 79px;
height:123px;
background-position: -869px -246px;
}
.hKh {
width: 79px;
height:123px;
background-position: -948px -246px;
}
.sAs {
width: 79px;
height:123px;
background-position: 0px -369px;
}
.s2s {
width: 79px;
height:123px;
background-position: -79px -369px;
}
.s3s {
width: 79px;
height:123px;
background-position: -158px -369px;
}
.s4s {
width: 79px;
height:123px;
background-position: -237px -369px;
}
.s5s {
width: 79px;
height:123px;
background-position: -316px -369px;
}
.s6s {
width: 79px;
height:123px;
background-position: -395px -369px;
}
.s7s {
width: 79px;
height:123px;
background-position: -474px -369px;
}
.s8s {
width: 79px;
height:123px;
background-position: -553px -369px;
}
.s9s {
width: 79px;
height:123px;
background-position: -632px -369px;
}
.sTs {
width: 79px;
height:123px;
background-position: -711px -369px;
}
.sJs {
width: 79px;
height:123px;
background-position: -790px -369px;
}
.sQs {
width: 79px;
height:123px;
background-position: -869px -369px;
}
.sKs {
width: 79px;
height:123px;
background-position: -948px -369px;
}
-->
</style>
<body>
<script type="text/javascript">
//***|--Copyright: by Omar P.
//***|--You are allowed to use, sell or modify this script at any time
//***|--You are NOT allowed to remove or change this Copyright in any way
myArray = ['Ah', '2h', '3h', '4h', '5h','6h','7h','8h','9h','Th','Jh','Qh', 'Kh', 'Ac', '2c', '3c', '4c', '5c','6c','7c','8c','9c','Tc','Jc','Qc', 'Kc', 'Ad', '2d', '3d', '4d', '5d','6d','7d','8d','9d','Td','Jd','Qd', 'Kd', 'As', '2s', '3s', '4s', '5s','6s','7s','8s','9s','Ts','Js','Qs', 'Ks'];
newArray= myArray;
cardsleft =52;
count = 0;
function resett()
{
//we set the default values and undisable the buttons in case they were disabled
document.MyForm.button1.disabled = false;
document.MyForm.button2.disabled = false;
myArray = ['Ah', '2h', '3h', '4h', '5h','6h','7h','8h','9h','Th','Jh','Qh', 'Kh', 'Ac', '2c', '3c', '4c', '5c','6c','7c','8c','9c','Tc','Jc','Qc', 'Kc', 'Ad', '2d', '3d', '4d', '5d','6d','7d','8d','9d','Td','Jd','Qd', 'Kd', 'As', '2s', '3s', '4s', '5s','6s','7s','8s','9s','Ts','Js','Qs', 'Ks'];
newArray= myArray;
cardsleft =52;
count = 0;
randomnumber= "";
document.MyForm.button1.className= 'sprites NaN';
//---------------
}
function rand()
{
//we set 'i' in false, the function will loop until it is true
i = 'false';
//---------------
//we start the looping until a)we pick a card previously not picked or b)we stop because there aren't any cards left
while (i != 'true'){
//---------------
//check if there are cards left. 'x' = the card is already taken, so when the array equal x,x,x...(x49)...x we know there aren't any left
if (newArray == 'x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x')
//---------------
{
//if there aren't any cards left, we set i='true' to stop looping, change the button sprite to NaN and disable the buttons
i = 'true';
document.MyForm.button1.className= 'NaN';
document.MyForm.button1.disabled = true;
document.MyForm.button2.disabled = true;
return;
//---------------
}
//note: if else is executed, it means there are cards left
else
//---------------
{
//set a random number to chose the card (output is 0-51)
randomnumber=Math.floor(Math.random()*52);
//---------------
//if the random array was a card already chosen it does nothing
if (newArray[randomnumber] == 'x')
{
}
//---------------
//if it is a card not already chosen...
else
{
//---------------
//stop looping
i = 'true';
//---------------
//'his' will be the short string for newArray[randomnumber]
his = newArray[randomnumber];
//---------------
//we do a search for h,c,s or d using the string 'his'
myRegExp = 'h';
matchH = his.search(myRegExp);
myRegExp = 'c';
matchC = his.search(myRegExp);
myRegExp = 's';
matchS = his.search(myRegExp);
myRegExp = 'd';
matchD = his.search(myRegExp);
//---------------
//pre is the string for the style of the button. Ex: hAh <- Ace of Hearts
pre = "";
if (matchH != -1)
{
pre = "h";
}
if (matchC != -1)
{
pre = "c";
}
if (matchD != -1)
{
pre = "d";
}
if (matchS != -1)
{
pre = "s";
}
pre = "sprites " + pre + his;
//---------------
//we change the button class to 'pre' so it turns into the card
document.MyForm.button1.className= pre;
//---------------
//change the values to simplify the counting of cards
his = his.replace(/A/g,'10');
his = his.replace(/T/g,'10');
his = his.replace(/J/g,'10');
his = his.replace(/Q/g,'10');
his = his.replace(/K/g,'10');
//---------------
//remove the suits so in the count we just x1 instead of x4
his = his.replace(/h/g,'');
his = his.replace(/c/g,'');
his = his.replace(/s/g,'');
his = his.replace(/d/g,'');
//---------------
//count +1, 0 or -1 depending on the value
if (his == '6' || his == '5' || his == '4' || his == '3' || his == '2'){
count = count +1;
}
else if(his == '10')
{
count = count -1;
}
//---------------
//remove the card used
newArray[randomnumber] = 'x';
cardsleft = cardsleft - 1;
//---------------
}
}
}
}
</script>
<br>
<div align="center">
<form name="MyForm">
<input name="button1" type=button onClick="rand();" class="sprites NaN"><br><br>
<input name="button2" type=button onClick="rand();" value="Next Card">
<input type=button onClick="alert('The count is: ' + count);" value="Current Count">
<input type=button onClick="alert('There are ' + cardsleft + ' cards left');" value="Cards Left">
<br><br>
<input type=button onClick="resett();" value="Reset?">
</form></div>
</body>
</html>