
En vez de T7 debería mostrarse el 7 de tréboles... o por lo menos que diga "7 tréboles"
y en D2 el 2 de diamantes, o que diga "2 diamantes".
Es para un Black Jack.
Código
// Generar array de cartas: Cartas = []; Nro = 0; do { Nro++; Cartas[Cartas.length] = "P"+Nro; Cartas[Cartas.length] = "T"+Nro; Cartas[Cartas.length] = "C"+Nro; Cartas[Cartas.length] = "D"+Nro; } while (Nro < 13); // Ordenarlas al azar: Posicion1aReubicarse = Cartas.length-1; while (Posicion1aReubicarse>0) { Posicion2aReubicarse = random(Posicion1aReubicarse+1); SaveDeElemento1 = Cartas[Posicion1aReubicarse]; Cartas[Posicion1aReubicarse] = Cartas[Posicion2aReubicarse]; Cartas[Posicion2aReubicarse] = SaveDeElemento1; Posicion1aReubicarse--; } // Dar a jugadores: SiguienteNroDeCarta = 0; CartasDeHumano = []; CartasDeIA = []; do { CartasDeHumano[CartasDeHumano.length] = Cartas[SiguienteNroDeCarta]; CartasDeIA[CartasDeIA.length] = Cartas[SiguienteNroDeCarta+1]; SiguienteNroDeCarta = SiguienteNroDeCarta+2; } while (SiguienteNroDeCarta < 4); Mensaje = "Has recibido "+CartasDeHumano[0]; Mensaje = Mensaje+"\nY "+CartasDeHumano[1]; // Agregarlas en pantalla: function AgregarCartasDeHumano () { CartaaAgregar = 0; if (CartasDeHumano.length % 2 == 0) { PosicionDe0 = 256 - CartasDeHumano.length-1 * 50 - 25; } else { PosicionDe0 = 256 - CartasDeHumano.length * 50; } do { Nombre = "CartaDeHumano"+CartasDeHumano[CartaaAgregar]; attachMovie ("sCarta", Nombre, CartaaAgregar); setProperty (Nombre, _x, PosicionDe0+(CartaaAgregar)*150); setProperty (Nombre, _y, 192); set (Nombre+".Text", CartasDeHumano[CartaaAgregar]); CartaaAgregar++; } while (CartaaAgregar < CartasDeHumano.length); } AgregarCartasDeHumano(); // Calcular suma de humano: ValorDeCartaHumana0 = Math.min(10, Number(CartasDeHumano[0].substring(1, CartasDeHumano[0].length))); ValorDeCartaHumana1 = Math.min(10, Number(CartasDeHumano[1].substring(1, CartasDeHumano[1].length))); if (ValorDeCartaHumana0 == 1) { SumaDeHumano = 11+ValorDeCartaHumana1; } else if (ValorDeCarta1 == 1) { SumaDeHumano = ValorDeCartaHumana0+11; } else { SumaDeHumano = ValorDeCartaHumana0+ValorDeCartaHumana1; } Mensaje = Mensaje+"\nTu suma es "+SumaDeHumano; // Calcular suma de IA: ValorDeCartaDeIA0 = Math.min(10, Number(CartasDeIA[0].substring(1, CartasDeIA[0].length))); ValorDeCartaDeIA1 = Math.min(10, Number(CartasDeIA[1].substring(1, CartasDeIA[1].length))); if (ValorDeCartaDeIA0 == 1) { SumaDeIA = 11+ValorDeCartaDeIA1; } else if (ValorDeCartaDeIA1 == 1) { SumaDeIA = ValorDeCartaDeIA0+11; } else { SumaDeIA = ValorDeCartaDeIA0+ValorDeCartaDeIA1; } Mensaje = Mensaje+"\nLa suma del rival es "+SumaDeIA;
No quiero copiar y pegar dibujos de 13*4 cartas. Debo copiar y pegar los 4 íconos (trébol, etc), y según la carta insertar en ella X de esos íconos, distribuídos en ella según el caso. Para J, Q, K y 1 sí usaré los dibujos.
¿Cómo lo hago?
Sobre que aparezca un texto más completo ya se me ocurrió cómo: El programa guarda el 1er caracter, lo quita, pone lo que queda (el número) y luego dependiendo de cual sea el caracter guardado agrega el texto, por ejemplo "tréboles" si es "T". Hago eso ahora.