mirror of
https://github.com/Aviortheking/Hangman.git
synced 2024-12-19 18:20:54 +00:00
finishing
need to add the hangman
This commit is contained in:
parent
343b8016bd
commit
bd242274bb
@ -28,7 +28,7 @@
|
||||
android:name=".GameActivity"
|
||||
android:theme="@style/DeltaWings.Color"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustPan">
|
||||
android:windowSoftInputMode="stateAlwaysVisible|adjustResize">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".settings.SettingActivity"
|
||||
|
@ -99,6 +99,7 @@ public class GameActivity extends AppCompatActivity {
|
||||
input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
|
||||
EditText editText = ((EditText) v);
|
||||
String word = editText.getText().toString().toLowerCase();
|
||||
|
||||
@ -129,6 +130,9 @@ public class GameActivity extends AppCompatActivity {
|
||||
} else {
|
||||
Toast.makeText(MainActivity.getInstance(), "Incorrect letter!", Toast.LENGTH_LONG).show();
|
||||
//update image
|
||||
if(letters.size() == 10) {
|
||||
lost();
|
||||
}
|
||||
}
|
||||
editText.setText("");
|
||||
|
||||
@ -142,6 +146,9 @@ public class GameActivity extends AppCompatActivity {
|
||||
} else {
|
||||
Toast.makeText(MainActivity.getInstance(), "Incorrect word!", Toast.LENGTH_LONG).show();
|
||||
//update image
|
||||
if(letters.size() == 10) {
|
||||
lost();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -251,7 +258,7 @@ public class GameActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void win() {
|
||||
new Command().execute("AFFICHER|You won !!!");
|
||||
new Command().execute("AFFICHER|Tu as gagné !!!");
|
||||
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@ -275,9 +282,40 @@ public class GameActivity extends AppCompatActivity {
|
||||
};
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setMessage("You won!")
|
||||
.setPositiveButton("Restart", clickListener)
|
||||
.setNegativeButton("Quit", clickListener)
|
||||
.setMessage("Tu as gagné!")
|
||||
.setPositiveButton("Recommencer", clickListener)
|
||||
.setNegativeButton("Quitter", clickListener)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void lost() {
|
||||
new Command().execute("AFFICHER|Tu as perdu !!!");
|
||||
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which){
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
//Close Connection
|
||||
Intent intent = getIntent();
|
||||
overridePendingTransition(0, 0);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
finish();
|
||||
|
||||
overridePendingTransition(0, 0);
|
||||
startActivity(intent);
|
||||
break;
|
||||
default:
|
||||
finish();
|
||||
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setMessage("Tu as perdu :( !")
|
||||
.setPositiveButton("Recommencer", clickListener)
|
||||
.setNegativeButton("Quitter", clickListener)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
instance = this;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if(getPref("setting_theme", this.getApplicationContext()) != "Color") {
|
||||
setPref("setting_theme", "Color", this.getApplicationContext());
|
||||
}
|
||||
|
||||
setTheme(this);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
|
@ -2,7 +2,8 @@ package net.DeltaWings.Android.Hangman.Util;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import net.DeltaWings.Android.Hangman.MainActivity;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
@ -23,12 +24,6 @@ public class Command extends AsyncTask<String, Integer, Long> {
|
||||
} catch (IOException e){
|
||||
System.out.println("\nDEBUG:\texception IOException");
|
||||
System.out.println( e.getMessage() );
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.println("\nDEBUG:\texception ClassNotFoundException");
|
||||
System.out.println( e.getMessage() );
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("\nDEBUG:\texception InterruptedException");
|
||||
System.out.println( e.getMessage() );
|
||||
}
|
||||
|
||||
publishProgress((int) (50));
|
||||
@ -45,57 +40,23 @@ public class Command extends AsyncTask<String, Integer, Long> {
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
public void envoyer_commande(String c) throws IOException, ClassNotFoundException, InterruptedException {
|
||||
public void envoyer_commande(String c) throws IOException {
|
||||
System.out.println("\nDEBUG:\tenvoyer_commande");
|
||||
|
||||
Socket socket = null;
|
||||
DataOutputStream dataOutputStream = null;
|
||||
DataInputStream dataInputStream = null;
|
||||
Socket socket = new Socket(MainActivity.getPref("setting_ip", MainActivity.instance.getApplicationContext()), Integer.parseInt(MainActivity.getPref("setting_port", MainActivity.instance.getApplicationContext())));
|
||||
|
||||
try {
|
||||
//establish socket connection to server
|
||||
socket = new Socket("192.168.0.2", 53000);
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
|
||||
dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
System.out.println("\nDEBUG:\tConnexion ok");
|
||||
System.out.println("\nDEBUG:\tdebut envoi");
|
||||
dataOutputStream.writeBytes(c);
|
||||
System.out.println("\nDEBUG:\tfinenvoi");
|
||||
|
||||
System.out.println("\nDEBUG:\tConnexion ok");
|
||||
System.out.println("\nDEBUG:\tdebut envoi");
|
||||
dataOutputStream.writeBytes(c);
|
||||
System.out.println("\nDEBUG:\tfinenvoi");
|
||||
System.out.println("\nDEBUG:\tdebut reception");
|
||||
System.out.println("\nDEBUG:\tfin réception");
|
||||
|
||||
System.out.println("\nDEBUG:\tdebut reception");
|
||||
System.out.println("\nDEBUG:\tfin réception");
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (socket != null) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dataOutputStream != null){
|
||||
try {
|
||||
dataOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (dataInputStream != null){
|
||||
try {
|
||||
dataInputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
socket.close();
|
||||
dataOutputStream.close();
|
||||
|
||||
System.out.println("\nDEBUG:\tFin envoyer_commande");
|
||||
}
|
||||
|
@ -5,9 +5,10 @@ import android.util.Log;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
@ -26,13 +27,13 @@ public class GameUtil {
|
||||
|
||||
JSONObject obj = null;
|
||||
|
||||
String s = "https://raw.githubusercontent.com/dwyl/english-words/master/words_dictionary.json";
|
||||
|
||||
String r = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader("/sdcard/list.txt"));
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("/sdcard/list.txt"), "UTF-8"));
|
||||
|
||||
String line = br.readLine();
|
||||
|
||||
|
@ -4,6 +4,6 @@
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#fff"
|
||||
<path android:fillColor="?android:attr/textColorPrimary"
|
||||
android:pathData="M11,13.5V21.5H3V13.5H11M9,15.5H5V19.5H9V15.5M12,2L17.5,11H6.5L12,2M12,5.86L10.08,9H13.92L12,5.86M17.5,13C20,13 22,15 22,17.5C22,20 20,22 17.5,22C15,22 13,20 13,17.5C13,15 15,13 17.5,13M17.5,15A2.5,2.5 0 0,0 15,17.5A2.5,2.5 0 0,0 17.5,20A2.5,2.5 0 0,0 20,17.5A2.5,2.5 0 0,0 17.5,15Z" />
|
||||
</vector>
|
@ -11,7 +11,7 @@
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:text="TextView"
|
||||
android:text="Fait par Florian Bouillon, Matéo Boulben et Killian Orain mots récupéré sur jsp.com"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -65,6 +65,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.50"
|
||||
android:contentDescription="image"
|
||||
app:srcCompat="@mipmap/logo"/>
|
||||
</LinearLayout>
|
||||
|
||||
@ -73,7 +74,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:text="null"
|
||||
android:textAlignment="center"
|
||||
android:textSize="36sp"
|
||||
android:textStyle="bold"/>
|
||||
@ -84,13 +84,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:ems="10"
|
||||
android:hint="Écrit une lettre/un mot"
|
||||
android:inputType="textPersonName"
|
||||
android:maxLength="16"
|
||||
android:maxLines="1"
|
||||
android:selectAllOnFocus="false"
|
||||
android:windowSoftInputMode="adjustResize|adjustPan"
|
||||
android:text="Name"
|
||||
android:textAlignment="center"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="36sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
<string name="setting_general_theme">Theme</string>
|
||||
<string name="setting_general_ip">Select the server IP</string>
|
||||
<string name="setting_general_port">Select the server port</string>
|
||||
|
||||
<string name="setting_single_title">Singleplayer</string>
|
||||
<string name="setting_single_desc">Singleplayer Configuration</string>
|
||||
|
@ -26,16 +26,19 @@
|
||||
<!-- Custom Elements -->
|
||||
|
||||
<!-- Android -->
|
||||
<item name="android:textColor">@color/Black</item>
|
||||
<item name="android:textColorPrimary">@color/Black</item>
|
||||
<item name="android:textColorPrimaryInverse">@color/Black</item>
|
||||
<item name="android:colorBackground">@color/Grey50</item>
|
||||
<item name="android:windowBackground">@color/Grey50</item>
|
||||
<item name="android:colorAccent">@color/BlueGrey500</item>
|
||||
<item name="android:textColorPrimary">@color/Grey900</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="DeltaWings.Color" parent="Theme.AppCompat.Light">
|
||||
|
||||
<!-- Drawables -->
|
||||
|
||||
<item name="drawable_people">@drawable/people</item>
|
||||
<item name="drawable_person">@drawable/person</item>
|
||||
|
||||
|
@ -1,15 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference
|
||||
<!--<ListPreference
|
||||
android:defaultValue="Color"
|
||||
android:entries="@array/theme"
|
||||
android:entryValues="@array/theme"
|
||||
android:key="setting_theme"
|
||||
android:title="@string/setting_general_theme"/>
|
||||
android:title="@string/setting_general_theme"/>-->
|
||||
<EditTextPreference
|
||||
android:defaultValue="192.168.0.2"
|
||||
android:key="setting_ip"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/setting_general_ip"/>
|
||||
<EditTextPreference
|
||||
android:defaultValue="53000"
|
||||
android:key="setting_port"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/setting_general_port"/>
|
||||
</PreferenceScreen>
|
@ -4,15 +4,16 @@
|
||||
android:icon="@drawable/shape_outline"
|
||||
android:title="@string/setting_general_title"
|
||||
android:summary="@string/setting_general_desc" />
|
||||
<!--
|
||||
<header android:fragment="net.DeltaWings.Android.Hangman.settings.singleOptions"
|
||||
android:icon="?attr/drawable_person"
|
||||
android:title="@string/setting_single_title"
|
||||
android:summary="@string/setting_single_desc" />
|
||||
|
||||
<header android:fragment="net.DeltaWings.Android.Hangman.settings.singleOptions"
|
||||
android:icon="?attr/drawable_person"
|
||||
android:title="@string/setting_single_title"
|
||||
android:summary="@string/setting_single_desc" />
|
||||
<header android:fragment="net.DeltaWings.Android.Hangman.settings.multiOptions"
|
||||
android:icon="?attr/drawable_people"
|
||||
android:title="@string/setting_multi_title"
|
||||
android:summary="@string/setting_multi_desc" />
|
||||
-->
|
||||
|
||||
<header android:fragment="net.DeltaWings.Android.Hangman.settings.multiOptions"
|
||||
android:icon="?attr/drawable_people"
|
||||
android:title="@string/setting_multi_title"
|
||||
android:summary="@string/setting_multi_desc" />
|
||||
|
||||
</preference-headers>
|
||||
</preference-headers>
|
Loading…
x
Reference in New Issue
Block a user