moved oldTop, simplify MagicCard.map
parent
a48b69a1f1
commit
201cdc77b7
|
@ -50,7 +50,7 @@ public class MagicCard implements MagicSource,MagicTarget,Comparable<MagicCard>
|
|||
@Override
|
||||
public MagicCard map(final MagicGame game) {
|
||||
final MagicPlayer mappedOwner=owner.map(game);
|
||||
MagicCard card = game.getStack().getCard(id);
|
||||
MagicCard card = MagicCard.NONE;
|
||||
if (card == MagicCard.NONE) {
|
||||
card = mappedOwner.getHand().getCard(id);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ public class MagicStack extends LinkedList<MagicItemOnStack> {
|
|||
|
||||
private final int spells[];
|
||||
private final int counts[];
|
||||
private MagicItemOnStack oldTop;
|
||||
|
||||
public MagicStack() {
|
||||
spells=new int[2];
|
||||
|
@ -52,7 +51,7 @@ public class MagicStack extends LinkedList<MagicItemOnStack> {
|
|||
}
|
||||
|
||||
public MagicItemOnStack removeFromTop() {
|
||||
oldTop = removeFirst();
|
||||
final MagicItemOnStack oldTop = removeFirst();
|
||||
removeCount(oldTop);
|
||||
return oldTop;
|
||||
}
|
||||
|
@ -72,20 +71,8 @@ public class MagicStack extends LinkedList<MagicItemOnStack> {
|
|||
Arrays.fill(counts,0);
|
||||
Arrays.fill(spells,0);
|
||||
}
|
||||
|
||||
public MagicCard getCard(final long id) {
|
||||
if (oldTop != null &&
|
||||
oldTop instanceof MagicCardOnStack &&
|
||||
((MagicCardOnStack)oldTop).getCard().getId() == id) {
|
||||
return ((MagicCardOnStack)oldTop).getCard();
|
||||
}
|
||||
return MagicCard.NONE;
|
||||
}
|
||||
|
||||
MagicItemOnStack getItemOnStack(final long id) {
|
||||
if (oldTop != null && oldTop.getId() == id) {
|
||||
return oldTop;
|
||||
}
|
||||
for (final MagicItemOnStack itemOnStack : this) {
|
||||
if (itemOnStack.getId()==id) {
|
||||
return itemOnStack;
|
||||
|
|
Loading…
Reference in New Issue