bouton annuler fonctionnel + condition victoire (un peu degueu)
This commit is contained in:
		@@ -40,7 +40,7 @@ public class GameView extends View {
 | 
			
		||||
        //copie des soumissions
 | 
			
		||||
        LinkedList<Integer> grille = new LinkedList<Integer>();
 | 
			
		||||
        grille.addAll(this.grille.getSoumissions());
 | 
			
		||||
        System.out.println(grille.size());
 | 
			
		||||
        //System.out.println(grille.size());
 | 
			
		||||
        for (int y=0; y<10;y++) {
 | 
			
		||||
            for (int x=0;x<4;x++) {
 | 
			
		||||
                this.circle.setColor(grille.pop());
 | 
			
		||||
@@ -62,7 +62,7 @@ public class GameView extends View {
 | 
			
		||||
        //copie des couleurs dispos
 | 
			
		||||
        LinkedList<Integer> couleurs = new LinkedList<Integer>();
 | 
			
		||||
        couleurs.addAll(this.saisie.getChoix());
 | 
			
		||||
        System.out.println(couleurs.size());
 | 
			
		||||
        //System.out.println(couleurs.size());
 | 
			
		||||
        for (int i=0;i<this.saisie.getChoix().size();i++){
 | 
			
		||||
            this.circle.setColor(couleurs.pop());
 | 
			
		||||
            //TODO: coordonnées propres (encore)
 | 
			
		||||
@@ -71,14 +71,12 @@ public class GameView extends View {
 | 
			
		||||
        //TODO: ajout des colonnes de notation
 | 
			
		||||
        LinkedList<Integer> notation = new LinkedList<Integer>();
 | 
			
		||||
        notation.addAll(this.grille.getNotations());
 | 
			
		||||
        for(int y=0; y<10; y++) { // colonne gauche
 | 
			
		||||
            for(int x=0; x<2; x++) {
 | 
			
		||||
        for(int y=0; y<10; y++) {
 | 
			
		||||
            for(int x=0; x<2; x++) { // colonne gauche
 | 
			
		||||
                this.circle.setColor(notation.pop());
 | 
			
		||||
                canvas.drawCircle((x*this.getWidth()/11+(this.getWidth()/11)),(y*this.getHeight()/14+getHeight()/21), this.getWidth()/26, this.circle);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        for(int y=0; y<10; y++) { // colonne droite
 | 
			
		||||
            for(int x=0; x<2; x++) {
 | 
			
		||||
            for(int x=0; x<2; x++) { // colonne droite
 | 
			
		||||
                this.circle.setColor(notation.pop());
 | 
			
		||||
                canvas.drawCircle((x*this.getWidth()/11+(this.getWidth()*4/5)),(y*this.getHeight()/14+getHeight()/21), this.getWidth()/26, this.circle);
 | 
			
		||||
            }
 | 
			
		||||
@@ -99,24 +97,50 @@ public class GameView extends View {
 | 
			
		||||
    //Change l'état de soumission à notation après qu'une combinaision ai été soumise puis inversement
 | 
			
		||||
    public void changeState() {
 | 
			
		||||
        if (this.saisie.getSizeSelection() == 4) {
 | 
			
		||||
            //partie à décommenter pour acceder à la notation
 | 
			
		||||
            /*this.state = !this.state;
 | 
			
		||||
            this.state = !this.state;
 | 
			
		||||
            if (this.state) {
 | 
			
		||||
                this.saisie.setChoix(this.pionsAttaquant);
 | 
			
		||||
                this.grille.addNotation(this.saisie.getSelection());
 | 
			
		||||
            } else if (!this.state) {
 | 
			
		||||
                this.saisie.setChoix(this.pionsDefenseur);
 | 
			
		||||
            }*/
 | 
			
		||||
            this.grille.addSoumission(this.saisie.getSelection());
 | 
			
		||||
                this.grille.addSoumission(this.saisie.getSelection());
 | 
			
		||||
            }
 | 
			
		||||
            this.saisie.initSelection(this.getResources().getColor(R.color.pionVide));
 | 
			
		||||
            this.invalidate();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean getState() {
 | 
			
		||||
        return this.state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //ajoute une nouvelle couleur pour la séléction à soumettre
 | 
			
		||||
    public void addChoix(int choix){
 | 
			
		||||
        this.saisie.addSelection(choix);
 | 
			
		||||
        this.invalidate();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*public void removeChoix() {
 | 
			
		||||
        this.saisie.removeSelection(this.getResources().getColor(R.color.pionVide));
 | 
			
		||||
        this.invalidate();
 | 
			
		||||
    }*/
 | 
			
		||||
 | 
			
		||||
    public void clearChoix() {
 | 
			
		||||
        this.saisie.getSelection().clear();
 | 
			
		||||
        this.saisie.initSelection(R.color.pionVide);
 | 
			
		||||
        this.invalidate();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean conditionVictoire(int choix) {
 | 
			
		||||
        if(choix==4) {
 | 
			
		||||
            System.out.println("WIN");
 | 
			
		||||
            return true;
 | 
			
		||||
        } else {
 | 
			
		||||
            System.out.println("LOSE");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //initialise les collections de pions et remplie saisie et grille de pions vides
 | 
			
		||||
    public void initpions(){
 | 
			
		||||
        //on initialise les pions
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,13 @@ public class Saisie {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*public void removeSelection(Integer color) {
 | 
			
		||||
        if(this.sizeSelection<=4) {
 | 
			
		||||
            this.sizeSelection-=1;
 | 
			
		||||
            this.selection.set(this.sizeSelection, this.choix.get(color));
 | 
			
		||||
        }
 | 
			
		||||
    }*/
 | 
			
		||||
 | 
			
		||||
    public int getSizeSelection(){
 | 
			
		||||
        return this.sizeSelection;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import android.view.View;
 | 
			
		||||
 | 
			
		||||
public class TouchListener implements View.OnTouchListener{
 | 
			
		||||
    private GameView view;
 | 
			
		||||
    private int i = 0;
 | 
			
		||||
    public TouchListener(GameView view) {
 | 
			
		||||
        this.view=view;
 | 
			
		||||
    }
 | 
			
		||||
@@ -22,6 +23,9 @@ public class TouchListener implements View.OnTouchListener{
 | 
			
		||||
                    this.view.addChoix(0);
 | 
			
		||||
                } else if(v.getWidth()*2/13+v.getWidth()/8-v.getWidth()/15<x && x<v.getWidth()*2/13+v.getWidth()/8+v.getWidth()/15){
 | 
			
		||||
                    this.view.addChoix(1);
 | 
			
		||||
                    if(!this.view.getState()) {
 | 
			
		||||
                        i++;
 | 
			
		||||
                    }
 | 
			
		||||
                } else if(2*v.getWidth()*2/13+v.getWidth()/8-v.getWidth()/15<x && x<2*v.getWidth()*2/13+v.getWidth()/8+v.getWidth()/15) {
 | 
			
		||||
                    this.view.addChoix(2);
 | 
			
		||||
                } else if(3*v.getWidth()*2/13+v.getWidth()/8-v.getWidth()/15<x && x<3*v.getWidth()*2/13+v.getWidth()/8+v.getWidth()/15){
 | 
			
		||||
@@ -31,10 +35,18 @@ public class TouchListener implements View.OnTouchListener{
 | 
			
		||||
                } else if(5*v.getWidth()*2/13+v.getWidth()/8-v.getWidth()/15<x && x<5*v.getWidth()*2/13+v.getWidth()/8+v.getWidth()/15){
 | 
			
		||||
                    this.view.addChoix(5);
 | 
			
		||||
                }
 | 
			
		||||
            // surveille si un bouton de controle est cliqué (ici seule la soumission est gérée)
 | 
			
		||||
            // surveille si un bouton de controle est cliqué
 | 
			
		||||
            } else if (v.getHeight()-v.getWidth()/16-v.getWidth()/13<y && y<v.getHeight()-v.getHeight()/16+v.getWidth()/13){
 | 
			
		||||
                if(v.getWidth()/2+(v.getWidth()/11)*2-v.getWidth()/13<x && x<v.getWidth()/2+(v.getWidth()/11)*2+v.getWidth()/13) {
 | 
			
		||||
                if(v.getWidth()/2+(v.getWidth()/11)*2-v.getWidth()/13<x && x<v.getWidth()/2+(v.getWidth()/11)*2+v.getWidth()/13) { // soumettre
 | 
			
		||||
                    if(!this.view.getState()) {
 | 
			
		||||
                        this.view.conditionVictoire(i);
 | 
			
		||||
                    }
 | 
			
		||||
                    this.view.changeState();
 | 
			
		||||
                    i = 0;
 | 
			
		||||
                } else if (v.getWidth()/2-v.getWidth()/13<x && x<v.getWidth()/2+v.getWidth()/13) { // retour
 | 
			
		||||
                    //this.view.removeChoix();
 | 
			
		||||
                } else if (v.getWidth()/2-(v.getWidth()/11)*2-v.getWidth()/13<x && x<v.getWidth()/2-(v.getWidth()/11)*2+v.getWidth()/13) { // annuler
 | 
			
		||||
                    this.view.clearChoix();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user