ajout 10 effet de carte
This commit is contained in:
+64
-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,34 @@ 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());
|
||||
}
|
||||
|
||||
private Board getBoard() {
|
||||
return board;
|
||||
@@ -451,4 +484,17 @@ public class Joueur {
|
||||
return pV == 0;
|
||||
|
||||
}
|
||||
|
||||
public void onTurnStart() {
|
||||
Iterator<Card> it = board.getIterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
Card c = it.next();
|
||||
if(c != null)
|
||||
{
|
||||
c.onTurnStart();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user