I was wondering if anyone would help me understand this.
I have a method called Generation() in my cards class that basically generates an image for the card and returns an integer.
In my player class, I am trying to test what values it returns. So I did a simple showtext to check what number it returns.
Code in my player class:
The method that generates a random integer.
The problem is that it shows a different number for the exact same image when I generate my cards.
This is really strange and I cannot understand why it would do that.
public void CardSelect()
{
CurrentMana ++;
MaxMana++;
int number = 0;
if (position == 6) return;
int value = Greenfoot.getRandomNumber(6-position);
Cards card = playerCards[value];
if(getY() > 400)
{
getWorld().addObject(card, 40 + (50*(position+1)^2), getY()+60);
}
if(getY() < 400)
{
getWorld().addObject(card, 40 + (50*(position+1)^2), getY() -40);
}
position++;
playerCards[value] = playerCards[6-position];
playerCards[6-position] = card;
int ShowInt = card.Generation();
String showInt = Integer.toString(ShowInt);
getWorld().showText(showInt, 500, 400);
public int Generation()
{
number = dice.Roll(number);
CardImages[number].scale(NormalWidth / 2, NormalHeight / 2);
setImage(CardImages[number]);
if(getImage().equals(CardImages[0]))
{
cost = 0;
attack = 1;
health = 1;
return 1;
}
if(getImage().equals(CardImages[1]))
{
cost = 7;
attack = 9;
health = 5;
return 2;
}
if(getImage().equals(CardImages[2]))
{
cost = 6;
attack = 6;
health = 7;
return 3;
}
if(getImage().equals(CardImages[3]))
{
cost = 2;
attack = 3;
health = 2;
return 4;
}
if(getImage().equals(CardImages[4]))
{
cost = 1;
attack = 2;
health = 1;
return 5;
}
if(getImage().equals(CardImages[5]))
{
cost = 8;
attack = 4;
health = 9;
return 6;
}
return 0;
}
