amelioration du moteur + ajout de DrawableCard pour simplifer la creation de carte + correction du support de texture + correction du support de rectangle
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.iutlaval.myapplication.Game;
|
||||
|
||||
import com.iutlaval.myapplication.Game.Cards.Card;
|
||||
import com.iutlaval.myapplication.Game.Player.Player;
|
||||
import com.iutlaval.myapplication.Game.Player.PlayerBot;
|
||||
import com.iutlaval.myapplication.Game.Player.PlayerOnlineAdversary;
|
||||
import com.iutlaval.myapplication.Game.Player.PlayerLocal;
|
||||
import com.iutlaval.myapplication.GameActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Board {
|
||||
private static final int MAX_CARD_ON_BOARD=10;
|
||||
private List<Card> AdvCardsOnBoard;
|
||||
private List<Card> PlayerCardsOnBoard;
|
||||
private PlayerLocal player1;
|
||||
private Player player2;
|
||||
|
||||
public Board()
|
||||
{
|
||||
AdvCardsOnBoard = new ArrayList<>();
|
||||
PlayerCardsOnBoard = new ArrayList<>();
|
||||
player1 = new PlayerLocal();
|
||||
|
||||
if(GameActivity.isMultiplayer())
|
||||
{
|
||||
player2 = new PlayerOnlineAdversary();
|
||||
}else{
|
||||
player2 = new PlayerBot();
|
||||
}
|
||||
|
||||
//TODO fill decks
|
||||
if(GameActivity.isHosting())
|
||||
{
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.iutlaval.myapplication.Game.Cards;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
|
||||
import com.iutlaval.myapplication.Game.Board;
|
||||
import com.iutlaval.myapplication.R;
|
||||
|
||||
public abstract class Card {
|
||||
private int health;
|
||||
private int attack;
|
||||
|
||||
private static Bitmap frameBitmap = null;
|
||||
|
||||
public void onCardAttack(Board board){}
|
||||
|
||||
public void onCardPlayed(Board board){}
|
||||
|
||||
public void onCardDeath(Board board){}
|
||||
|
||||
public void onTurnBegin(Board board){}
|
||||
|
||||
/**
|
||||
* SURTOUT NE PAS @OVERRIDE
|
||||
* si vous voulez modifier le cadre changer getFrameTexture()
|
||||
* @param c context
|
||||
* @return bitmap
|
||||
*/
|
||||
public Bitmap getFrameBitmap(Context c)
|
||||
{
|
||||
//TODO add a frame
|
||||
if(frameBitmap == null) {
|
||||
frameBitmap=BitmapFactory.decodeResource(c.getResources(), R.drawable.cadre_carte);
|
||||
}
|
||||
|
||||
if(getFrameTexture() == R.drawable.cadre_carte)
|
||||
{
|
||||
return frameBitmap;
|
||||
}else{
|
||||
return BitmapFactory.decodeResource(c.getResources(),getFrameTexture());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getFrameTexture()
|
||||
{
|
||||
return R.drawable.cadre_carte;
|
||||
}
|
||||
|
||||
|
||||
public abstract int getCardPicture();
|
||||
|
||||
/**
|
||||
* retourne la culeur de la carte
|
||||
* la couleur s'affiche comme un filtre sur la carte
|
||||
* /!\ attention a l'opacite /!\ le format n'est PAS rgba MAIS argb
|
||||
* #AARRGGBB
|
||||
* je recomander une opaciter en 44 et 70
|
||||
* @return
|
||||
*/
|
||||
public String getColor()
|
||||
{
|
||||
return "#00000000";
|
||||
}
|
||||
//TODO
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.iutlaval.myapplication.Game.Cards;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.iutlaval.myapplication.R;
|
||||
|
||||
public class DemoCard extends Card{
|
||||
|
||||
@Override
|
||||
public int getCardPicture() {
|
||||
return R.drawable.guerrier_nul;
|
||||
}
|
||||
|
||||
|
||||
//#AARRGGBB
|
||||
@Override
|
||||
public String getColor() {
|
||||
return "#70FF0000";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.iutlaval.myapplication.Game.Player;
|
||||
|
||||
import com.iutlaval.myapplication.Game.Cards.Card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class Player {
|
||||
private static final int MAX_HAND_SIZE = 10;
|
||||
|
||||
private List<Card> deck;
|
||||
private List<Card> hand;
|
||||
private int hp = 100;
|
||||
|
||||
|
||||
public Player(){
|
||||
deck=new ArrayList<>();
|
||||
hand=new ArrayList<>();
|
||||
}
|
||||
|
||||
public void shuffle()
|
||||
{
|
||||
Collections.shuffle(deck);
|
||||
}
|
||||
|
||||
/**
|
||||
* cette fonction ajoute un carte dans la main de l'utilisateur
|
||||
*/
|
||||
public void pickCard()
|
||||
{
|
||||
if(!deck.isEmpty()) {
|
||||
if (hand.size() >= MAX_HAND_SIZE) {
|
||||
deck.remove(0);
|
||||
} else {
|
||||
hand.add(deck.remove(0));
|
||||
}
|
||||
}else{
|
||||
getHurt(2);
|
||||
}
|
||||
}
|
||||
|
||||
public void getHurt(int dmg)
|
||||
{
|
||||
hp -= dmg;
|
||||
//TODO death trigger
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.iutlaval.myapplication.Game.Player;
|
||||
|
||||
public class PlayerBot extends Player{
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.iutlaval.myapplication.Game.Player;
|
||||
|
||||
public class PlayerLocal extends Player{
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.iutlaval.myapplication.Game.Player;
|
||||
|
||||
public class PlayerOnlineAdversary extends Player{
|
||||
}
|
||||
Reference in New Issue
Block a user