get id return long

master
melvin 2011-06-14 17:34:36 +08:00
parent c5df1a02ee
commit 121919dafc
2 changed files with 8 additions and 17 deletions

View File

@ -22,10 +22,10 @@ public class MagicCardList extends ArrayList<MagicCard> {
return cardList;
}
public int getCardsId() {
int id=size()*97;
public long getCardsId() {
long id = 0;
for (final MagicCard card : this) {
id+=card.getCardDefinition().getIndex();
id = id * 31 + card.getCardDefinition().getIndex();
}
return id;
}

View File

@ -6,27 +6,20 @@ public class MagicPermanentSet extends TreeSet<MagicPermanent> {
private static final long serialVersionUID = 1L;
public MagicPermanentSet() {
}
public MagicPermanentSet() {}
public MagicPermanentSet(final MagicPermanentSet set) {
super(set);
}
public MagicPermanentSet(final MagicCopyMap copyMap,final MagicPermanentSet source) {
for (final MagicPermanent permanent : source) {
add(copyMap.copy(permanent));
}
}
public MagicPermanent getPermanent(final long id) {
for (final MagicPermanent permanent : this) {
if (permanent.getId()==id) {
return permanent;
}
@ -34,13 +27,11 @@ public class MagicPermanentSet extends TreeSet<MagicPermanent> {
return null;
}
public int getPermanentsId() {
int id=0;
public long getPermanentsId() {
long id = 0;
for (final MagicPermanent permanent : this) {
id=id*3+permanent.getPermanentId();
id = id * 31 + permanent.getPermanentId();
}
return id;
}
}
}