on peut voire les detail des carte enemis + repatch de fautes + javadoc
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
package com.iutlaval.myapplication;
|
||||
|
||||
/**
|
||||
* pour obtenir le code erreur faite ERROR_CODE.****.ordinal();
|
||||
*/
|
||||
public enum ERROR_CODE {
|
||||
ERROR_SUCCESS,ERROR_UNKNOwN, ERROR_INVALID_CARD_DIMENSIONS, ERROR_TEXTURE_DIMENSIONS_INVALID
|
||||
}
|
||||
@@ -44,6 +44,11 @@ public class Board {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* surprime une carte sur le terrain du joueur et la retourne
|
||||
* @param zone
|
||||
* @return
|
||||
*/
|
||||
public Card removeCardOnPlayerBoard(int zone)
|
||||
{
|
||||
Card c = playerCardsOnBoard[zone];
|
||||
@@ -51,6 +56,11 @@ public class Board {
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* surprime une carte sur le terrain enemy et la retourne
|
||||
* @param zone
|
||||
* @return
|
||||
*/
|
||||
public Card removeCardOnEnemyPlayerBoard(int zone) {
|
||||
Card c = advCardsOnBoard[zone];
|
||||
advCardsOnBoard[zone] = null;
|
||||
|
||||
@@ -38,11 +38,13 @@ public abstract class Card {
|
||||
|
||||
public void setAttack(int attack) {
|
||||
this.attack = attack;
|
||||
//on met a jours l'affichage
|
||||
drawableCard.updateHpAndAtk(attack,null);
|
||||
}
|
||||
|
||||
public void setHealth(int health) {
|
||||
this.health = health;
|
||||
//on met a jours l'affichage
|
||||
drawableCard.updateHpAndAtk(null,health);
|
||||
}
|
||||
|
||||
@@ -127,9 +129,6 @@ public abstract class Card {
|
||||
this.drawableCard = drawableCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public final DrawableCard getDrawableCard() {
|
||||
return drawableCard;
|
||||
}
|
||||
|
||||
@@ -96,10 +96,15 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* registre de carte identique a celui du serveur permet la déserialisation des decks et cartes
|
||||
* par example si le serveur envoie un messange du genre : destruire 0
|
||||
* on comprendera detruire Mythes_Perséphone
|
||||
*/
|
||||
public class CardRegistery {
|
||||
public static List<Class<? extends Card>> registry;
|
||||
|
||||
/**
|
||||
* initialise le registre des carte
|
||||
*/
|
||||
private static void initCardRegistery()
|
||||
{
|
||||
registry = new ArrayList<>();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.iutlaval.myapplication.Game;
|
||||
|
||||
/**
|
||||
* cette classe sert de registre de command basiquement elle joue le role d'un enum mais en plus simple a faire avec le fait que l'on a besoin de string
|
||||
*/
|
||||
public final class Command {
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ import java.io.ObjectOutputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
|
||||
/**
|
||||
* cette classe a pour role de gérer l'envie et la reception de message client serveur
|
||||
*/
|
||||
public class Communication {
|
||||
private static final short MAX_ACCEPTABLE_PING = 500;
|
||||
public static final String TIMEOUT = "timeout";
|
||||
|
||||
@@ -115,8 +115,7 @@ public class GameLogicThread extends Thread{
|
||||
|
||||
//adding the background
|
||||
renderer.addToDraw(new DrawableBitmap(bitmapBackground, 0,0, "background", 100, 100 ));
|
||||
//drawHandPreview();
|
||||
//Rectangle pos = new Rectangle(0F,0F,100F,100F);
|
||||
|
||||
ready=true;
|
||||
|
||||
final String host = "2.tcp.ngrok.io";//192.168.43.251tcp://2.tcp.ngrok.io:
|
||||
@@ -124,16 +123,29 @@ public class GameLogicThread extends Thread{
|
||||
|
||||
//gameativity.finish() n'etait pas utilisable il fermais l'application
|
||||
|
||||
try {
|
||||
Socket client = new Socket(host, port);
|
||||
coms= new Communication(client);
|
||||
} catch (IOException e) {
|
||||
//on fait trois essay de connection
|
||||
for(int i = 0 ; i < 3 ; i++)
|
||||
{
|
||||
try {
|
||||
Socket client = new Socket(host, port);
|
||||
coms= new Communication(client);
|
||||
//connection reussie
|
||||
break;
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
//si la connection a échouer on print un log + un toast
|
||||
if(coms == null)
|
||||
{
|
||||
Log.e("ERROR SERVER DEAD","srv");
|
||||
gameActivity.runOnUiThread(new PopupRunable("erreur de comunication avec le serveur",gameActivity));
|
||||
//on arette le moteur de rendu
|
||||
renderer.terminate();
|
||||
//et on retourne la 'activité precedente
|
||||
returnToTheMainActivity();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
renderer.updateFrame();
|
||||
|
||||
//principe de fonctionnement : on attends une comande du server et on l'execute
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* c'est un deck qui déserialise les info recut du serveur ce qui donne une deck de carte a terme
|
||||
* c'est un deck qui déserialise les info recut du serveur ce qui donne un deck de carte a terme
|
||||
*/
|
||||
public class NetworkDeck{
|
||||
private Stack<Card> cards;
|
||||
@@ -36,11 +36,20 @@ public class NetworkDeck{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* retire la premiere carte et la retourne
|
||||
* @return
|
||||
*/
|
||||
public Card draw()
|
||||
{
|
||||
return cards.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* retire un nombre donné de carte et les retourne
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
public List<Card> draw(int amount)
|
||||
{
|
||||
List<Card> drawn = new ArrayList<>();
|
||||
|
||||
@@ -14,7 +14,9 @@ import com.iutlaval.myapplication.Video.Renderer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* gére l'affichage des rectangle gris qui indique les zones jouables
|
||||
*/
|
||||
public class PlayableZonesHandler {
|
||||
private List<Drawable> playableZones;
|
||||
private boolean isDisplayed;
|
||||
@@ -135,6 +137,4 @@ public class PlayableZonesHandler {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//cardPlayed.getDrawableCard().setCoordinates(((DrawableCard.getCardWith()+1)*zone+DrawableCard.getCardWith()),10F);
|
||||
}
|
||||
|
||||
@@ -230,6 +230,10 @@ public class TouchHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gére le glisser déposer de carte pour attacker une enemy
|
||||
* @param event
|
||||
*/
|
||||
private void attackHandler(MotionEvent event)
|
||||
{
|
||||
if(dragAndDropCard != null){
|
||||
|
||||
@@ -62,7 +62,7 @@ public class GameActivity extends Activity {
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
//kill les threads
|
||||
//System.exit(0);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.iutlaval.myapplication.ERROR_CODE;
|
||||
import com.iutlaval.myapplication.GameActivity;
|
||||
import com.iutlaval.myapplication.InvalidDataException;
|
||||
|
||||
@@ -29,7 +28,7 @@ public class DrawableBitmap extends Drawable{
|
||||
if(x_scaled_size <=0 || y_scaled_size <=0)
|
||||
{
|
||||
Log.e("DRAWABLE_TEXTURE :","ERREUR DE MISE A L'ECHELLE");
|
||||
System.exit(ERROR_CODE.ERROR_TEXTURE_DIMENSIONS_INVALID.ordinal());
|
||||
throw new RuntimeException("ECHELLE INVALID EXCEPTION "+this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
setBitmap(Bitmap.createScaledBitmap(bitmap, (int)x_scaled_size, (int)y_scaled_size, GameActivity.bilinearFiltering));
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.util.Log;
|
||||
|
||||
import com.iutlaval.myapplication.ERROR_CODE;
|
||||
import com.iutlaval.myapplication.Game.Cards.Card;
|
||||
import com.iutlaval.myapplication.InvalidDataException;
|
||||
import com.iutlaval.myapplication.Video.Rectangle;
|
||||
@@ -175,7 +174,7 @@ public class DrawableCard extends Drawable{
|
||||
} catch (InvalidDataException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("CARTE :","forme de la carte invalide !");
|
||||
System.exit(ERROR_CODE.ERROR_INVALID_CARD_DIMENSIONS.ordinal());
|
||||
System.exit(100);
|
||||
}
|
||||
|
||||
|
||||
@@ -360,6 +359,9 @@ public class DrawableCard extends Drawable{
|
||||
return onBoard;
|
||||
}
|
||||
|
||||
public int getRatio() {
|
||||
return ratio;
|
||||
}
|
||||
|
||||
public Card getCard() {
|
||||
return card;
|
||||
|
||||
@@ -319,7 +319,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
||||
{
|
||||
//on n'a pas d'objet non card a deplacer
|
||||
//si on venais a en avoir besoin crée une interface draggable s'avererais utile
|
||||
if(d instanceof DrawableCard && d.isDraggable())
|
||||
if(d instanceof DrawableCard && ((DrawableCard)d).getRatio() == 1)
|
||||
{
|
||||
DrawableCard card = ((DrawableCard)d);
|
||||
if(x >= card.getX() && x <= card.getX()+card.getCardWith())
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 115 KiB |
Reference in New Issue
Block a user