mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00: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
|
@ -205,7 +205,7 @@ public class CardInfoWindowDialog extends MageDialog {
|
|||
private int qtyCardTypes(mage.view.CardsView cardsView){
|
||||
Set<String> cardTypesPresent = new LinkedHashSet<String>() {};
|
||||
for (CardView card : cardsView.values()){
|
||||
List<CardType> cardTypes = card.getCardTypes();
|
||||
Set<CardType> cardTypes = card.getCardTypes();
|
||||
for (CardType cardType : cardTypes){
|
||||
cardTypesPresent.add(cardType.toString());
|
||||
}
|
||||
|
|
|
@ -869,7 +869,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
Set<String> cardTypesPresent = new LinkedHashSet<String>() {
|
||||
};
|
||||
for (CardView card : cardsView.values()) {
|
||||
List<CardType> cardTypes = card.getCardTypes();
|
||||
Set<CardType> cardTypes = card.getCardTypes();
|
||||
for (CardType cardType : cardTypes) {
|
||||
cardTypesPresent.add(cardType.toString());
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
package mage.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
|
||||
|
@ -53,7 +55,7 @@ public class AbilityView extends CardView {
|
|||
this.power = "";
|
||||
this.toughness = "";
|
||||
this.loyalty = "";
|
||||
this.cardTypes = new ArrayList<>();
|
||||
this.cardTypes = new HashSet<>();
|
||||
this.subTypes = new ArrayList<>();
|
||||
this.superTypes = new ArrayList<>();
|
||||
this.color = new ObjectColor();
|
||||
|
|
|
@ -27,9 +27,8 @@
|
|||
*/
|
||||
package mage.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Mode;
|
||||
|
@ -71,7 +70,7 @@ public class CardView extends SimpleCardView {
|
|||
protected String toughness;
|
||||
protected String loyalty;
|
||||
protected String startingLoyalty;
|
||||
protected List<CardType> cardTypes;
|
||||
protected Set<CardType> cardTypes;
|
||||
protected List<String> subTypes;
|
||||
protected List<String> superTypes;
|
||||
protected ObjectColor color;
|
||||
|
@ -519,7 +518,7 @@ public class CardView extends SimpleCardView {
|
|||
this.toughness = "";
|
||||
this.loyalty = "";
|
||||
this.startingLoyalty = "";
|
||||
this.cardTypes = new ArrayList<>();
|
||||
this.cardTypes = new HashSet<>();
|
||||
this.subTypes = new ArrayList<>();
|
||||
this.superTypes = new ArrayList<>();
|
||||
this.color = new ObjectColor();
|
||||
|
@ -640,7 +639,7 @@ public class CardView extends SimpleCardView {
|
|||
return startingLoyalty;
|
||||
}
|
||||
|
||||
public List<CardType> getCardTypes() {
|
||||
public Set<CardType> getCardTypes() {
|
||||
return cardTypes;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ public class UserManager {
|
|||
calendar.add(Calendar.MINUTE, -3);
|
||||
List<User> usersToCheck = new ArrayList<>(users.values());
|
||||
for (User user : usersToCheck) {
|
||||
if (!user.getUserState().equals(UserState.Expired) && user.isExpired(calendar.getTime())) {
|
||||
if (user.getUserState() != UserState.Expired && user.isExpired(calendar.getTime())) {
|
||||
removeUser(user.getId(), DisconnectReason.SessionExpired);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -401,7 +401,7 @@ public class GameController implements GameCallback {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (player.isHuman() && gameSessions.get(player.getId()) == null) {
|
||||
if (player.isHuman() && !gameSessions.containsKey(player.getId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -410,11 +410,11 @@ public class GameController implements GameCallback {
|
|||
}
|
||||
|
||||
public void watch(UUID userId) {
|
||||
if (userPlayerMap.get(userId) != null) {
|
||||
if (userPlayerMap.containsKey(userId)) {
|
||||
// You can't watch a game if you already a player in it
|
||||
return;
|
||||
}
|
||||
if (watchers.get(userId) != null) {
|
||||
if (watchers.containsKey(userId)) {
|
||||
// You can't watch a game if you already watch it
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.OnEventTriggeredAbility;
|
||||
|
@ -95,7 +96,7 @@ class CrawlingSensationTriggeredAbility extends TriggeredAbilityImpl {
|
|||
for (Card card : zEvent.getCards()) {
|
||||
if (card != null) {
|
||||
UUID cardOwnerId = card.getOwnerId();
|
||||
List<CardType> cardType = card.getCardType();
|
||||
Set<CardType> cardType = card.getCardType();
|
||||
|
||||
if (cardOwnerId != null
|
||||
&& card.getOwnerId().equals(getControllerId())
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
|
@ -90,7 +91,7 @@ class PermanentsAreArtifactsEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
|
||||
List<CardType> cardType = perm.getCardType();
|
||||
Set<CardType> cardType = perm.getCardType();
|
||||
if (!cardType.contains(CardType.ARTIFACT)) {
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.cards.p;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -164,7 +165,7 @@ class PossibilityStormEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean sharesType(Card card, List<CardType> cardTypes) {
|
||||
private boolean sharesType(Card card, Set<CardType> cardTypes) {
|
||||
for (CardType type : card.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
return true;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.cards.p;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -95,7 +96,7 @@ class PrimalSurgeEffect extends OneShotEffect {
|
|||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToExile(null, "", source.getSourceId(), game);
|
||||
List<CardType> cardType = card.getCardType();
|
||||
Set<CardType> cardType = card.getCardType();
|
||||
if ((cardType.contains(CardType.ARTIFACT) || cardType.contains(CardType.CREATURE)
|
||||
|| cardType.contains(CardType.ENCHANTMENT) || cardType.contains(CardType.LAND)
|
||||
|| cardType.contains(CardType.PLANESWALKER))
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
|
@ -99,7 +100,7 @@ class SidisiBroodTyrantTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (card != null) {
|
||||
|
||||
UUID cardOwnerId = card.getOwnerId();
|
||||
List<CardType> cardType = card.getCardType();
|
||||
Set<CardType> cardType = card.getCardType();
|
||||
|
||||
if (cardOwnerId != null
|
||||
&& card.getOwnerId().equals(getControllerId())
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
|
@ -110,7 +111,7 @@ class TheGitrogMonsterTriggeredAbility extends TriggeredAbilityImpl {
|
|||
for (Card card : zEvent.getCards()) {
|
||||
if (card != null) {
|
||||
UUID cardOwnerId = card.getOwnerId();
|
||||
List<CardType> cardType = card.getCardType();
|
||||
Set<CardType> cardType = card.getCardType();
|
||||
if (cardOwnerId != null
|
||||
&& card.getOwnerId().equals(getControllerId())
|
||||
&& cardType != null
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package org.mage.test.cards.continuous;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* Created by IGOUDT on 23-2-2017.
|
||||
*/
|
||||
public class AuratouchedMageTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testSearch() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 10);
|
||||
|
||||
addCard(Zone.HAND, playerA, "Auratouched Mage");
|
||||
|
||||
castSpell(0, PhaseStep.PRECOMBAT_MAIN, playerA, "Auratouched Mage");
|
||||
addCard(Zone.LIBRARY, playerA, "White Ward", 1);
|
||||
setChoice(playerA, "White ward");
|
||||
setStopAt(0, PhaseStep.PRECOMBAT_MAIN);
|
||||
execute();
|
||||
}
|
||||
|
||||
}
|
|
@ -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…
Reference in a new issue