www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 606f1c0081dd0b165fca300c08bdc65d40487364
parent bd3030223e59bfe5953436239b58eec217b673dc
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Wed,  2 Feb 2011 18:33:26 +0100

Merge branch 'master', remote branch 'origin'

Diffstat:
M.gitignore | 4++--
Mcode/PtiClic/AndroidManifest.xml | 1+
Rcode/images/Aide72.png -> code/PtiClic/res/drawable-hdpi/aide.png | 0
Rcode/images/Contenant72.png -> code/PtiClic/res/drawable-hdpi/contenant.png | 0
Rcode/images/Contenu72.png -> code/PtiClic/res/drawable-hdpi/contenu.png | 0
Rcode/images/Contraire72.png -> code/PtiClic/res/drawable-hdpi/contraire.png | 0
Rcode/images/ModeNormal72.png -> code/PtiClic/res/drawable-hdpi/mode_normal.png | 0
Rcode/images/ModeOmbre72.png -> code/PtiClic/res/drawable-hdpi/mode_ombre.png | 0
Rcode/images/Rapport72.png -> code/PtiClic/res/drawable-hdpi/rapport.png | 0
Rcode/images/FondLogo.png -> code/PtiClic/res/drawable-hdpi/splash.png | 0
Rcode/images/Synonyme72.png -> code/PtiClic/res/drawable-hdpi/synonyme.png | 0
Rcode/images/Aide36.png -> code/PtiClic/res/drawable-ldpi/aide.png | 0
Rcode/images/Contenant36.png -> code/PtiClic/res/drawable-ldpi/contenant.png | 0
Rcode/images/Contenu36.png -> code/PtiClic/res/drawable-ldpi/contenu.png | 0
Rcode/images/Contraire36.png -> code/PtiClic/res/drawable-ldpi/contraire.png | 0
Rcode/images/ModeNormal36.png -> code/PtiClic/res/drawable-ldpi/mode_normal.png | 0
Rcode/images/ModeOmbre36.png -> code/PtiClic/res/drawable-ldpi/mode_ombre.png | 0
Rcode/images/Rapport36.png -> code/PtiClic/res/drawable-ldpi/rapport.png | 0
Rcode/images/FondLogo.png -> code/PtiClic/res/drawable-ldpi/splash.png | 0
Rcode/images/Synonyme36.png -> code/PtiClic/res/drawable-ldpi/synonyme.png | 0
Rcode/images/Aide48.png -> code/PtiClic/res/drawable-mdpi/aide.png | 0
Rcode/images/Contenant48.png -> code/PtiClic/res/drawable-mdpi/contenant.png | 0
Rcode/images/Contenu48.png -> code/PtiClic/res/drawable-mdpi/contenu.png | 0
Rcode/images/Contraire48.png -> code/PtiClic/res/drawable-mdpi/contraire.png | 0
Rcode/images/ModeNormal48.png -> code/PtiClic/res/drawable-mdpi/mode_normal.png | 0
Rcode/images/ModeOmbre48.png -> code/PtiClic/res/drawable-mdpi/mode_ombre.png | 0
Rcode/images/Rapport48.png -> code/PtiClic/res/drawable-mdpi/rapport.png | 0
Rcode/images/FondLogo.png -> code/PtiClic/res/drawable-mdpi/splash.png | 0
Rcode/images/Synonyme48.png -> code/PtiClic/res/drawable-mdpi/synonyme.png | 0
Acode/PtiClic/res/layout/frontpage.xml | 43+++++++++++++++++++++++++++++++++++++++++++
Mcode/PtiClic/res/layout/game.xml | 38++++++++++++++++++++++----------------
Mcode/PtiClic/res/layout/main.xml | 49+++++--------------------------------------------
Mcode/PtiClic/res/raw/info.html | 26+++++++++++++++-----------
Acode/PtiClic/src/org/pticlic/FrontPage.java | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Mcode/PtiClic/src/org/pticlic/Main.java | 48+++++++++++++++---------------------------------
Mcode/PtiClic/src/org/pticlic/Score.java | 7+++----
Mcode/PtiClic/src/org/pticlic/games/BaseGame.java | 25++++++++++++++-----------
Dcode/PtiClic/src/org/pticlic/model/DownloadedScore.java | 11-----------
Dcode/PtiClic/src/org/pticlic/model/GamePlayed.java | 49-------------------------------------------------
Acode/PtiClic/src/org/pticlic/model/Match.java | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcode/PtiClic/src/org/pticlic/model/Network.java | 67++++++++++++++++++++++++++++++++++++++++++++-----------------------
Acode/PtiClic/src/org/pticlic/model/TotalScore.java | 46++++++++++++++++++++++++++++++++++++++++++++++
Acode/PtiClic/src/org/pticlic/model/WordScore.java | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dcode/images/Config36.png | 0
Dcode/images/Config48.png | 0
Dcode/images/Config72.png | 0
Dcode/images/ModeChrono36.png | 0
Dcode/images/ModeChrono48.png | 0
Dcode/images/ModeChrono72.png | 0
Dcode/images/ModeMarathon36.png | 0
Dcode/images/ModeMarathon48.png | 0
Dcode/images/ModeMarathon72.png | 0
Mcode/serveur/.gitignore | 2+-
Mcode/serveur/dump2sqlite.sh | 2++
Dcode/serveur/php/config.php | 10----------
Dcode/serveur/php/function.php | 37-------------------------------------
Mcode/serveur/php/pticlic.php | 62+++++++++++++++++++++++++++++++++++---------------------------
57 files changed, 446 insertions(+), 279 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1 +1,2 @@ -.DS_Store -\ No newline at end of file +.DS_Store +code.zip diff --git a/code/PtiClic/AndroidManifest.xml b/code/PtiClic/AndroidManifest.xml @@ -14,6 +14,7 @@ <activity android:name=".games.BaseGame" android:screenOrientation="portrait"></activity> <activity android:label="Information" android:name=".Information" android:screenOrientation="portrait"></activity> <activity android:name=".Score" android:label="Score" android:screenOrientation="portrait"></activity> +<activity android:name=".FrontPage" android:screenOrientation="portrait"></activity> </application> diff --git a/code/images/Aide72.png b/code/PtiClic/res/drawable-hdpi/aide.png Binary files differ. diff --git a/code/images/Contenant72.png b/code/PtiClic/res/drawable-hdpi/contenant.png Binary files differ. diff --git a/code/images/Contenu72.png b/code/PtiClic/res/drawable-hdpi/contenu.png Binary files differ. diff --git a/code/images/Contraire72.png b/code/PtiClic/res/drawable-hdpi/contraire.png Binary files differ. diff --git a/code/images/ModeNormal72.png b/code/PtiClic/res/drawable-hdpi/mode_normal.png Binary files differ. diff --git a/code/images/ModeOmbre72.png b/code/PtiClic/res/drawable-hdpi/mode_ombre.png Binary files differ. diff --git a/code/images/Rapport72.png b/code/PtiClic/res/drawable-hdpi/rapport.png Binary files differ. diff --git a/code/images/FondLogo.png b/code/PtiClic/res/drawable-hdpi/splash.png Binary files differ. diff --git a/code/images/Synonyme72.png b/code/PtiClic/res/drawable-hdpi/synonyme.png Binary files differ. diff --git a/code/images/Aide36.png b/code/PtiClic/res/drawable-ldpi/aide.png Binary files differ. diff --git a/code/images/Contenant36.png b/code/PtiClic/res/drawable-ldpi/contenant.png Binary files differ. diff --git a/code/images/Contenu36.png b/code/PtiClic/res/drawable-ldpi/contenu.png Binary files differ. diff --git a/code/images/Contraire36.png b/code/PtiClic/res/drawable-ldpi/contraire.png Binary files differ. diff --git a/code/images/ModeNormal36.png b/code/PtiClic/res/drawable-ldpi/mode_normal.png Binary files differ. diff --git a/code/images/ModeOmbre36.png b/code/PtiClic/res/drawable-ldpi/mode_ombre.png Binary files differ. diff --git a/code/images/Rapport36.png b/code/PtiClic/res/drawable-ldpi/rapport.png Binary files differ. diff --git a/code/images/FondLogo.png b/code/PtiClic/res/drawable-ldpi/splash.png Binary files differ. diff --git a/code/images/Synonyme36.png b/code/PtiClic/res/drawable-ldpi/synonyme.png Binary files differ. diff --git a/code/images/Aide48.png b/code/PtiClic/res/drawable-mdpi/aide.png Binary files differ. diff --git a/code/images/Contenant48.png b/code/PtiClic/res/drawable-mdpi/contenant.png Binary files differ. diff --git a/code/images/Contenu48.png b/code/PtiClic/res/drawable-mdpi/contenu.png Binary files differ. diff --git a/code/images/Contraire48.png b/code/PtiClic/res/drawable-mdpi/contraire.png Binary files differ. diff --git a/code/images/ModeNormal48.png b/code/PtiClic/res/drawable-mdpi/mode_normal.png Binary files differ. diff --git a/code/images/ModeOmbre48.png b/code/PtiClic/res/drawable-mdpi/mode_ombre.png Binary files differ. diff --git a/code/images/Rapport48.png b/code/PtiClic/res/drawable-mdpi/rapport.png Binary files differ. diff --git a/code/images/FondLogo.png b/code/PtiClic/res/drawable-mdpi/splash.png Binary files differ. diff --git a/code/images/Synonyme48.png b/code/PtiClic/res/drawable-mdpi/synonyme.png Binary files differ. diff --git a/code/PtiClic/res/layout/frontpage.xml b/code/PtiClic/res/layout/frontpage.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:orientation="vertical"> + + <TextView android:text="@string/app_name" android:id="@+id/logo" + android:layout_width="fill_parent" android:layout_height="wrap_content" + android:textSize="50px" android:layout_weight="1" /> + + <RelativeLayout android:layout_height="wrap_content" + android:id="@+id/RelativeLayout01" android:layout_width="wrap_content" + android:layout_gravity="bottom|center_horizontal"> + + <ImageView android:layout_height="wrap_content" + android:text="@string/play_label" android:layout_width="wrap_content" + android:id="@+id/play" android:clickable="true" android:padding="30dip" android:src="@drawable/mode_normal"/> + + <ImageView android:src="@drawable/config" android:layout_height="wrap_content" android:id="@+id/prefs" + android:layout_width="wrap_content" android:layout_below="@+id/play" + android:layout_alignLeft="@+id/play" android:layout_alignRight="@+id/play" android:padding="30dip"></ImageView> + + + + + + + +</RelativeLayout> + + <LinearLayout android:id="@+id/LinearLayout01" + android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="vertical" android:layout_weight="1"> + + <TextView android:layout_height="wrap_content" + android:layout_width="fill_parent" android:textStyle="bold" + android:gravity="center_horizontal" android:text="@+id/login" + android:id="@+id/login"></TextView> + <ImageView android:layout_height="wrap_content" android:id="@+id/infoButton" + android:layout_width="wrap_content" android:layout_gravity="right" android:layout_weight="5" + android:clickable="true" android:src="@drawable/aide"/> + + </LinearLayout> + +</LinearLayout> diff --git a/code/PtiClic/res/layout/game.xml b/code/PtiClic/res/layout/game.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout android:id="@+id/widget29" - android:layout_width="fill_parent" android:layout_height="fill_parent" - android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> +<LinearLayout android:layout_width="fill_parent" + android:layout_height="fill_parent" android:orientation="vertical" + xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:id="@+id/widget40" android:layout_width="fill_parent" android:layout_height="fill_parent" @@ -15,27 +15,33 @@ android:layout_height="wrap_content" android:text="currentWord" android:textStyle="bold" android:gravity="center"> </TextView> - + </LinearLayout> - <LinearLayout android:id="@+id/widget44" - android:orientation="horizontal" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="9"> + <LinearLayout android:orientation="horizontal" + android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="9"> - <Button android:id="@+id/relation1" - android:text="relation1" android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="fill_parent" android:layout_gravity="bottom"> + <Button android:id="@+id/relation1" android:text="relation1" + android:layout_height="wrap_content" android:layout_weight="1" + android:layout_width="fill_parent" android:layout_gravity="bottom"> </Button> - <Button android:id="@+id/relation2" - android:text="relation2" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:layout_gravity="bottom"> + <Button android:id="@+id/relation2" android:text="relation2" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="bottom"> </Button> - <Button android:id="@+id/poubelle" - android:text="poubelle" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:layout_gravity="bottom"> + <Button android:id="@+id/trash" android:text="trash" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="bottom"> </Button> - <Button android:id="@+id/relation3" - android:text="relation3" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:layout_gravity="bottom"> + <Button android:id="@+id/relation3" android:text="relation3" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="bottom"> </Button> - <Button android:id="@+id/relation4" - android:text="relation4" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:layout_gravity="bottom"> + <Button android:id="@+id/relation4" android:text="relation4" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="bottom"> </Button> </LinearLayout> diff --git a/code/PtiClic/res/layout/main.xml b/code/PtiClic/res/layout/main.xml @@ -1,46 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" android:layout_height="fill_parent" - android:orientation="vertical"> - - <TextView android:text="@string/app_name" android:id="@+id/logo" - android:layout_width="fill_parent" android:layout_height="wrap_content" - android:textSize="50px" android:layout_weight="1" /> - - <RelativeLayout android:layout_height="wrap_content" - android:id="@+id/RelativeLayout01" android:layout_width="wrap_content" - android:layout_gravity="bottom|center_horizontal"> - - <ImageView android:layout_height="wrap_content" - android:text="@string/play_label" android:layout_width="wrap_content" - android:id="@+id/play" android:src="@drawable/mode_chrono" - android:clickable="true" android:padding="40dip" /> - - <ImageView android:src="@drawable/config" android:padding="40dip" - android:layout_height="wrap_content" android:id="@+id/prefs" - android:layout_width="wrap_content" android:layout_below="@+id/play" - android:layout_alignLeft="@+id/play" android:layout_alignRight="@+id/play"></ImageView> - - - - - - - -</RelativeLayout> - - <LinearLayout android:id="@+id/LinearLayout01" - android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="vertical" android:layout_weight="1"> - - <TextView android:layout_height="wrap_content" - android:layout_width="fill_parent" android:textStyle="bold" - android:gravity="center_horizontal" android:text="@+id/login" - android:id="@+id/login"></TextView> - <ImageView android:layout_height="wrap_content" android:id="@+id/infoButton" - android:layout_width="wrap_content" android:src="@android:drawable/ic_dialog_info" - android:layout_gravity="right" android:layout_weight="5" - android:clickable="true" /> - - </LinearLayout> - +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> +<ImageView android:id="@+id/ImageView01" android:src="@drawable/splash" android:layout_gravity="center_vertical|center_horizontal|center" android:layout_width="fill_parent" android:layout_height="fill_parent"></ImageView> </LinearLayout> diff --git a/code/PtiClic/res/raw/info.html b/code/PtiClic/res/raw/info.html @@ -10,17 +10,21 @@ </style> <body style="margin: 0; padding: 0" bgcolor="Black"> <center> -<p> -PtiClic a ete concu et developpe par Mathieu Lafourcade (LIRMM - Universite Montpellier 3) et Virginie Zampa (LIDILEM - Universite Stendhal Grenoble 3)<br /> -</p><p> -Merci en particulier a (en vrac) farfadet, mehdi (mym), alain joubert, gilles serasset (krado)...<br /> -</p><p> -Pticlic n'est pas exempt de bugs - si vous en rencontrez un, pourriez-vous le signaler a l'administrateur ?<br /> -</p><p> -Mathieu Lafourcade - Administrateur - <a mailto:"pticlic.android.beta@gmail.com">contact</a><br /> -</p><p> -Derniere mise a jour : fevrier 2008 -</p> + +<p>PtiClic a été conçu et développé par Mathieu Lafourcade (LIRMM - Université Montpellier 3) +et Virginie Zampa (LIDILEM - Université Stendhal Grenoble 3)</p> + +<p>La présente version pour SmartPhone sous Android en cours de développement a été +conçue et réalisée par des étudiants en Master 1 à l'Université Montpellier II&nbsp;: +Yoann BONAVERO, Bertrand BRUN, John CHARRON et Georges DUPERON.</p> + +<p>Cette version du PtiClic est une version Alpha. Elle n'est pas exempte de bogues.</p> +<p>Si vous souhaitez participer au projet en tant que Bêta-testeur, +rendez-vous sur le site http://www... pour vous y inscrire.</p> +<p>Si vous souhaitez signaler des bogues ou de nous fournir des commentaires, vous pouvez +nous contacter sur pticlic.android.beta@gmail.com</p> + + </center> </body> </html> \ No newline at end of file diff --git a/code/PtiClic/src/org/pticlic/FrontPage.java b/code/PtiClic/src/org/pticlic/FrontPage.java @@ -0,0 +1,51 @@ +package org.pticlic; + +import org.pticlic.games.BaseGame; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.ImageView; +import android.widget.TextView; + +public class FrontPage extends Activity implements OnClickListener{ + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.frontpage); + // Écoute des clics sur les différents boutons + ((ImageView)findViewById(R.id.prefs)).setOnClickListener(this); + ((ImageView)findViewById(R.id.play)).setOnClickListener(this); + ((ImageView)findViewById(R.id.infoButton)).setOnClickListener(this); + + // On récupère le nom du joueur des préférences. + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); + String loginPref = sp.getString("login", "joueur"); + // On l'ajoute dans le TextView prévu à cet effet + ((TextView)findViewById(R.id.login)).setText("Login : " + loginPref); + } + + /* (non-Javadoc) + * @see android.view.View.OnClickListener#onClick(android.view.View) + */ + @Override + public void onClick(View v) { + switch (v.getId()) { + case (R.id.prefs) : startActivity(new Intent(this, Preference.class)); break; + case (R.id.play) : startActivity(new Intent(this, BaseGame.class)); break; + case (R.id.infoButton) : startActivity(new Intent(this, Information.class)); break; + } + } + + @Override + public void onBackPressed() { + System.exit(0); + } + +} diff --git a/code/PtiClic/src/org/pticlic/Main.java b/code/PtiClic/src/org/pticlic/Main.java @@ -1,51 +1,33 @@ package org.pticlic; -import org.pticlic.games.BaseGame; - import android.app.Activity; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.ImageView; -import android.widget.TextView; +import android.view.MotionEvent; -public class Main extends Activity implements OnClickListener { +public class Main extends Activity { - /** Called when the activity is first created. */ @Override - public void onCreate(Bundle savedInstanceState) { + protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); - // Écoute des clics sur les différents boutons - ((ImageView)findViewById(R.id.prefs)).setOnClickListener(this); - ((ImageView)findViewById(R.id.play)).setOnClickListener(this); - ((ImageView)findViewById(R.id.infoButton)).setOnClickListener(this); - - // On récupère le nom du joueur des préférences. - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); - String loginPref = sp.getString("login", "joueur"); - // On l'ajoute dans le TextView prévu à cet effet - ((TextView)findViewById(R.id.login)).setText("Login : " + loginPref); } - /* (non-Javadoc) - * @see android.view.View.OnClickListener#onClick(android.view.View) - */ @Override - public void onClick(View v) { - switch (v.getId()) { - case (R.id.prefs) : startActivity(new Intent(this, Preference.class)); break; - case (R.id.play) : startActivity(new Intent(this, BaseGame.class)); break; - case (R.id.infoButton) : startActivity(new Intent(this, Information.class)); break; - } + protected void onStart() { + super.onStart(); + } - @Override - public void onBackPressed() { - System.exit(0); + public boolean onTouchEvent(MotionEvent event) { + startActivityForResult(new Intent(this, FrontPage.class), 0x0); + return super.onTouchEvent(event); } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + } + } \ No newline at end of file diff --git a/code/PtiClic/src/org/pticlic/Score.java b/code/PtiClic/src/org/pticlic/Score.java @@ -1,8 +1,7 @@ package org.pticlic; import org.pticlic.model.Constant; -import org.pticlic.model.DownloadedScore; -import org.pticlic.model.GamePlayed; +import org.pticlic.model.Match; import org.pticlic.model.Network; import org.pticlic.model.Network.Mode; @@ -21,7 +20,7 @@ import android.widget.Button; */ public class Score extends Activity implements OnClickListener{ - private GamePlayed gamePlayed; + private Match gamePlayed; @Override protected void onCreate(Bundle savedInstanceState) { @@ -36,7 +35,7 @@ public class Score extends Activity implements OnClickListener{ if (getIntent().getExtras() != null) { // Pour JC : GamePlayed contient toutes les infos sur la partie jouee - this.gamePlayed = (GamePlayed) getIntent().getExtras().get(Constant.SCORE_GAMEPLAYED); + this.gamePlayed = (Match) getIntent().getExtras().get(Constant.SCORE_GAMEPLAYED); mode = (Mode) getIntent().getExtras().get(Constant.SCORE_MODE); } diff --git a/code/PtiClic/src/org/pticlic/games/BaseGame.java b/code/PtiClic/src/org/pticlic/games/BaseGame.java @@ -4,10 +4,10 @@ import org.pticlic.R; import org.pticlic.Score; import org.pticlic.model.Constant; import org.pticlic.model.DownloadedGame; -import org.pticlic.model.GamePlayed; +import org.pticlic.model.Match; import org.pticlic.model.Network; -import org.pticlic.model.Relation; import org.pticlic.model.Network.Mode; +import org.pticlic.model.Relation; import android.app.Activity; import android.content.Intent; @@ -41,7 +41,7 @@ public class BaseGame extends Activity implements OnClickListener { private int currentWord = 0; private int nbWord = 0; private DownloadedGame game; - private GamePlayed gamePlayed; + private Match gamePlayed; /** Called when the activity is first created. */ @Override @@ -54,7 +54,7 @@ public class BaseGame extends Activity implements OnClickListener { String serverURL = sp.getString(Constant.SERVER_URL, "http://dumbs.fr/~bbrun/pticlic.json"); // TODO : Mettre comme valeur par defaut l'adresse reel du serveur String id = sp.getString(Constant.USER_ID, "joueur"); String passwd = sp.getString(Constant.USER_PASSWD, ""); - + // On initialise la classe permettant la communication avec le serveur. Network network = new Network(serverURL, Mode.SIMPLE_GAME, id, passwd); game = network.getGames(1); @@ -62,9 +62,9 @@ public class BaseGame extends Activity implements OnClickListener { nbWord = game.getNbWord(); // On initialise la partie. - gamePlayed = new GamePlayed(); + gamePlayed = new Match(); gamePlayed.setGame(game); - + Relation r = Relation.getInstance(); // Boutons des relations @@ -72,9 +72,11 @@ public class BaseGame extends Activity implements OnClickListener { Button r2 = ((Button)findViewById(R.id.relation2)); Button r3 = ((Button)findViewById(R.id.relation3)); Button r4 = ((Button)findViewById(R.id.relation4)); - + // TODO : Pour l'instant la poubelle ne fait rien. Il faudra certainement la ranger dans un categorie dans GamePlayed pour calculer le score. - ((Button)findViewById(R.id.poubelle)).setText("Poubelle"); + Button trash = ((Button)findViewById(R.id.trash)); + trash.setOnClickListener(this); + trash.setText("poubelle"); // Écoute des clics sur les relations if (nbrel > 0) { r1.setOnClickListener(this); r1.setText(r.getRelationName(game.getCat1())); } else { r1.setVisibility(View.GONE); } @@ -82,7 +84,7 @@ public class BaseGame extends Activity implements OnClickListener { if (nbrel > 2) { r3.setOnClickListener(this); r3.setText(r.getRelationName(game.getCat3()));} else { r3.setVisibility(View.GONE); } if (nbrel > 3) { r4.setOnClickListener(this); r4.setText(r.getRelationName(game.getCat4()));} else { r4.setVisibility(View.GONE); } - + ((TextView)findViewById(R.id.mainWord)).setText(DownloadedGame.getName(game.getCentre())); } @@ -151,7 +153,7 @@ public class BaseGame extends Activity implements OnClickListener { Intent intent = new Intent(this, Score.class); intent.putExtra(Constant.SCORE_GAMEPLAYED, gamePlayed); intent.putExtra(Constant.SCORE_MODE, Mode.SIMPLE_GAME); - + startActivityForResult(intent, 0x100); } } @@ -161,12 +163,13 @@ public class BaseGame extends Activity implements OnClickListener { */ @Override public void onClick(View v) { - CharSequence currentWord = ((TextView)findViewById(R.id.currentWord)).getText(); + int currentWord = game.getWordInCloud(this.currentWord).getId(); switch (v.getId()) { case (R.id.relation1) : gamePlayed.add(1, currentWord); next(); break; case (R.id.relation2) : gamePlayed.add(2, currentWord); next(); break; case (R.id.relation3) : gamePlayed.add(3, currentWord); next(); break; case (R.id.relation4) : gamePlayed.add(4, currentWord); next(); break; + case (R.id.trash) : gamePlayed.add(0, currentWord); next(); break; } } } \ No newline at end of file diff --git a/code/PtiClic/src/org/pticlic/model/DownloadedScore.java b/code/PtiClic/src/org/pticlic/model/DownloadedScore.java @@ -1,11 +0,0 @@ -package org.pticlic.model; - -/** - * @author Bertrand BRUN - * - * Classe metier reprensentant le score sous forme json envoyer par le serveur. - * - */ -public class DownloadedScore { - -} diff --git a/code/PtiClic/src/org/pticlic/model/GamePlayed.java b/code/PtiClic/src/org/pticlic/model/GamePlayed.java @@ -1,49 +0,0 @@ -package org.pticlic.model; - -import java.io.Serializable; -import java.util.ArrayList; - -/** - * @author Bertrand BRUN - * - * Cette classe represente une partie joue. - * Elle sera envoyer au serveur pour que celui-ci - * puisse calculer le score obtenue. - * - */ -public class GamePlayed implements Serializable { - - private static final long serialVersionUID = 1L; - private ArrayList<CharSequence> relation1; - private ArrayList<CharSequence> relation2; - private ArrayList<CharSequence> relation3; - private ArrayList<CharSequence> relation4; - private ArrayList<CharSequence> poubelle; - private DownloadedGame game; - - public GamePlayed() { - relation1 = new ArrayList<CharSequence>(); - relation2 = new ArrayList<CharSequence>(); - relation3 = new ArrayList<CharSequence>(); - relation4 = new ArrayList<CharSequence>(); - poubelle = new ArrayList<CharSequence>(); - } - - public void setGame(DownloadedGame game) { - this.game = game; - } - - public DownloadedGame getGame() { - return game; - } - - public void add(int relation, CharSequence word) { - switch (relation) { - case 1: relation1.add(word); break; - case 2: relation2.add(word); break; - case 3: relation3.add(word); break; - case 4: relation4.add(word); break; - default: poubelle.add(word); break; - } - } -} diff --git a/code/PtiClic/src/org/pticlic/model/Match.java b/code/PtiClic/src/org/pticlic/model/Match.java @@ -0,0 +1,85 @@ +package org.pticlic.model; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * @author Bertrand BRUN + * + * Cette classe represente une partie joue. + * Elle sera envoyer au serveur pour que celui-ci + * puisse calculer le score obtenue. + * + */ +public class Match implements Serializable { + + private static final long serialVersionUID = 1L; + private ArrayList<Integer> relation1; + private ArrayList<Integer> relation2; + private ArrayList<Integer> relation3; + private ArrayList<Integer> relation4; + private ArrayList<Integer> trash; + private DownloadedGame game; + + public Match() { + relation1 = new ArrayList<Integer>(); + relation2 = new ArrayList<Integer>(); + relation3 = new ArrayList<Integer>(); + relation4 = new ArrayList<Integer>(); + trash = new ArrayList<Integer>(); + } + + public void setGame(DownloadedGame game) { + this.game = game; + } + + public DownloadedGame getGame() { + return game; + } + + public void add(int relation, int word) { + switch (relation) { + case 1: relation1.add(word); break; + case 2: relation2.add(word); break; + case 3: relation3.add(word); break; + case 4: relation4.add(word); break; + default: trash.add(word); break; + } + } + + /** + * @return the relation1 + */ + public ArrayList<Integer> getRelation1() { + return relation1; + } + + /** + * @return the relation2 + */ + public ArrayList<Integer> getRelation2() { + return relation2; + } + + /** + * @return the relation3 + */ + public ArrayList<Integer> getRelation3() { + return relation3; + } + + /** + * @return the relation4 + */ + public ArrayList<Integer> getRelation4() { + return relation4; + } + + /** + * @return the trash + */ + public ArrayList<Integer> getTrash() { + return trash; + } + +} diff --git a/code/PtiClic/src/org/pticlic/model/Network.java b/code/PtiClic/src/org/pticlic/model/Network.java @@ -21,24 +21,24 @@ public class Network { public enum Action { GET_GAMES } - + public enum Mode { SIMPLE_GAME("normal"); - + private final String value; - + Mode(String value) { this.value = value; } - + private String value() { return value; } } - + private Mode mode; private String serverURL; private String id; private String passwd; - + /** * Constructeur * @@ -53,7 +53,7 @@ public class Network { this.id = id; this.passwd = passwd; } - + /** * Cette méthode permet de récupérer du serveur un certain nombre de parties. * @param nbGames Le nombre de parties que l'on veut récupérer. @@ -69,10 +69,10 @@ public class Network { connection.addRequestProperty("passwd", this.passwd); connection.addRequestProperty("nb", String.valueOf(nbGames)); connection.addRequestProperty("mode", mode.value()); - + Gson gson = new Gson(); JsonReader reader = new JsonReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); - + // FIXME : Attention lorsque l'on pourra vraiment recupere plusieur partie, il faudra changer ce qui suit. reader.beginArray(); while (reader.hasNext()) { @@ -82,13 +82,13 @@ public class Network { reader.close(); } catch (IOException e) { e.printStackTrace(); - + return null; } - + return game; } - + /** * Permet la transformation du Json en une instance de Game. * @@ -105,7 +105,7 @@ public class Network { int cat4 = -1; DownloadedGame.Word center = null; DownloadedGame.Word[] cloud = null; - + reader.beginObject(); while (reader != null && reader.hasNext()) { String name = reader.nextName(); @@ -130,16 +130,16 @@ public class Network { reader.endObject(); return new DownloadedGame(id, cat1, cat2, cat3, cat4, center, cloud); } - - + + /** * Cette méthode permet d'envoyer les parties au serveur pour qu'il puisse les * rajouter à la base de données, et calculer le score. * @param game La partie jouee par l'utilisateur * @return Le score sous forme JSON. */ - public DownloadedScore sendGame(GamePlayed game) { - DownloadedScore score = null; + public TotalScore sendGame(Match game) { + TotalScore score = null; try { URL url = new URL(this.serverURL); URLConnection connection = url.openConnection(); @@ -147,16 +147,37 @@ public class Network { connection.addRequestProperty("user", this.id); connection.addRequestProperty("passwd", this.passwd); connection.addRequestProperty("mode", mode.value()); + + if (game.getGame().getCat1() != -1) { + for (Integer i : game.getRelation1()) { + connection.addRequestProperty("cat1[]", i.toString()); + } + } + if (game.getGame().getCat2() != -1) { + for (Integer i : game.getRelation2()) { + connection.addRequestProperty("cat2[]", i.toString()); + } + } + if (game.getGame().getCat3() != -1) { + for (Integer i : game.getRelation3()) { + connection.addRequestProperty("cat3[]", i.toString()); + } + } + if (game.getGame().getCat4() != -1) { + for (Integer i : game.getRelation4()) { + connection.addRequestProperty("cat4[]", i.toString()); + } + } + for (Integer i : game.getTrash()) { + connection.addRequestProperty("trash[]", i.toString()); + } Gson gson = new Gson(); - String json = gson.toJson(game); - - connection.addRequestProperty("json", json); JsonReader reader = new JsonReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); + + score = gson.fromJson(reader, TotalScore.class); - // TODO : A changer lorsque je serais exactement ce que renvoie le serveur. - score = gson.fromJson(reader, DownloadedScore.class); - + } catch (IOException e) { return score; } diff --git a/code/PtiClic/src/org/pticlic/model/TotalScore.java b/code/PtiClic/src/org/pticlic/model/TotalScore.java @@ -0,0 +1,45 @@ +package org.pticlic.model; + +/** + * + * @author John CHARRON + * + */ + +public class TotalScore { + + private TotalScore scoreTotal; + private WordScore scores; + + public TotalScore() { + } + + public TotalScore(TotalScore scoreTotal, WordScore wordscores) { + this.scoreTotal = scoreTotal; + this.scores = wordscores; + } + + public TotalScore getScoreTotal() { + return scoreTotal; + } + + public void setScoreTotal(TotalScore scoreTotal) { + this.scoreTotal = scoreTotal; + } + + public WordScore getWordscores() { + return scores; + } + + public void setWordscores(WordScore wordscores) { + this.scores = wordscores; + } + + @Override + public String toString() { + return "TotalScore [scoreTotal=" + scoreTotal + ", wordscores=" + + scores + "]"; + } + + +} +\ No newline at end of file diff --git a/code/PtiClic/src/org/pticlic/model/WordScore.java b/code/PtiClic/src/org/pticlic/model/WordScore.java @@ -0,0 +1,62 @@ +package org.pticlic.model; + +/** + * + * @author John CHARRON + * + */ + +public class WordScore { + + private int idmot; + private double score; + private double probaR1; + private double probaR2; + + public WordScore() {} + + public WordScore(int idmot, double score, double probaR1, double probaR2) { + this.idmot = idmot; + this.score = score; + this.probaR1 = probaR1; + this.probaR2 = probaR2; + } + + public int getIdmot() { + return idmot; + } + + public void setIdmot(int idmot) { + this.idmot = idmot; + } + + public double getScore() { + return score; + } + + public void setScore(double score) { + this.score = score; + } + + public double getProbaR1() { + return probaR1; + } + + public void setProbaR1(double probaR1) { + this.probaR1 = probaR1; + } + + public double getProbaR2() { + return probaR2; + } + + public void setProbaR2(double probaR2) { + this.probaR2 = probaR2; + } + + @Override + public String toString() { + return "WordScore [idmot=" + idmot + ", score=" + score + ", probaR1=" + + probaR1 + ", probaR2=" + probaR2 + "]"; + } +} diff --git a/code/images/Config36.png b/code/images/Config36.png Binary files differ. diff --git a/code/images/Config48.png b/code/images/Config48.png Binary files differ. diff --git a/code/images/Config72.png b/code/images/Config72.png Binary files differ. diff --git a/code/images/ModeChrono36.png b/code/images/ModeChrono36.png Binary files differ. diff --git a/code/images/ModeChrono48.png b/code/images/ModeChrono48.png Binary files differ. diff --git a/code/images/ModeChrono72.png b/code/images/ModeChrono72.png Binary files differ. diff --git a/code/images/ModeMarathon36.png b/code/images/ModeMarathon36.png Binary files differ. diff --git a/code/images/ModeMarathon48.png b/code/images/ModeMarathon48.png Binary files differ. diff --git a/code/images/ModeMarathon72.png b/code/images/ModeMarathon72.png Binary files differ. diff --git a/code/serveur/.gitignore b/code/serveur/.gitignore @@ -1,3 +1,3 @@ -01042011-LEXICALNET-JEUXDEMOTS-FR-NOHTML.txt +*-LEXICALNET-JEUXDEMOTS-FR-NOHTML.txt db sql diff --git a/code/serveur/dump2sqlite.sh b/code/serveur/dump2sqlite.sh @@ -1,5 +1,7 @@ #!/bin/sh +# TODO : sed -E sur certaines machines, sed -r sur d'autres. + echo " dump2sql.sh : conversion des dumps de JeuxDeMots vers du sql (sqlite3)." >&2 echo " La progression est affichée avec pv. Si vous n'avez pas pv, supprimez la ligne correspondante dans ce script." >&2 echo " Et c'est parti !" >&2 diff --git a/code/serveur/php/config.php b/code/serveur/php/config.php @@ -1,10 +0,0 @@ -<?php - -/** fichier de configuration */ - -// Général - -// Quelques fonctions utiles. -// include("function.php"); - -?> diff --git a/code/serveur/php/function.php b/code/serveur/php/function.php @@ -1,36 +0,0 @@ -<?php - -/**Ce fichier définit un certain nombre de fonctions utiles */ - -// Connexion à la base de données. -function sqlConnect() -{ - global $sql_server, $sql_login, $sql_pass, $sql_bdd; - //connexion au serveur - $linkid = @mysql_connect($sql_server,$sql_login,$sql_pass) or die ("Erreur lors de la connection au serveur MySQL !"); - //selection de la base - @mysql_select_db($sql_bdd,$linkid) or die("Impossible de selectionner la base de données\n<br>\nVoici l'erreur renvoyée par le serveur MySQL :\n<br>\n".mysql_error()); - - return $linkid; -} - -function secure($string) -{ - if(ctype_digit($string)) - { - $string = intval($string); - } - else - { - $string = sqlite_escape_string($string); - $string = addcslashes($string, '%_'); - } - - return $string; -} - -function writeRequest($request) -{ - -} -?> -\ No newline at end of file diff --git a/code/serveur/php/pticlic.php b/code/serveur/php/pticlic.php @@ -69,23 +69,27 @@ function cg_build_result_sets($cloudSize, $centerEid, $r1, $r2) { // Ce n'est toujours pas ça… : "select eid from (select B.start as eid from relation as A, relation as B where A.type not in (4, 12, 36, 18, 29, 45, 46, 47, 48, 1000, 1001) and A.start = $centerEid and B.type not in (4, 12, 36, 18, 29, 45, 46, 47, 48, 1000, 1001) and B.end = A.end limit 1) order by random();" // Tordu, mais ça marche \o/ . En fait il faut empêcher l'optimiseur de ramener le random avant le limit (et l'optimiseur est malin… :) array('w'=>10, 'd'=>8, 's'=>"select x as eid, -0.1 as r1, -0.1 as r2 from (select x from (select X.eid + Y.dumb as x from (select B.start as eid from relation as A, relation as B where A.type not in (4, 12, 36, 18, 29, 45, 46, 47, 48, 1000, 1001) and A.start = 74860 and B.type not in (4, 12, 36, 18, 29, 45, 46, 47, 48, 1000, 1001) and B.end = A.end limit $cloudSize) as X, (select 0 as dumb) as Y)) order by random();"), - array('w'=>10, 's'=>false) // random. Le r1 et r2 de random sont juste en-dessous + 'rand' => array('w'=>10, 's'=>false) // random. Le r1 et r2 de random sont juste en-dessous ); $sumWeights = 0; foreach ($sources as $k => $x) { - $sumWeights += $x['w']; + $sumWeights += $x['w']; + $sources[$k]['rsPos'] = 0; + $sources[$k]['rsSize'] = 0; if ($x['s'] !== false) { $sources[$k]['resultSet'] = array(); $res = $db->query($x['s']); $i = 0; while ($i < 10 && $sources[$k]['resultSet'][] = $res->fetchArray()) { - $i++; + $i++; + $sources[$k]['rsSize']++; } } else { $sources[$k]['resultSet'] = array(); for ($i = 0; $i < 10; $i++) { $sources[$k]['resultSet'][] = array('eid'=>random_node(), 'r1'=>-1, 'r2'=>-1); + $sources[$k]['rsSize']++; } } } @@ -106,32 +110,46 @@ function cg_build_cloud($cloudSize, $sources, $sumWeights) { // On boucle tant qu'il n'y a pas eu au moins 2 sources épuisées $cloud = array(); $nbFailed = 0; - $i = 0; - while ($i < $cloudSize && $nbFailed < 50) { + $i = 0; + while ($i < $cloudSize && $nbFailed < 5*$cloudSize) { // On choisit une source aléatoire en tennant compte des poids. $rands = rand(1,$sumWeights); $sumw = 0; - $res = false; // TODO + $src = $sources['rand']; foreach ($sources as $x) { $sumw += $x['w']; if ($rands < $sumw) { - $res = $x['resultSet']; + $src = $x; break; } } - if (/* dépassé la fin de ce set */) { + if ($src['rsPos'] >= $src['rsSize']) { $nbFailed++; continue; } - $res = $res['eid']; - if (in_array($res, $cloud)) { + $res = $src['resultSet'][$src['rsPos']++]; + if (in_array($res['eid'], $cloud)) { $nbFailed++; continue; - } - $cloud[] = $res; - $i++; + } + // position dans le nuage, difficulté, eid, probaR1, probaR2 + $cloud[$i] = array('pos'=>$i++, 'd'=>$src['d'], 'eid'=>$res['eid'], 'probaR1'=>$res['r1'], 'probaR2'=>$res['r2']); + } + while ($i < $cloudSize) { + $cloud[$i] = array('pos'=>$i++, 'd'=>$sources['rand']['d'], 'eid'=>random_node(), 'probaR1'=>$sources['rand']['resultSet'][0]['r1'], 'probaR2'=>$sources['rand']['resultSet'][0]['r2']); } return $cloud; +} + +function cg_insert($centerEid, $cloud, $r1, $r2) { + $db->exec("begin transaction;"); + $db->exec("insert into game(gid, eid_central_word, relation_1, relation_2) values (null, $centerEid, $r1, $r2);"); + $gid = $db->lastInsertRowID(); + foreach ($cloud as $c) { + $db->exec("insert into game_cloud(gid, num, difficulty, probaR1, probaR2, eid_word) values($gid, ".$c['pos'].", ".$c['d'].", ".$c['probaR1'].', '.$c['probaR2'].', '.$c['eid'].");"); + } + // TODO : insert into game_played une partie de référence. + $db->exec("commit;"); } function create_game($cloudSize) { @@ -140,20 +158,11 @@ function create_game($cloudSize) { $centerEid = random_node(); $r1 = cg_choose_relations(); $r2 = $r1[1]; $r1 = $r1[0]; $sources = cg_build_result_sets($cloudSize, $centerEid, $r1, $r2); $sumWeights = $sources[1]; $sources = $sources[0]; - $cloud = cg_build_cloud($cloudSize, $sources, $sumWeights); + $cloud = cg_build_cloud($cloudSize, $sources, $sumWeights); + cg_insert($centerEid, $cloud); var_dump($cloud); - exit; - - $db->exec("begin transaction;"); - $db->exec("insert into game(gid, eid_central_word, relation_1, relation_2, relation_3, relation_4, reference_played_game) values (null, ".$centerEid.", 1,2,3,4,null);"); - $gid = $db->lastInsertRowID(); - foreach ($cloud as $eid) { - $db->exec("insert into game_cloud(gid, num, difficulty, eid_word) values(".$gid.", ".$i.", ".$difficulty.", ".$eid.");"); - } - // TODO : insert into game_played une partie de référence. - $db->exec("commit;"); -} + exit;} create_game(10); echo 'ok'; @@ -210,4 +219,4 @@ echo 'ok'; // else // die("Commande inconnue"); -?> -\ No newline at end of file +?>