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é
|
* @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) {
|
public Card contains(Class<? extends Card> c) {
|
||||||
int index = 0;
|
|
||||||
for(Card ca : hand)
|
for(Card ca : hand)
|
||||||
{
|
{
|
||||||
if(ca.getClass().equals(c))
|
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() {
|
public boolean isFull() {
|
||||||
|
|||||||
+12
-6
@@ -80,7 +80,7 @@ public class Joueur {
|
|||||||
while(phaseActive)
|
while(phaseActive)
|
||||||
{
|
{
|
||||||
coms.getSocket().setSoTimeout(500);
|
coms.getSocket().setSoTimeout(500);
|
||||||
String command = (String) coms.recieve();
|
String command = coms.recieve();
|
||||||
coms.getSocket().setSoTimeout(Integer.MAX_VALUE);
|
coms.getSocket().setSoTimeout(Integer.MAX_VALUE);
|
||||||
if(command != null && !command.equals("time out"))
|
if(command != null && !command.equals("time out"))
|
||||||
{
|
{
|
||||||
@@ -124,14 +124,20 @@ public class Joueur {
|
|||||||
|
|
||||||
|
|
||||||
int zone = Integer.parseInt(coms.recieve());
|
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 {
|
else {
|
||||||
if(board.isZoneAvaliable(zone))
|
if(board.isZoneAvaliable(zone))
|
||||||
{
|
{
|
||||||
Card card = hand.remove(handIndex);
|
hand.remove(handCard);
|
||||||
board.setCard(zone, card);
|
board.setCard(zone, handCard);
|
||||||
adversaire.enemyPlay(cardId,zone);
|
adversaire.enemyPlay(cardId,zone);
|
||||||
coms.send(Command.OK);
|
coms.send(Command.OK);
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
Reference in New Issue
Block a user