ajour de ping et suppretion commentaire et todo obselette

This commit is contained in:
marc barbier
2020-12-09 19:41:08 +01:00
parent 246dcc2487
commit 41d0061b79
7 changed files with 35 additions and 16 deletions
@@ -11,5 +11,6 @@ public final class COMMAND {
public static final String DEFEND = "defend"; public static final String DEFEND = "defend";
public static final String CAST_SPELL = "castSpell"; public static final String CAST_SPELL = "castSpell";
public static final String PASS_TURN = "passTurn"; public static final String PASS_TURN = "passTurn";
public static final String POPUP = "pupup";
} }
@@ -7,6 +7,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.widget.Toast;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
@@ -20,6 +21,7 @@ import com.iutlaval.myapplication.Video.Drawables.Drawable;
import com.iutlaval.myapplication.Video.Drawables.DrawableBitmap; import com.iutlaval.myapplication.Video.Drawables.DrawableBitmap;
import com.iutlaval.myapplication.Video.Drawables.DrawableCard; import com.iutlaval.myapplication.Video.Drawables.DrawableCard;
import com.iutlaval.myapplication.Video.Drawables.DrawableSelfRemoving; import com.iutlaval.myapplication.Video.Drawables.DrawableSelfRemoving;
import com.iutlaval.myapplication.Video.Drawables.DrawableText;
import com.iutlaval.myapplication.Video.Renderer; import com.iutlaval.myapplication.Video.Renderer;
import java.io.IOException; import java.io.IOException;
@@ -78,10 +80,8 @@ public class GameLogicThread extends Thread{
ready=true; ready=true;
//TODO : choix du deck avant de se co au serv
final String host = "4.tcp.ngrok.io";//192.168.43.251tcp://2.tcp.ngrok.io: final String host = "4.tcp.ngrok.io";//192.168.43.251tcp://2.tcp.ngrok.io:
final int port = 18240; final int port = 14307;
try { try {
client = new Socket(host, port); client = new Socket(host, port);
@@ -97,6 +97,8 @@ public class GameLogicThread extends Thread{
//principe de fonctionnement : on attends une comande du server et on l'execute //principe de fonctionnement : on attends une comande du server et on l'execute
//si quelquechose se passe alors c'est le server qu'il l'a dit //si quelquechose se passe alors c'est le server qu'il l'a dit
while(ready && !cancelled) while(ready && !cancelled)
{ {
try { try {
@@ -105,7 +107,6 @@ public class GameLogicThread extends Thread{
{ {
case COMMAND.GET_DECK: case COMMAND.GET_DECK:
clientOut.writeObject(deckName); clientOut.writeObject(deckName);
//TODO assing this deck
String deckstr = (String)clientIn.readObject(); String deckstr = (String)clientIn.readObject();
deck = new NetworkDeck(deckstr,gameActivity.getBaseContext()); deck = new NetworkDeck(deckstr,gameActivity.getBaseContext());
Log.e("got deck",deckstr); Log.e("got deck",deckstr);
@@ -147,6 +148,13 @@ public class GameLogicThread extends Thread{
case COMMAND.PASS_TURN: case COMMAND.PASS_TURN:
//TODO pass turn //TODO pass turn
break; break;
case COMMAND.POPUP:
String recivedMessage = (String)clientIn.readObject();
Toast t = new Toast(gameActivity);
t.setText(recivedMessage);
t.setDuration(Toast.LENGTH_LONG);
t.show();
break;
default: default:
Log.e("UNKOWN COMMAND",serveurCmd); Log.e("UNKOWN COMMAND",serveurCmd);
} }
@@ -243,3 +251,21 @@ public class GameLogicThread extends Thread{
} }
} }
/**
* ce thread a pour role de repondre pong au requette udp contenant ping
*
* cela sert a verifier sur le clien et présent sans blockage
*/
class UDPPingThread extends Thread
{
public UDPPingThread()
{
}
@Override
public void run() {
super.run();
}
}
@@ -20,9 +20,6 @@ public class GameActivity extends Activity {
public static int screenHeight=0; public static int screenHeight=0;
public static boolean bilinearFiltering = true; public static boolean bilinearFiltering = true;
public static boolean isMultiplayer() {
return false;//TODO implement it
}
private Renderer renderer; private Renderer renderer;
@Override @Override
@@ -15,7 +15,6 @@ import com.iutlaval.myapplication.Video.Rectangle;
/** /**
* TOUT LES NUMEROS QUI NE SONT PAS DANS DES FINAL SONT DES RATIO PERMETTANT DE METTRE TOUT A L ECHCELLE * TOUT LES NUMEROS QUI NE SONT PAS DANS DES FINAL SONT DES RATIO PERMETTANT DE METTRE TOUT A L ECHCELLE
* TODO : tout mettre dans des finals
*/ */
public class DrawableCard extends Drawable{ public class DrawableCard extends Drawable{
//propriéte de base utilisé pour calculer toutes les tailles est positoins //propriéte de base utilisé pour calculer toutes les tailles est positoins
@@ -150,8 +149,6 @@ public class DrawableCard extends Drawable{
*/ */
public DrawableCard(Card c, float x, float y, String name, Context context,int ratio){ public DrawableCard(Card c, float x, float y, String name, Context context,int ratio){
super(x,y,name); super(x,y,name);
//super(c.getFrameBitmap(context),x,y,name,CARD_WITH*ratio,CARD_HEIGHT*ratio);//todo replace this with a con
this.draggable =true; this.draggable =true;
this.onBoard=false; this.onBoard=false;
this.ratio=ratio; this.ratio=ratio;
@@ -9,7 +9,6 @@ import com.iutlaval.myapplication.Video.Rectangle;
public class DrawableRectangle extends Drawable{ public class DrawableRectangle extends Drawable{
/** /**
* ce constructeur n'est pas rapide essayer de l'utiliser le moin possible * ce constructeur n'est pas rapide essayer de l'utiliser le moin possible
* TODO : optimize it
* *
* ce constructeur dessine un rectangle avec la couleur donné en argument * ce constructeur dessine un rectangle avec la couleur donné en argument
* @param rectangle recange cooresspondant a la surface a dessiner * @param rectangle recange cooresspondant a la surface a dessiner
@@ -15,7 +15,7 @@ import java.util.List;
* tout modification de ce code doit passer par marc car seul moi sait a quel point il est complex * tout modification de ce code doit passer par marc car seul moi sait a quel point il est complex
*/ */
public class DrawableText extends Drawable{ public class DrawableText extends Drawable{
/**TODO : corriger les deformation due au changement de ratio (x_size,y_size) /**
* ce constructeur permet de rendre du texte * ce constructeur permet de rendre du texte
* @param text le texte a rendre * @param text le texte a rendre
* @param x_pos position en x du texte * @param x_pos position en x du texte
@@ -63,7 +63,8 @@ public class DrawableText extends Drawable{
private List<String> cutText(int charPerLines,String text) private List<String> cutText(int charPerLines,String text)
{ {
List<String> output = new ArrayList<>(); List<String> output = new ArrayList<>();
//TODO cut text in lines
//cut text in lines
StringBuilder nextLine = new StringBuilder(charPerLines); StringBuilder nextLine = new StringBuilder(charPerLines);
for (String word : text.split(" ")) { for (String word : text.split(" ")) {
if(word.length() < charPerLines) if(word.length() < charPerLines)
@@ -67,9 +67,8 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
/** /**
* cette fonction est appeler a chaque fois que l'utilisateur tourne son ecran * cette fonction est appeler a chaque fois que l'utilisateur tourne son ecran
* this function is unused since the screen is locked * cette fonction ne sert a rien vu que l'on ne peut pas tourner l'ecran et on ne peut pas la supprimer donc elle est vide
*/ */
//TODO : a supprimer si elle set a rien (surment importante avec la veille)
@Override @Override
public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int i, int i1, int i2) { public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int i, int i1, int i2) {
} }
@@ -77,7 +76,6 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
/** /**
* on surface destruction stop the thread * on surface destruction stop the thread
* la surface ce fait detruire aussi quand le jeu est en pause * la surface ce fait detruire aussi quand le jeu est en pause
* TODO ajouter une relance sur le GameActivity
* @param surfaceHolder * @param surfaceHolder
*/ */
@Override @Override