danpost wrote...
Ahhh -- I understand what you meant now. Another way would be to use a List object. If the card is not on the list, it can attack; once it attacks, it is added to the list; at the end of the turn, clear the list.
CurrentMana ++; //Increasing current and max mana
MaxMana++;
if (position == 6) return; //Cannot have more than six cards.
int value = Greenfoot.getRandomNumber(6-position); //Value used for cards indexing.
Cards card = playerCards[value];
ArrayList<Cards> array = new ArrayList<Cards>();
if(getY() > 400) //Determines player position for card positioning.
{
getWorld().addObject(card, 40 + (50*(position+1)^2), getY()+60);
}
if(getY() < 400)
{
getWorld().addObject(card, 40 + (50*(position+1)^2), getY() -40);
}
position++; //Increases value of position.
playerCards[value] = playerCards[6-position]; //changes value based on position.
playerCards[6-position] = card; //Turns array value into a single variable.
if(card.hasAttacked)
{
array.add(card);
}
if(array.contains(card))
{
card.attacking = false;
}
array.clear();
if(card.Deployment && Greenfoot.mouseClicked(this))
{
loseHealth(card.attack); //Looses health if card attacks plaer.
}
if(Deployment && Greenfoot.mouseClicked(this) && attacking) //Method for attacking
{
//changed comment in next line, I think you misunderstood what it does
if (attacker == null) attacker = this; //set attacker
else if(attacker != this) //if there already is an attacker, attack this with the attacker
{
loseHealth(attacker.attack);
attacker.loseHealth(attack); //If you are attacking someone, have both loose health.
attacker = null;
}
}public static ArrayList<Cards> array = new ArrayList<Cards>();
array.add(this); array.add(attacker);
Cards.array.clear();
public void act()
{
int value = turn%playerCount;
if("up"!=(key))
{//Changing value depending on player selected
if (Greenfoot.mouseClicked(Player[turn%playerCount]))
{
Card.setImage(BackCard); //Making sure that players cannot see their opponent's hand.
Player[turn%playerCount].CardSelect(); //Running the cardselect method.
Player[turn%2].showCards(); //Shows the card for the current player.
Player[(turn+1)%2].hideCards(); //Hides the card for the other.
turn ++;
Cards.array.clear();
}
}
if(Greenfoot.mouseClicked(Spells[0]))
{
Player[0].gainArmor(2);
}
if(Greenfoot.mouseClicked(Spells[1]))
{
Spells[1].act();
}
}