package roshka.bootcamp.poker; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class PokerJuego { private Carta[] mano; public static void main(String[] args){ System.out.println("POKER HAND GENERATOR\nSe ha generado una mano" + "\n\tHa conseguido las siguientes combinaciones: "); PokerJuego pokerJuego = new PokerJuego(); pokerJuego.cartaAlta(); pokerJuego.doble(); pokerJuego.dobleDoble(); pokerJuego.trio(); pokerJuego.escalera(); pokerJuego.color(); pokerJuego.full(); pokerJuego.poker(); pokerJuego.escaleraColor(); } public PokerJuego(){ this.mano = this.repartirCincoCartas(); // this.mano = new Carta[]{ // new Carta("H", "A", 14), // new Carta("H", "2", 2), // new Carta("H", "3", 3), // new Carta("H", "4", 4), // new Carta("H", "5", 5)}; // Arrays.sort(mano, Comparator.comparing(Carta::getNumericValue).reversed()); // if(mano[1].getValor().equals("2") && mano[4].getValor().equals("A")){ // Carta temp = mano[0]; // mano[0] = mano[4]; // mano[4] = temp; // } } public Carta[] repartirCincoCartas(){ ArrayList mazo = Carta.crearMazo(); Carta[] mano = new Carta[5]; int[] choices = new int[]{-1, -1, -1, -1, -1}; boolean repeatedChoice = false; Scanner in = new Scanner(System.in); int i=0; for(i=0;i<5;i++){ repeatedChoice = false; int choice = (int)(Math.random()*(52)); for(int temp: choices){ if(temp == choice){ i--; repeatedChoice = true; } } if(repeatedChoice) continue; choices[i] = choice; mano[i] = mazo.get(choice); } Arrays.sort(mano, Comparator.comparing(Carta::getNumericValue).reversed()); if(mano[1].getValor().equals("2") && mano[4].getValor().equals("A")){ Carta temp = mano[0]; mano[0] = mano[4]; mano[4] = temp; } return mano; } public void cartaAlta(){ System.out.print("\nCarta Alta: *"); for(Carta carta: mano){ System.out.print("|"+carta.getValor()+""+carta.getPalo()+"|-"); } } public void doble(){ String[] act = new String[5]; boolean exist = false; for(int i=0;i 1){ exist = false; break; } } if(exist){ System.out.print("\nEscalera: "); for(int i=0;i 1 || !(mano[0].getPalo().equals(mano[i + 1].getPalo()))){ exist = false; break; } } if(exist){ System.out.print("\nEscalera Color: "); for(int i=0;i