changed MagicCard to use abs(hashCode) has imageIndex instead of using nextInt as nextInt is not synchronized

master
melvin 2011-07-05 14:53:28 +08:00
parent 1790228260
commit 52cf57c32e
2 changed files with 5 additions and 4 deletions

View File

@ -18,10 +18,10 @@ public class MagicCard implements MagicSource,MagicTarget,Comparable<MagicCard>
private int imageIndex=0;
public MagicCard(final MagicCardDefinition cardDefinition,final MagicPlayer owner,final long id) {
this.cardDefinition=cardDefinition;
this.owner=owner;
this.id=id;
imageIndex=MagicRandom.nextInt(100);
this.cardDefinition = cardDefinition;
this.owner = owner;
this.id = id;
imageIndex = Math.abs(hashCode());
}
private MagicCard() {}

View File

@ -88,6 +88,7 @@ public class MagicGame {
private long[] keys;
private long time = 1000000;
public static MagicGame getInstance() {
return INSTANCE;
}