Mus Online game

0

We are implementing an online mus game, in Java, for which we have created several classes: Jugador , Carta , Mesa and Partida . In this last one we are stuck in how to create the methods of the game of the mus, as they are the turn of Big, Small ...

In this class, we have a List<Jugador> jugadores = new ArrayList<>(); where the 4 players are included and each one has 4 cards, and you order from highest to lowest score.

I do not know if someone could help us out. There I leave the code of departure until the moment

public class Partida {

List<Jugador> lJugadores = null;
Mesa m1 =null;

public Partida()
{
    for(int i = 0;i<4;i++)
    {
        this.lJugadores.add(new Jugador());
    }

     m1 = new Mesa();
}

public void iniciarPartida()
{
    for(Jugador j : this.lJugadores)
    {
        j.obtenerCartaInicial(m1);
    }
}

public void mus()
{
    boolean b = true;
    while(b)
    {

        //Comprobamos si quiere mus ( 1-4) o no quieren (0)
        int [] numCartas = new int[4];
        int n = 0;
        for(Jugador j : this.lJugadores)
        {
            j.mostrarCartas();
            numCartas[n] = j.quiereMus();

        }


        int i = 0;
        while(i<4 && b==true)
        {
            if(numCartas[i]==0)
            {
                b = false;
            }
            i++;
        }
        //Si hay mus
        if(b)
        {   
            Scanner entrada = new Scanner(System.in);
            for(Jugador j : this.lJugadores)
            {
                j.mostrarCartas();
                System.out.println("¿Qué cartas quieres quitarte? [0-3]");

                for(int i2 =0; i2<numCartas[i2];i++)
                {
                    int posicion = entrada.nextInt();
                    Carta c = j.cartas.remove(posicion);
                    this.m1.añadirCartaMontonMus(c);
                    if(!this.m1.montonVacio())
                    {
                        j.cartas.add(posicion, this.m1.getCartaMonton());
                    }
                    else {
                        j.cartas.add(posicion, this.m1.getCartaMus());
                    }
                }
            }
        }
    }

}

public void cambiarMano()
{
    Jugador j1 = this.lJugadores.get(0);
    this.lJugadores.remove(j1);
    this.lJugadores.add(j1);
}
    
asked by Fernando Ortiz 15.11.2018 в 18:32
source

0 answers