ajout de la gestion de la mana
This commit is contained in:
+14
-9
@@ -34,25 +34,30 @@ public class Hand {
|
||||
}
|
||||
|
||||
/**
|
||||
* retourne l'index de la carte
|
||||
* retourne la carte si elle est contenu dans la main de la carte
|
||||
* @param c la classe de la carte cherché
|
||||
* @return -1 si elle n'est pas trouver
|
||||
* @return null si elle n'est pas trouver
|
||||
*/
|
||||
public int contains(Class<? extends Card> c) {
|
||||
int index = 0;
|
||||
public Card contains(Class<? extends Card> c) {
|
||||
for(Card ca : hand)
|
||||
{
|
||||
if(ca.getClass().equals(c))
|
||||
{
|
||||
return index;
|
||||
return ca;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Card remove(int index) {
|
||||
return hand.remove(index);
|
||||
/**
|
||||
* retire la carte
|
||||
* @param c carte a retirer
|
||||
* @return si la carte a été retirer
|
||||
*/
|
||||
public Boolean remove(Card c)
|
||||
{
|
||||
return hand.remove(c);
|
||||
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
|
||||
+11
-5
@@ -80,7 +80,7 @@ public class Joueur {
|
||||
while(phaseActive)
|
||||
{
|
||||
coms.getSocket().setSoTimeout(500);
|
||||
String command = (String) coms.recieve();
|
||||
String command = coms.recieve();
|
||||
coms.getSocket().setSoTimeout(Integer.MAX_VALUE);
|
||||
if(command != null && !command.equals("time out"))
|
||||
{
|
||||
@@ -125,13 +125,19 @@ public class Joueur {
|
||||
|
||||
int zone = Integer.parseInt(coms.recieve());
|
||||
|
||||
int handIndex = hand.contains(cardClass);
|
||||
if(handIndex == -1)coms.send(Command.NOK);
|
||||
|
||||
Card handCard = hand.contains(cardClass);
|
||||
|
||||
//si la carte n'est pas trouve ou si elle coute trop cher
|
||||
if(handCard == null || mana < handCard.getCost()){
|
||||
//on refuse le placement
|
||||
coms.send(Command.NOK);
|
||||
}
|
||||
else {
|
||||
if(board.isZoneAvaliable(zone))
|
||||
{
|
||||
Card card = hand.remove(handIndex);
|
||||
board.setCard(zone, card);
|
||||
hand.remove(handCard);
|
||||
board.setCard(zone, handCard);
|
||||
adversaire.enemyPlay(cardId,zone);
|
||||
coms.send(Command.OK);
|
||||
}else {
|
||||
|
||||
Reference in New Issue
Block a user