diff --git a/app/src/main/background-playstore.png b/app/src/main/background-playstore.png new file mode 100644 index 0000000..9498e2c Binary files /dev/null and b/app/src/main/background-playstore.png differ diff --git a/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java b/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java index 8aadb43..1a35a48 100644 --- a/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java +++ b/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java @@ -80,19 +80,22 @@ public class ColorSelectorEvent extends View implements View.OnClickListener { } } - if(countOfBlack == 4) { - String[] opts = new String[] { - "Rejouer", - "Voir votre jeu", - "Retourner au menu" - }; - - Popup popup = new Popup(this.context, opts, true, (10 - this.tentative + 1)); - popup.show(); - } + String[] opts = new String[] { + "Rejouer", + "Voir votre jeu", + "Retourner au menu" + }; this.tentative--; + if(countOfBlack == 4) { + Popup popup = new Popup(this.context, opts, (10 - this.tentative)); + popup.show(); + } else if(this.tentative == 0) { + Popup popup = new Popup(this.context, opts); + popup.show(); + } + TextView tx = (TextView) this.context.findViewById(R.id.counter); tx.setText("Tentative rest. \n" + this.tentative); tx.invalidate(); diff --git a/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java b/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java index bb08000..084d704 100644 --- a/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java +++ b/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java @@ -2,22 +2,29 @@ package com.example.jmastermind.Events; import android.content.DialogInterface; import android.content.Intent; +import android.view.View; +import android.widget.Button; +import android.widget.PopupMenu; import androidx.appcompat.app.AppCompatActivity; import com.example.jmastermind.Game.Popup; import com.example.jmastermind.Game.SoloGame; import com.example.jmastermind.MainActivity; +import com.example.jmastermind.R; -public class PopupEvent implements DialogInterface.OnClickListener { +public class PopupEvent implements DialogInterface.OnClickListener, View.OnClickListener { + private int tentative; private AppCompatActivity context; /** * Event lié au popup de fin de partie * @param context Le context + * @param tentative Le nombre de tentative * */ - public PopupEvent(AppCompatActivity context) { + public PopupEvent(AppCompatActivity context, int tentative) { this.context = context; + this.tentative = tentative; } @Override @@ -30,6 +37,10 @@ public class PopupEvent implements DialogInterface.OnClickListener { } case 1: { + Button btn = (Button) this.context.findViewById(R.id.validate); + btn.setText("Finish HIM"); + btn.setOnClickListener(this); + dialogInterface.cancel(); break; } @@ -41,4 +52,16 @@ public class PopupEvent implements DialogInterface.OnClickListener { } } } + + @Override + public void onClick(View view) { + String[] opts = new String[] { + "Rejouer", + "Voir votre jeu", + "Retourner au menu" + }; + + Popup pop = new Popup(this.context, opts, this.tentative); + pop.show(); + } } diff --git a/app/src/main/java/com/example/jmastermind/Game/Popup.java b/app/src/main/java/com/example/jmastermind/Game/Popup.java index af80e4d..59ca4be 100644 --- a/app/src/main/java/com/example/jmastermind/Game/Popup.java +++ b/app/src/main/java/com/example/jmastermind/Game/Popup.java @@ -1,8 +1,11 @@ package com.example.jmastermind.Game; +import android.widget.Button; + import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import com.example.jmastermind.Events.PopupEvent; +import com.example.jmastermind.R; public class Popup extends AlertDialog.Builder { private AppCompatActivity context; @@ -11,20 +14,18 @@ public class Popup extends AlertDialog.Builder { * Affiche la popup de fin de jeu * @param context Le context * @param options La liste des options (rejouer, ...) - * @param isWinner Esceque le joueur a gagner la partie * @param tentative Le nombre de tentatives * */ - public Popup(AppCompatActivity context, String[] options, Boolean isWinner, int tentative) { + public Popup(AppCompatActivity context, String[] options, int... tentative) { super(context); - this.context = context; - if(isWinner) { - this.setTitle("Félicitation ! Vous avez gagner en : " + tentative + " coup(s)."); - } else { + if(tentative.length > 0) { + this.setTitle("Félicitation ! Vous avez gagner en : " + tentative[0] + " coup(s)."); + } else { this.setTitle("Perdu !"); } - this.setItems(options, new PopupEvent(this.context)); + this.setItems(options, new PopupEvent(this.context, tentative[0])); } } diff --git a/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java b/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java index 2c9e4e1..08aef0b 100644 --- a/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java +++ b/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java @@ -1,18 +1,14 @@ package com.example.jmastermind.Geometrics; - import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.view.View; - import androidx.annotation.Nullable; - public class Circle extends View { private Paint picasso; private int color; - /** * Les cercles du jeu "programmiser" en Java * @param context Le context @@ -23,7 +19,6 @@ public class Circle extends View { this.color = Color.GRAY; this.picasso = new Paint(); } - /** * Recuperer la couleur du cercle * @return La couleur du cercle en int @@ -31,7 +26,6 @@ public class Circle extends View { public int getColor() { return this.color; } - /** * Changer la couleur d'un cercle * @param c La nouvelle couleur @@ -44,12 +38,19 @@ public class Circle extends View { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - int centerX = getWidth() / 2; int centerY = getHeight() / 2; int radius = Math.min(centerX, centerY); this.picasso.setColor(this.color); - canvas.drawCircle(centerX, centerY, radius, this.picasso); + this.picasso.setStyle(Paint.Style.FILL); + + canvas.drawCircle(centerX, centerY, radius-2, this.picasso); + + this.picasso.setColor(Color.GRAY); + this.picasso.setStyle(Paint.Style.STROKE); + this.picasso.setStrokeWidth(5f); + + canvas.drawCircle(centerX, centerY, radius-3, this.picasso); } } diff --git a/app/src/main/java/com/example/jmastermind/MainActivity.java b/app/src/main/java/com/example/jmastermind/MainActivity.java index 92bc607..caf2195 100644 --- a/app/src/main/java/com/example/jmastermind/MainActivity.java +++ b/app/src/main/java/com/example/jmastermind/MainActivity.java @@ -1,8 +1,12 @@ package com.example.jmastermind; import androidx.appcompat.app.AppCompatActivity; + +import android.annotation.SuppressLint; import android.os.Bundle; import android.widget.Button; +import android.widget.ImageView; + import com.example.jmastermind.Events.MenuEvent; import com.example.jmastermind.Game.*; diff --git a/app/src/main/res/drawable/background_background.xml b/app/src/main/res/drawable/background_background.xml new file mode 100644 index 0000000..ca3826a --- /dev/null +++ b/app/src/main/res/drawable/background_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/space.png b/app/src/main/res/drawable/space.png new file mode 100644 index 0000000..e333e17 Binary files /dev/null and b/app/src/main/res/drawable/space.png differ diff --git a/app/src/main/res/layout/game.xml b/app/src/main/res/layout/game.xml index 098313a..e97918e 100644 --- a/app/src/main/res/layout/game.xml +++ b/app/src/main/res/layout/game.xml @@ -7,7 +7,7 @@ android:layout_height="match_parent" android:orientation="horizontal" tools:context=".MainActivity" - android:background="#FFC0CB" + android:background="@drawable/space" >