mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
changed cardtype from list to enumset
This commit is contained in:
parent
c0ffc47bf7
commit
372584f7ad
22 changed files with 116 additions and 55 deletions
|
|
@ -1,7 +1,9 @@
|
|||
package mage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -24,7 +26,7 @@ public interface MageObject extends MageItem, Serializable {
|
|||
|
||||
void setName(String name);
|
||||
|
||||
List<CardType> getCardType();
|
||||
EnumSet<CardType> getCardType();
|
||||
|
||||
List<String> getSubtype(Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@
|
|||
*/
|
||||
package mage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -55,7 +54,7 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
protected ObjectColor color;
|
||||
protected ObjectColor frameColor;
|
||||
protected FrameStyle frameStyle;
|
||||
protected List<CardType> cardType = new ArrayList<>();
|
||||
protected EnumSet<CardType> cardType = EnumSet.noneOf(CardType.class);
|
||||
protected List<String> subtype = new ArrayList<>();
|
||||
protected List<String> supertype = new ArrayList<>();
|
||||
protected Abilities<Ability> abilities;
|
||||
|
|
@ -127,7 +126,7 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CardType> getCardType() {
|
||||
public EnumSet<CardType> getCardType() {
|
||||
return cardType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,9 @@ package mage.cards.repository;
|
|||
import com.j256.ormlite.field.DataType;
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
|
|
@ -253,8 +252,8 @@ public class CardInfo {
|
|||
return Arrays.asList(list.split(SEPARATOR));
|
||||
}
|
||||
|
||||
public final List<CardType> getTypes() {
|
||||
ArrayList<CardType> list = new ArrayList<>();
|
||||
public final EnumSet<CardType> getTypes() {
|
||||
EnumSet<CardType> list = EnumSet.noneOf(CardType.class);
|
||||
for (String type : this.types.split(SEPARATOR)) {
|
||||
try {
|
||||
list.add(CardType.valueOf(type));
|
||||
|
|
@ -264,7 +263,7 @@ public class CardInfo {
|
|||
return list;
|
||||
}
|
||||
|
||||
public final void setTypes(List<CardType> types) {
|
||||
public final void setTypes(Set<CardType> types) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (CardType item : types) {
|
||||
sb.append(item.name()).append(SEPARATOR);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@
|
|||
*/
|
||||
package mage.designations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
|
|
@ -29,6 +28,7 @@ import mage.util.GameLog;
|
|||
*/
|
||||
public abstract class Designation implements MageObject {
|
||||
|
||||
private static EnumSet emptySet = EnumSet.noneOf(CardType.class);
|
||||
private static List emptyList = new ArrayList();
|
||||
private static ObjectColor emptyColor = new ObjectColor();
|
||||
private static ManaCosts<ManaCost> emptyCost = new ManaCostsImpl();
|
||||
|
|
@ -118,8 +118,8 @@ public abstract class Designation implements MageObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CardType> getCardType() {
|
||||
return emptyList;
|
||||
public EnumSet<CardType> getCardType() {
|
||||
return emptySet;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@
|
|||
*/
|
||||
package mage.game.command;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
|
|
@ -110,7 +112,7 @@ public class Commander implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CardType> getCardType() {
|
||||
public EnumSet<CardType> getCardType() {
|
||||
return sourceObject.getCardType();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@
|
|||
*/
|
||||
package mage.game.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
|
|
@ -51,7 +50,8 @@ import mage.util.GameLog;
|
|||
*/
|
||||
public class Emblem implements CommandObject {
|
||||
|
||||
private static List emptyList = new ArrayList();
|
||||
private static EnumSet<CardType> emptySet = EnumSet.noneOf(CardType.class);
|
||||
private static List emptyList = new ArrayList();
|
||||
private static ObjectColor emptyColor = new ObjectColor();
|
||||
private static ManaCosts emptyCost = new ManaCostsImpl();
|
||||
|
||||
|
|
@ -148,8 +148,8 @@ public class Emblem implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CardType> getCardType() {
|
||||
return emptyList;
|
||||
public EnumSet<CardType> getCardType() {
|
||||
return emptySet;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@
|
|||
*/
|
||||
package mage.game.stack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
|
|
@ -457,14 +456,14 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CardType> getCardType() {
|
||||
public EnumSet<CardType> getCardType() {
|
||||
if (faceDown) {
|
||||
List<CardType> cardTypes = new ArrayList<>();
|
||||
EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class);
|
||||
cardTypes.add(CardType.CREATURE);
|
||||
return cardTypes;
|
||||
}
|
||||
if (this.getSpellAbility() instanceof BestowAbility) {
|
||||
List<CardType> cardTypes = new ArrayList<>();
|
||||
EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class);
|
||||
cardTypes.addAll(card.getCardType());
|
||||
cardTypes.remove(CardType.CREATURE);
|
||||
return cardTypes;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@
|
|||
*/
|
||||
package mage.game.stack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
|
|
@ -72,7 +71,7 @@ import mage.watchers.Watcher;
|
|||
*/
|
||||
public class StackAbility extends StackObjImpl implements Ability {
|
||||
|
||||
private static List<CardType> emptyCardType = new ArrayList<>();
|
||||
private static EnumSet<CardType> emptyCardType = EnumSet.noneOf(CardType.class);
|
||||
private static List<String> emptyString = new ArrayList<>();
|
||||
private static ObjectColor emptyColor = new ObjectColor();
|
||||
private static ManaCosts<ManaCost> emptyCost = new ManaCostsImpl<>();
|
||||
|
|
@ -160,7 +159,7 @@ public class StackAbility extends StackObjImpl implements Ability {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CardType> getCardType() {
|
||||
public EnumSet<CardType> getCardType() {
|
||||
return emptyCardType;
|
||||
}
|
||||
|
||||
|
|
|
|||
28
Mage/src/test/java/mage/ContinuousEffectImplTest.java
Normal file
28
Mage/src/test/java/mage/ContinuousEffectImplTest.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package mage;
|
||||
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.constants.DependencyType;
|
||||
import mage.constants.Duration;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
||||
/**
|
||||
* Created by IGOUDT on 25-2-2017.
|
||||
*/
|
||||
public class ContinuousEffectImplTest {
|
||||
|
||||
@Test
|
||||
public void isDependentTo(){
|
||||
BoostTargetEffect ghe = new BoostTargetEffect(0,0, Duration.Custom);
|
||||
ghe.setDependedToType(DependencyType.AuraAddingRemoving);
|
||||
Set<UUID> x = ghe.isDependentTo(new ArrayList<>());
|
||||
Assert.assertThat(x.size(), is(0));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue