$
BIN
app/src/main/background-playstore.png
Normal file
After Width: | Height: | Size: 160 KiB |
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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.*;
|
||||
|
||||
|
74
app/src/main/res/drawable/background_background.xml
Normal 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>
|
BIN
app/src/main/res/drawable/space.png
Normal file
After Width: | Height: | Size: 1.8 MiB |
@ -7,7 +7,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".MainActivity"
|
||||
android:background="#FFC0CB"
|
||||
android:background="@drawable/space"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
@ -810,6 +810,9 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:background="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:layout_gravity="center"
|
||||
android:text="Tentatives rest. \n 10" />
|
||||
|
||||
<com.example.jmastermind.Geometrics.Circle
|
||||
@ -857,12 +860,18 @@
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:layout_gravity="center"
|
||||
android:text="Valider"
|
||||
android:id="@+id/validate" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:backgroundTint="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="Effacer"
|
||||
android:id="@+id/reset" />
|
||||
</LinearLayout>
|
||||
|
@ -6,7 +6,7 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:background="#FFC0CB"
|
||||
android:background="@drawable/space"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
@ -15,7 +15,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="40dp"
|
||||
android:textColor="@color/purple_700"
|
||||
android:textColor="@color/white"
|
||||
android:gravity="center"
|
||||
android:text="JMastermind" />
|
||||
|
||||
@ -29,6 +29,8 @@
|
||||
android:id="@+id/robotselect"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:text="Joueur vs Robot"
|
||||
/>
|
||||
|
||||
@ -36,11 +38,15 @@
|
||||
android:id="@+id/jcjselect"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:text="Joueur contre Joueur" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/rules"
|
||||
android:layout_width="wrap_content"
|
||||
android:backgroundTint="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Regles du jeu" />
|
||||
</LinearLayout>
|
||||
|
5
app/src/main/res/mipmap-anydpi-v26/background.xml
Normal 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>
|
5
app/src/main/res/mipmap-anydpi-v26/background_round.xml
Normal 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>
|
BIN
app/src/main/res/mipmap-hdpi/background.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
app/src/main/res/mipmap-hdpi/background_foreground.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
app/src/main/res/mipmap-hdpi/background_round.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/background.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/background_foreground.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
app/src/main/res/mipmap-mdpi/background_round.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/main/res/mipmap-xhdpi/background.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
app/src/main/res/mipmap-xhdpi/background_foreground.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
app/src/main/res/mipmap-xhdpi/background_round.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/background.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/background_foreground.png
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/background_round.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/background.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/background_foreground.png
Normal file
After Width: | Height: | Size: 129 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/background_round.png
Normal file
After Width: | Height: | Size: 26 KiB |