mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
Sonar fixes
This commit is contained in:
parent
1621704b12
commit
178da75e4d
39 changed files with 97 additions and 79 deletions
|
|
@ -18,6 +18,7 @@ import mage.util.SubTypeList;
|
|||
import java.io.Serializable;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface MageObject extends MageItem, Serializable {
|
||||
|
|
@ -32,13 +33,13 @@ public interface MageObject extends MageItem, Serializable {
|
|||
|
||||
void setName(String name);
|
||||
|
||||
EnumSet<CardType> getCardType();
|
||||
Set<CardType> getCardType();
|
||||
|
||||
SubTypeList getSubtype(Game game);
|
||||
|
||||
boolean hasSubtype(SubType subtype, Game game);
|
||||
|
||||
EnumSet<SuperType> getSuperType();
|
||||
Set<SuperType> getSuperType();
|
||||
|
||||
Abilities<Ability> getAbilities();
|
||||
|
||||
|
|
@ -199,7 +200,7 @@ public interface MageObject extends MageItem, Serializable {
|
|||
|
||||
void setIsAllCreatureTypes(boolean value);
|
||||
|
||||
default void addCardTypes(EnumSet<CardType> cardType) {
|
||||
default void addCardTypes(Set<CardType> cardType) {
|
||||
getCardType().addAll(cardType);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
protected ObjectColor color;
|
||||
protected ObjectColor frameColor;
|
||||
protected FrameStyle frameStyle;
|
||||
protected EnumSet<CardType> cardType = EnumSet.noneOf(CardType.class);
|
||||
protected Set<CardType> cardType = EnumSet.noneOf(CardType.class);
|
||||
protected SubTypeList subtype = new SubTypeList();
|
||||
protected boolean isAllCreatureTypes;
|
||||
protected EnumSet<SuperType> supertype = EnumSet.noneOf(SuperType.class);
|
||||
protected Set<SuperType> supertype = EnumSet.noneOf(SuperType.class);
|
||||
protected Abilities<Ability> abilities;
|
||||
protected String text;
|
||||
protected MageInt power;
|
||||
|
|
@ -111,7 +111,7 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<CardType> getCardType() {
|
||||
public Set<CardType> getCardType() {
|
||||
return cardType;
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
public Set<SuperType> getSuperType() {
|
||||
return supertype;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
package mage.abilities;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -24,7 +25,7 @@ public class SpecialActions extends AbilitiesImpl<SpecialAction> {
|
|||
* false = only non mana actions get returned
|
||||
* @return
|
||||
*/
|
||||
public LinkedHashMap<UUID, SpecialAction> getControlledBy(UUID controllerId, boolean manaAction) {
|
||||
public Map<UUID, SpecialAction> getControlledBy(UUID controllerId, boolean manaAction) {
|
||||
LinkedHashMap<UUID, SpecialAction> controlledBy = new LinkedHashMap<>();
|
||||
for (SpecialAction action: this) {
|
||||
if (action.isControlledBy(controllerId) && action.isManaAction() == manaAction) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public enum RaidCondition implements Condition {
|
|||
return watcher != null && watcher.getNumberOfAttackersCurrentTurn(source.getControllerId()) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if you attacked with a creature this turn";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class AlternativeCost2Impl<T extends AlternativeCost2Impl<T>> extends Cos
|
|||
this.name = name;
|
||||
this.delimiter = delimiter;
|
||||
if (reminderText != null) {
|
||||
this.reminderText = new StringBuilder("<i>").append(reminderText).append("</i>").toString();
|
||||
this.reminderText = "<i>" + reminderText + "</i>";
|
||||
}
|
||||
this.add(cost);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class AlternativeCostSourceAbility extends StaticAbility implements AlternativeSourceCosts {
|
||||
|
||||
Costs<AlternativeCost2> alternateCosts = new CostsImpl<>();
|
||||
private Costs<AlternativeCost2> alternateCosts = new CostsImpl<>();
|
||||
protected Condition condition;
|
||||
protected String rule;
|
||||
protected FilterCard filter;
|
||||
|
|
@ -149,8 +149,7 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
if (!onlyMana) {
|
||||
ability.getCosts().clear();
|
||||
}
|
||||
for (Cost cost : alternativeCostsToCheck) {
|
||||
AlternativeCost2 alternateCost = (AlternativeCost2) cost;
|
||||
for (AlternativeCost2 alternateCost : alternativeCostsToCheck) {
|
||||
alternateCost.activate();
|
||||
for (Iterator it = ((Costs) alternateCost).iterator(); it.hasNext();) {
|
||||
Cost costDeailed = (Cost) it.next();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
|
|
@ -140,7 +141,7 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
|
|||
if (permanent != null) {
|
||||
// handle copies of copies
|
||||
Permanent copyFromPermanent = permanent;
|
||||
for (Effect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
|
||||
for (ContinuousEffect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
|
||||
if (effect instanceof CopyEffect) {
|
||||
CopyEffect copyEffect = (CopyEffect) effect;
|
||||
// there is another copy effect that our targetPermanent copies stats from
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
|
|
@ -84,7 +85,7 @@ public class CreateTokenEffect extends OneShotEffect {
|
|||
return lastAddedTokenId;
|
||||
}
|
||||
|
||||
public ArrayList<UUID> getLastAddedTokenIds() {
|
||||
public List<UUID> getLastAddedTokenIds() {
|
||||
return lastAddedTokenIds;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ public class UntapLandsEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game)) {
|
||||
for (Object targetId : target.getTargets()) {
|
||||
Permanent p = game.getPermanent((UUID) targetId);
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent p = game.getPermanent(targetId);
|
||||
if (p != null) {
|
||||
p.untap(game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
|
|||
if (numberToDiscard > 0) {
|
||||
TargetCard target = new TargetCard(numberToDiscard, Zone.HAND, filter);
|
||||
if (controller.choose(Outcome.Benefit, revealedCards, target, game)) {
|
||||
for (Object targetId : target.getTargets()) {
|
||||
Card card = revealedCards.get((UUID) targetId, game);
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Card card = revealedCards.get(targetId, game);
|
||||
if (card != null) {
|
||||
if (!player.discard(card, source, game)) {
|
||||
result = false;
|
||||
|
|
|
|||
|
|
@ -244,8 +244,8 @@ public class CardInfo {
|
|||
return Arrays.asList(list.split(SEPARATOR));
|
||||
}
|
||||
|
||||
public final EnumSet<CardType> getTypes() {
|
||||
EnumSet<CardType> list = EnumSet.noneOf(CardType.class);
|
||||
public final Set<CardType> getTypes() {
|
||||
Set<CardType> list = EnumSet.noneOf(CardType.class);
|
||||
for (String type : this.types.split(SEPARATOR)) {
|
||||
try {
|
||||
list.add(CardType.valueOf(type));
|
||||
|
|
@ -310,8 +310,8 @@ public class CardInfo {
|
|||
this.subtypes = joinList(subtypes);
|
||||
}
|
||||
|
||||
public final EnumSet<SuperType> getSupertypes() {
|
||||
EnumSet<SuperType> list = EnumSet.noneOf(SuperType.class);
|
||||
public final Set<SuperType> getSupertypes() {
|
||||
Set<SuperType> list = EnumSet.noneOf(SuperType.class);
|
||||
for (String type : this.supertypes.split(SEPARATOR)) {
|
||||
try {
|
||||
list.add(SuperType.valueOf(type));
|
||||
|
|
|
|||
|
|
@ -5,15 +5,16 @@ import mage.Mana;
|
|||
import mage.ObjectColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public class ChoiceColor extends ChoiceImpl {
|
||||
|
||||
private static final ArrayList<String> colorChoices = getBaseColors();
|
||||
private static final List<String> colorChoices = getBaseColors();
|
||||
|
||||
public static ArrayList<String> getBaseColors() {
|
||||
public static List<String> getBaseColors() {
|
||||
ArrayList<String> arr = new ArrayList<>();
|
||||
arr.add("Green");
|
||||
arr.add("Blue");
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import mage.util.SubTypeList;
|
|||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Commander implements CommandObject {
|
||||
|
|
@ -122,7 +123,7 @@ public class Commander implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<CardType> getCardType() {
|
||||
public Set<CardType> getCardType() {
|
||||
return sourceObject.getCardType();
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +138,7 @@ public class Commander implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
public Set<SuperType> getSuperType() {
|
||||
return sourceObject.getSuperType();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,7 @@ import mage.players.Player;
|
|||
import mage.util.GameLog;
|
||||
import mage.util.SubTypeList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -458,7 +455,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<CardType> getCardType() {
|
||||
public Set<CardType> getCardType() {
|
||||
if (faceDown) {
|
||||
EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class);
|
||||
cardTypes.add(CardType.CREATURE);
|
||||
|
|
@ -500,7 +497,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
public Set<SuperType> getSuperType() {
|
||||
return card.getSuperType();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue