Merge branch 'master' of
https://github.com/Marc-Pierre-Barbier/PTS3-SERVEUR/ Conflicts: bin/game/Board.class bin/game/Command.class bin/game/Joueur.class bin/game/Match.class bin/game/cards/Card.class bin/game/cards/MoyenAge/Moyen_Age_Charlemagne.class
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -35,4 +35,32 @@ public class Board {
|
||||
return Arrays.stream(board).iterator();
|
||||
}
|
||||
|
||||
public int getZoneOf(Card cardToUpDate) {
|
||||
int index = 0;
|
||||
for(Card c : board)
|
||||
{
|
||||
//si c'est la meme instance
|
||||
if(c == cardToUpDate)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getBoardSize()
|
||||
{
|
||||
int nbCardOnBoard = 0;
|
||||
for(Card c : board)
|
||||
{
|
||||
//si c'est la meme instance
|
||||
if(c != null)
|
||||
{
|
||||
nbCardOnBoard++;
|
||||
}
|
||||
}
|
||||
return nbCardOnBoard;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public final class Command {
|
||||
public static final String SET_HP = "sethp";
|
||||
public static final String SET_CARD_HP = "setcardhp";
|
||||
public static final String SET_ADV_CARD_HP = "setadvcardhp";
|
||||
public static final String SET_CARD_ATK = "setcardatk";
|
||||
public static final String SET_ADV_CARD_ATK = "setadvcardatk";
|
||||
|
||||
|
||||
}
|
||||
|
||||
+85
-18
@@ -5,7 +5,12 @@ import java.util.Iterator;
|
||||
|
||||
import game.cards.Card;
|
||||
import game.cards.CardRegistery;
|
||||
import game.cards.SpecialCard.IAntiPlayer;
|
||||
import game.cards.SpecialCard.ICanDoge;
|
||||
import game.cards.SpecialCard.IInvisible;
|
||||
import game.cards.SpecialCard.ILifeSteal;
|
||||
import game.cards.SpecialCard.IPlayerFocused;
|
||||
import game.cards.SpecialCard.IShortRange;
|
||||
import game.cards.SpecialCard.IToxic;
|
||||
import game.deck.Deck;
|
||||
import game.deck.DeckRegistery;
|
||||
@@ -192,6 +197,7 @@ public class Joueur {
|
||||
coms.send(Command.SETMANA);
|
||||
mana -= handCard.getCost();
|
||||
coms.send(mana);
|
||||
handCard.onCardPlaced(board);
|
||||
} else {
|
||||
System.out.println("the zone is not avaliable");
|
||||
coms.send(Command.NOK);
|
||||
@@ -317,7 +323,10 @@ public class Joueur {
|
||||
String carteCible = coms.recieve();
|
||||
if (!isInt(carteAttaquante) || !isInt(carteCible))
|
||||
throw new RuntimeException("non number zone recived in attack phase");
|
||||
|
||||
Card attackingCard = board.getCardInZone(Integer.parseInt(carteAttaquante));
|
||||
Card attackedCard = adversaire.getBoard().getCardInZone(Integer.parseInt(carteCible));
|
||||
|
||||
|
||||
if (attackingCard == null) {
|
||||
throw new RuntimeException("invalid attack");
|
||||
@@ -330,7 +339,7 @@ public class Joueur {
|
||||
}
|
||||
attackingCard.hasAttacked();
|
||||
} else {
|
||||
if (!attackingCard.hasAlreadyAttacked()) {
|
||||
if (!attackingCard.hasAlreadyAttacked() && !(attackedCard instanceof IInvisible) && !(attackingCard instanceof IPlayerFocused)) {
|
||||
handleAttackAgainstCard(carteAttaquante, carteCible, adversaire);
|
||||
attackingCard.hasAttacked();
|
||||
}
|
||||
@@ -347,7 +356,18 @@ public class Joueur {
|
||||
}
|
||||
|
||||
private boolean handleAttackAgainstPlayer(Card attackingCard, Joueur adversaire) throws IOException {
|
||||
boolean result = adversaire.takeDamage(attackingCard.getAttack());
|
||||
int damage = attackingCard.getAttack();
|
||||
if(attackingCard instanceof IAntiPlayer)
|
||||
{
|
||||
damage *= 2;
|
||||
}
|
||||
|
||||
if(attackingCard instanceof IShortRange)
|
||||
{
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
boolean result = adversaire.takeDamage(damage);
|
||||
if(!result)
|
||||
{
|
||||
adversaire.updateHp(this);
|
||||
@@ -375,6 +395,13 @@ public class Joueur {
|
||||
}
|
||||
|
||||
boolean isDestroyed = attackedCard.takeDamage(attackingCard.getAttack());
|
||||
if(attackingCard instanceof ILifeSteal)
|
||||
{
|
||||
attackingCard.heal(attackingCard.getAttack());
|
||||
|
||||
updateCardHp(attackingCard, this);
|
||||
}
|
||||
|
||||
if (isDestroyed || attackingCard instanceof IToxic) {
|
||||
// on suprime la carte du terrain
|
||||
board.setCard(Integer.parseInt(carteCible), null);
|
||||
@@ -391,14 +418,7 @@ public class Joueur {
|
||||
// NOTE : non implémenter dans les cartes individuelles par manque de temps
|
||||
attackedCard.onCardDestroyed();
|
||||
}else {
|
||||
adversaire.getComs().send(Command.SET_CARD_HP);
|
||||
adversaire.getComs().send(carteCible);
|
||||
adversaire.getComs().send(attackedCard.getHealth());
|
||||
|
||||
this.getComs().send(Command.SET_ADV_CARD_HP);
|
||||
this.getComs().send(carteCible);
|
||||
this.getComs().send(attackedCard.getHealth());
|
||||
|
||||
adversaire.updateCardHp(attackedCard, this);
|
||||
|
||||
//cette partie est le fightback C.A.D quand tu attaque une carte si elle survit elle te frape a son tour
|
||||
if(attackedCard.getAttack() > 0 && !(attackingCard instanceof ICanDoge))
|
||||
@@ -419,21 +439,53 @@ public class Joueur {
|
||||
|
||||
// appelle les effet de quand la carte est détruite
|
||||
// NOTE : non implémenter dans les cartes individuelles par manque de temps
|
||||
attackedCard.onCardDestroyed();
|
||||
attackingCard.onCardDestroyed();
|
||||
}else {
|
||||
adversaire.getComs().send(Command.SET_CARD_HP);
|
||||
adversaire.getComs().send(carteAttaquante);
|
||||
adversaire.getComs().send(attackingCard.getHealth());
|
||||
|
||||
this.getComs().send(Command.SET_ADV_CARD_HP);
|
||||
this.getComs().send(carteAttaquante);
|
||||
this.getComs().send(attackingCard.getHealth());
|
||||
adversaire.updateCardHp(attackingCard, this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* met a jorus les hp d'une carte tout ce passe du poin de vue du joueur
|
||||
* @param cardToUpDate
|
||||
* @param adversaire
|
||||
* @throws IOException
|
||||
*/
|
||||
private void updateCardHp(Card cardToUpDate,Joueur adversaire) throws IOException
|
||||
{
|
||||
int zone = board.getZoneOf(cardToUpDate);
|
||||
if(zone == -1)return;
|
||||
adversaire.getComs().send(Command.SET_ADV_CARD_HP);
|
||||
adversaire.getComs().send(zone+"");
|
||||
adversaire.getComs().send(cardToUpDate.getHealth());
|
||||
|
||||
this.getComs().send(Command.SET_CARD_HP);
|
||||
this.getComs().send(zone+"");
|
||||
this.getComs().send(cardToUpDate.getHealth());
|
||||
}
|
||||
|
||||
/**
|
||||
* met a jorus les hp d'une carte tout ce passe du poin de vue du joueur
|
||||
* @param cardToUpDate
|
||||
* @param adversaire
|
||||
* @throws IOException
|
||||
*/
|
||||
private void updateCardAtk(Card cardToUpDate,Joueur adversaire) throws IOException
|
||||
{
|
||||
int zone = board.getZoneOf(cardToUpDate);
|
||||
if(zone == -1)return;
|
||||
adversaire.getComs().send(Command.SET_ADV_CARD_ATK);
|
||||
adversaire.getComs().send(zone+"");
|
||||
adversaire.getComs().send(cardToUpDate.getAttack());
|
||||
|
||||
this.getComs().send(Command.SET_CARD_ATK);
|
||||
this.getComs().send(zone+"");
|
||||
this.getComs().send(cardToUpDate.getAttack());
|
||||
}
|
||||
|
||||
private Board getBoard() {
|
||||
return board;
|
||||
@@ -451,4 +503,19 @@ public class Joueur {
|
||||
return pV == 0;
|
||||
|
||||
}
|
||||
|
||||
public void onTurnStart(Joueur adversaire) throws IOException {
|
||||
Iterator<Card> it = board.getIterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
Card c = it.next();
|
||||
if(c != null)
|
||||
{
|
||||
c.onTurnStart();
|
||||
updateCardHp(c, adversaire);
|
||||
updateCardAtk(c, adversaire);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ public class Match extends Thread {
|
||||
//et on dit au joueur oposé que ce n'est pas le tien
|
||||
enemy.debutTourEnemie();
|
||||
|
||||
|
||||
joueur.onTurnStart(enemy);
|
||||
joueur.mainPhase1(enemy); //Joue autant de carte qu'il veut/peut
|
||||
joueur.battlePhase(enemy);//lance des attaques à son adversaire qui peut répliquer
|
||||
//cette phases ne serira surment pas car nous manquon de temps pour implrementer les fonctionnalité specifique de certaine cartes
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package game.cards;
|
||||
|
||||
import game.Board;
|
||||
|
||||
public abstract class Card{
|
||||
|
||||
private int attack;
|
||||
@@ -41,7 +43,7 @@ public abstract class Card{
|
||||
/**
|
||||
* evenement déclanché au placement de la carte
|
||||
*/
|
||||
public void onCardPlaced(){};
|
||||
public void onCardPlaced(Board board){};
|
||||
/**
|
||||
* évenement déclenché a la mort de la carte
|
||||
*/
|
||||
@@ -89,5 +91,12 @@ public abstract class Card{
|
||||
public void resetAttack() {
|
||||
hasAttacked=false;
|
||||
}
|
||||
public void heal(int amount) {
|
||||
health += amount;
|
||||
}
|
||||
public void makeStronger(int amount)
|
||||
{
|
||||
attack += amount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package game.cards.MoyenAge;
|
||||
|
||||
import game.cards.Card;
|
||||
import game.cards.SpecialCard.VigilanceCard;
|
||||
|
||||
public class Moyen_Age_Charlemagne extends Card{
|
||||
public class Moyen_Age_Charlemagne extends VigilanceCard{
|
||||
/**
|
||||
* retourne un entier coresspondant a l'attaque de la carte
|
||||
*
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
public interface IAntiPlayer {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
public interface IInvisible {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
public interface ILifeSteal {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
public interface IPlayerFocused {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
public interface IShortRange {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
import game.Board;
|
||||
import game.cards.Card;
|
||||
|
||||
public abstract class LonerCard extends Card{
|
||||
@Override
|
||||
public void onCardPlaced(Board board) {
|
||||
if(board.getBoardSize() == 1)
|
||||
{
|
||||
makeStronger(3);
|
||||
}
|
||||
super.onCardPlaced(board);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
import game.cards.Card;
|
||||
|
||||
public abstract class RegeneratingCard extends Card{
|
||||
@Override
|
||||
public void onTurnStart() {
|
||||
heal(1);
|
||||
super.onTurnStart();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
public abstract class SelfHarmCard extends SteroidsCard{
|
||||
@Override
|
||||
public void onTurnStart() {
|
||||
heal(-1);
|
||||
super.onTurnStart();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
import game.cards.Card;
|
||||
|
||||
public abstract class SteroidsCard extends Card{
|
||||
|
||||
@Override
|
||||
public void onTurnStart() {
|
||||
makeStronger(1);
|
||||
super.onTurnStart();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package game.cards.SpecialCard;
|
||||
|
||||
import game.cards.Card;
|
||||
|
||||
public abstract class VigilanceCard extends Card{
|
||||
int nbAttack = 0;
|
||||
|
||||
public boolean hasAlreadyAttacked() {
|
||||
return nbAttack==2;
|
||||
}
|
||||
|
||||
public void hasAttacked() {
|
||||
nbAttack++;
|
||||
}
|
||||
|
||||
public void resetAttack() {
|
||||
nbAttack=0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user