This commit is contained in:
pro.boooooo 2023-04-01 03:17:07 +02:00
parent fe364094ef
commit eb826b077a
27 changed files with 161 additions and 30 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@ -80,19 +80,22 @@ public class ColorSelectorEvent extends View implements View.OnClickListener {
} }
} }
if(countOfBlack == 4) {
String[] opts = new String[] { String[] opts = new String[] {
"Rejouer", "Rejouer",
"Voir votre jeu", "Voir votre jeu",
"Retourner au menu" "Retourner au menu"
}; };
Popup popup = new Popup(this.context, opts, true, (10 - this.tentative + 1)); 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(); popup.show();
} }
this.tentative--;
TextView tx = (TextView) this.context.findViewById(R.id.counter); TextView tx = (TextView) this.context.findViewById(R.id.counter);
tx.setText("Tentative rest. \n" + this.tentative); tx.setText("Tentative rest. \n" + this.tentative);
tx.invalidate(); tx.invalidate();

View File

@ -2,22 +2,29 @@ package com.example.jmastermind.Events;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.PopupMenu;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.example.jmastermind.Game.Popup; import com.example.jmastermind.Game.Popup;
import com.example.jmastermind.Game.SoloGame; import com.example.jmastermind.Game.SoloGame;
import com.example.jmastermind.MainActivity; 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; private AppCompatActivity context;
/** /**
* Event lié au popup de fin de partie * Event lié au popup de fin de partie
* @param context Le context * @param context Le context
* @param tentative Le nombre de tentative
* */ * */
public PopupEvent(AppCompatActivity context) { public PopupEvent(AppCompatActivity context, int tentative) {
this.context = context; this.context = context;
this.tentative = tentative;
} }
@Override @Override
@ -30,6 +37,10 @@ public class PopupEvent implements DialogInterface.OnClickListener {
} }
case 1: { case 1: {
Button btn = (Button) this.context.findViewById(R.id.validate);
btn.setText("Finish HIM");
btn.setOnClickListener(this);
dialogInterface.cancel(); dialogInterface.cancel();
break; 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();
}
} }

View File

@ -1,8 +1,11 @@
package com.example.jmastermind.Game; package com.example.jmastermind.Game;
import android.widget.Button;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.example.jmastermind.Events.PopupEvent; import com.example.jmastermind.Events.PopupEvent;
import com.example.jmastermind.R;
public class Popup extends AlertDialog.Builder { public class Popup extends AlertDialog.Builder {
private AppCompatActivity context; private AppCompatActivity context;
@ -11,20 +14,18 @@ public class Popup extends AlertDialog.Builder {
* Affiche la popup de fin de jeu * Affiche la popup de fin de jeu
* @param context Le context * @param context Le context
* @param options La liste des options (rejouer, ...) * @param options La liste des options (rejouer, ...)
* @param isWinner Esceque le joueur a gagner la partie
* @param tentative Le nombre de tentatives * @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); super(context);
this.context = context; this.context = context;
if(isWinner) { if(tentative.length > 0) {
this.setTitle("Félicitation ! Vous avez gagner en : " + tentative + " coup(s)."); this.setTitle("Félicitation ! Vous avez gagner en : " + tentative[0] + " coup(s).");
} else { } else {
this.setTitle("Perdu !"); this.setTitle("Perdu !");
} }
this.setItems(options, new PopupEvent(this.context)); this.setItems(options, new PopupEvent(this.context, tentative[0]));
} }
} }

View File

@ -1,18 +1,14 @@
package com.example.jmastermind.Geometrics; package com.example.jmastermind.Geometrics;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
public class Circle extends View { public class Circle extends View {
private Paint picasso; private Paint picasso;
private int color; private int color;
/** /**
* Les cercles du jeu "programmiser" en Java * Les cercles du jeu "programmiser" en Java
* @param context Le context * @param context Le context
@ -23,7 +19,6 @@ public class Circle extends View {
this.color = Color.GRAY; this.color = Color.GRAY;
this.picasso = new Paint(); this.picasso = new Paint();
} }
/** /**
* Recuperer la couleur du cercle * Recuperer la couleur du cercle
* @return La couleur du cercle en int * @return La couleur du cercle en int
@ -31,7 +26,6 @@ public class Circle extends View {
public int getColor() { public int getColor() {
return this.color; return this.color;
} }
/** /**
* Changer la couleur d'un cercle * Changer la couleur d'un cercle
* @param c La nouvelle couleur * @param c La nouvelle couleur
@ -44,12 +38,19 @@ public class Circle extends View {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
super.onDraw(canvas); super.onDraw(canvas);
int centerX = getWidth() / 2; int centerX = getWidth() / 2;
int centerY = getHeight() / 2; int centerY = getHeight() / 2;
int radius = Math.min(centerX, centerY); int radius = Math.min(centerX, centerY);
this.picasso.setColor(this.color); 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);
} }
} }

View File

@ -1,8 +1,12 @@
package com.example.jmastermind; package com.example.jmastermind;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView;
import com.example.jmastermind.Events.MenuEvent; import com.example.jmastermind.Events.MenuEvent;
import com.example.jmastermind.Game.*; import com.example.jmastermind.Game.*;

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

@ -7,7 +7,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
tools:context=".MainActivity" tools:context=".MainActivity"
android:background="#FFC0CB" android:background="@drawable/space"
> >
<LinearLayout <LinearLayout
@ -810,6 +810,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:background="@color/white"
android:textColor="@color/black"
android:layout_gravity="center"
android:text="Tentatives rest. \n 10" /> android:text="Tentatives rest. \n 10" />
<com.example.jmastermind.Geometrics.Circle <com.example.jmastermind.Geometrics.Circle
@ -857,12 +860,18 @@
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:textColor="@color/black"
android:layout_gravity="center"
android:text="Valider" android:text="Valider"
android:id="@+id/validate" /> android:id="@+id/validate" />
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:backgroundTint="@color/white"
android:textColor="@color/black"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Effacer" android:text="Effacer"
android:id="@+id/reset" /> android:id="@+id/reset" />
</LinearLayout> </LinearLayout>

View File

@ -6,7 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity" tools:context=".MainActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:background="#FFC0CB" android:background="@drawable/space"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
> >
@ -15,7 +15,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="40dp" android:textSize="40dp"
android:textColor="@color/purple_700" android:textColor="@color/white"
android:gravity="center" android:gravity="center"
android:text="JMastermind" /> android:text="JMastermind" />
@ -29,6 +29,8 @@
android:id="@+id/robotselect" android:id="@+id/robotselect"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:textColor="@color/black"
android:text="Joueur vs Robot" android:text="Joueur vs Robot"
/> />
@ -36,11 +38,15 @@
android:id="@+id/jcjselect" android:id="@+id/jcjselect"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:textColor="@color/black"
android:text="Joueur contre Joueur" /> android:text="Joueur contre Joueur" />
<Button <Button
android:id="@+id/rules" android:id="@+id/rules"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:backgroundTint="@color/white"
android:textColor="@color/black"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Regles du jeu" /> android:text="Regles du jeu" />
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/background_background"/>
<foreground android:drawable="@mipmap/background_foreground"/>
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/background_background"/>
<foreground android:drawable="@mipmap/background_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB