mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Fixed bugs related to Animate AF (see bug issue #137)
This commit is contained in:
@@ -4,6 +4,7 @@ package forge;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -3174,7 +3175,11 @@ public class Card extends MyObservable implements Comparable<Card> {
|
||||
if (!changedCardTypes.isEmpty()) {
|
||||
|
||||
ArrayList<String> newType = new ArrayList<String>(type);
|
||||
ArrayList<Card_Type> types = sortByTimestamp(changedCardTypes);
|
||||
ArrayList<Card_Type> types = changedCardTypes;
|
||||
//TODO: Any reason why changedCardTypes can't be sorted in place
|
||||
// Does changedCardTypes ever get out of increasing time
|
||||
// stamp order?
|
||||
Collections.sort(types); // sorts types by timeStamp
|
||||
|
||||
for (Card_Type ct : types) {
|
||||
ArrayList<String> removeTypes = new ArrayList<String>();
|
||||
@@ -3203,20 +3208,6 @@ public class Card extends MyObservable implements Comparable<Card> {
|
||||
return new ArrayList<String>(type);
|
||||
}
|
||||
|
||||
private ArrayList<Card_Type> sortByTimestamp(ArrayList<Card_Type> cardTypes) {
|
||||
ArrayList<Card_Type> remainingCardTypes = cardTypes;
|
||||
ArrayList<Card_Type> types = new ArrayList<Card_Type>();
|
||||
for(int i = 0; i < cardTypes.size(); i++) {
|
||||
Card_Type nextCT = remainingCardTypes.get(i);
|
||||
long nextLowest = nextCT.getTimestamp();
|
||||
for(Card_Type ct : remainingCardTypes) {
|
||||
if (nextLowest > ct.getTimestamp())
|
||||
nextCT = ct;
|
||||
}
|
||||
types.add(nextCT);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
public void addChangedCardTypes(ArrayList<String> types, boolean removeSuperTypes, boolean removeCardTypes,
|
||||
boolean removeSubTypes, boolean removeCreatureTypes, long timestamp) {
|
||||
|
||||
@@ -2,13 +2,14 @@ package forge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Card_Color class.</p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Card_Type {
|
||||
public class Card_Type implements Comparable<Card_Type> {
|
||||
// takes care of individual card types
|
||||
private ArrayList<String> type = new ArrayList<String>();
|
||||
private boolean removeSuperTypes;
|
||||
@@ -63,4 +64,16 @@ public class Card_Type {
|
||||
public boolean isRemoveCreatureTypes() {
|
||||
return removeCreatureTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final Card_Type anotherCardType) {
|
||||
int returnValue = 0;
|
||||
long anotherTimeStamp = anotherCardType.getTimestamp();
|
||||
if (this.timeStamp < anotherTimeStamp)
|
||||
returnValue = -1;
|
||||
else if (this.timeStamp > anotherTimeStamp)
|
||||
returnValue = 1;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ public class AbilityFactory_Animate {
|
||||
if (params.containsKey("Toughness"))
|
||||
toughness = AbilityFactory.calculateAmount(host, params.get("Toughness"), sa);
|
||||
|
||||
if (power != -1 || toughness != -1)
|
||||
// Every Animate event needs a unique time stamp
|
||||
timest = AllZone.getNextTimestamp();
|
||||
|
||||
final long timestamp = timest;
|
||||
@@ -785,7 +785,7 @@ public class AbilityFactory_Animate {
|
||||
if (params.containsKey("Toughness"))
|
||||
toughness = AbilityFactory.calculateAmount(host, params.get("Toughness"), sa);
|
||||
|
||||
if (power != -1 || toughness != -1)
|
||||
// Every Animate event needs a unique time stamp
|
||||
timest = AllZone.getNextTimestamp();
|
||||
|
||||
final long timestamp = timest;
|
||||
|
||||
Reference in New Issue
Block a user