mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
Merge pull request #3042 from ingmargoudt/card_functions
move static function to CardImpl, and other api fixes
This commit is contained in:
commit
884ae83791
32 changed files with 177 additions and 296 deletions
|
|
@ -45,7 +45,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -92,7 +91,7 @@ class AlphaStatusDynamicValue implements DynamicValue {
|
|||
if (enchanted != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game)) {
|
||||
if (!permanent.getId().equals(enchanted.getId())) {
|
||||
if (CardUtil.shareSubtypes(enchanted, permanent, game)) {
|
||||
if (enchanted.shareSubtypes(permanent, game)) {
|
||||
xValue += 2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
|
@ -134,9 +134,9 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
|||
return new TargetControlledPermanentSharingOpponentPermanentCardType(this);
|
||||
}
|
||||
|
||||
private Set<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Player controller = game.getPlayer(sourceControllerId);
|
||||
Set<CardType> cardTypes = new HashSet<>();
|
||||
EnumSet<CardType> cardTypes =EnumSet.noneOf(CardType.class);
|
||||
if (controller != null) {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(sourceControllerId, game)) {
|
||||
if (controller.hasOpponent(permanent.getControllerId(), game)) {
|
||||
|
|
@ -171,7 +171,7 @@ class DaringThiefSecondTarget extends TargetPermanent {
|
|||
Permanent target1 = game.getPermanent(source.getFirstTarget());
|
||||
Permanent opponentPermanent = game.getPermanent(id);
|
||||
if (target1 != null && opponentPermanent != null) {
|
||||
return CardUtil.shareTypes(target1, opponentPermanent);
|
||||
return target1.shareTypes(opponentPermanent);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -184,7 +184,7 @@ class DaringThiefSecondTarget extends TargetPermanent {
|
|||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (CardUtil.shareTypes(permanent, firstTarget)) {
|
||||
if (permanent.shareTypes(firstTarget)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import mage.filter.common.FilterControlledCreaturePermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -102,7 +101,7 @@ class DescendantsPathEffect extends OneShotEffect {
|
|||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
|
||||
boolean found = false;
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
|
||||
if (CardUtil.shareSubtypes(card, permanent, game)) {
|
||||
if (card.shareSubtypes(permanent, game)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ import mage.game.stack.Spell;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetSpell;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -90,15 +88,13 @@ class DesertionEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Spell targetSpell = game.getStack().getSpell(targetPointer.getFirst(game, source));
|
||||
if (targetSpell != null) {
|
||||
Set<CardType> cardTypes = new HashSet<>(targetSpell.getCardType());
|
||||
if (!cardTypes.isEmpty()) {
|
||||
//targetPointer.getFirst(game, source)
|
||||
if (cardTypes.contains(CardType.ARTIFACT) || cardTypes.contains(CardType.CREATURE)) {
|
||||
if (targetSpell.isArtifact() || targetSpell.isCreature()) {
|
||||
return game.getStack().counter(targetSpell.getId(), source.getSourceId(), game, Zone.BATTLEFIELD, false, ZoneDetail.NONE);
|
||||
} else {
|
||||
return game.getStack().counter(targetSpell.getId(), source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import mage.constants.*;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -106,7 +106,7 @@ class DuskFeasterCostReductionEffect extends CostModificationEffectImpl {
|
|||
boolean hasDelirium = false;
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
HashSet<CardType> foundCardTypes = new HashSet<>();
|
||||
EnumSet<CardType> foundCardTypes = EnumSet.noneOf(CardType.class);
|
||||
for (Card card : controller.getGraveyard().getCards(game)) {
|
||||
foundCardTypes.addAll(card.getCardType());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
*/
|
||||
package mage.cards.k;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttachableToRestrictedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -46,7 +45,8 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -111,7 +111,7 @@ class KondasBannerTypeBoostEffect extends BoostAllEffect {
|
|||
Permanent equipedCreature = game.getPermanent(equipment.getAttachedTo());
|
||||
if (equipedCreature != null) {
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (CardUtil.shareSubtypes(perm, equipedCreature, game)) {
|
||||
if (perm.shareSubtypes(equipedCreature, game)) {
|
||||
perm.addPower(power.calculate(game, source, this));
|
||||
perm.addToughness(toughness.calculate(game, source, this));
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
|
||||
|
|
@ -42,7 +41,8 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -91,7 +91,7 @@ class ManaEchoesEffect extends OneShotEffect {
|
|||
if (controller != null && permanent != null) {
|
||||
int foundCreatures = 0;
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
|
||||
if (CardUtil.shareSubtypes(permanent, perm, game)) {
|
||||
if (permanent.shareSubtypes(perm, game)) {
|
||||
foundCreatures++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@
|
|||
*/
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -40,14 +37,7 @@ import mage.abilities.effects.ContinuousEffectImpl;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.CommandObject;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -55,6 +45,8 @@ import mage.game.stack.Spell;
|
|||
import mage.players.ManaPoolItem;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author duncant
|
||||
*/
|
||||
|
|
@ -91,10 +83,7 @@ class PermanentsAreArtifactsEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
|
||||
Set<CardType> cardType = perm.getCardType();
|
||||
if (!cardType.contains(CardType.ARTIFACT)) {
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
}
|
||||
perm.getCardType().add(CardType.ARTIFACT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,21 +27,20 @@
|
|||
*/
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
|
|
@ -96,10 +95,7 @@ class PrimalSurgeEffect extends OneShotEffect {
|
|||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToExile(null, "", source.getSourceId(), game);
|
||||
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))
|
||||
if (card.isPermanent()
|
||||
&& player.chooseUse(Outcome.PutCardInPlay, "Put " + card.getName() + " onto the battlefield?", source, game)) {
|
||||
card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class SemblanceAnvilCostReductionEffect extends CostModificationEffectImpl {
|
|||
List<UUID> imprinted = permanent.getImprinted();
|
||||
if (!imprinted.isEmpty()) {
|
||||
Card imprintedCard = game.getCard(imprinted.get(0));
|
||||
if (imprintedCard != null && CardUtil.shareTypes(imprintedCard, sourceCard)) {
|
||||
if (imprintedCard != null && imprintedCard.shareTypes(sourceCard)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@
|
|||
*/
|
||||
package mage.cards.s;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
|
||||
|
|
@ -41,7 +38,10 @@ import mage.filter.FilterPermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -88,7 +88,7 @@ class TargetPermanentsThatShareCardType extends TargetPermanent {
|
|||
if (targetOne == null || targetTwo == null) {
|
||||
return false;
|
||||
}
|
||||
return CardUtil.shareTypes(targetOne, targetTwo);
|
||||
return targetOne.shareTypes(targetTwo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
|
|
@ -43,7 +42,8 @@ import mage.constants.Zone;
|
|||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -85,7 +85,7 @@ class StoneforgeMasterworkDynamicValue implements DynamicValue {
|
|||
if (equipped != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), sourceAbility.getControllerId(), game)) {
|
||||
if (!permanent.getId().equals(equipped.getId())) {
|
||||
if (CardUtil.shareSubtypes(equipped, permanent, game)) {
|
||||
if (equipped.shareSubtypes(permanent, game)) {
|
||||
xValue++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class TheGitrogMonsterTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (cardOwnerId != null
|
||||
&& card.getOwnerId().equals(getControllerId())
|
||||
&& cardType != null
|
||||
&& cardType.contains(CardType.LAND)) {
|
||||
&& card.isLand()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
*/
|
||||
package mage.cards.w;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -56,6 +52,11 @@ import mage.target.common.TargetControlledCreaturePermanent;
|
|||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
|
|
@ -158,7 +159,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent {
|
|||
Permanent firstTargetCreature = game.getPermanent(firstTargetId);
|
||||
if (firstTargetCreature != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, game)) {
|
||||
if (!permanent.getId().equals(firstTargetId) && CardUtil.shareSubtypes(firstTargetCreature, permanent, game)) {
|
||||
if (!permanent.getId().equals(firstTargetId) && firstTargetCreature.shareSubtypes(permanent, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -172,7 +173,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
for (Permanent permanent1 : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, game)) {
|
||||
for (Permanent permanent2 : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, game)) {
|
||||
if (!Objects.equals(permanent1, permanent2) && CardUtil.shareSubtypes(permanent1, permanent2, game)) {
|
||||
if (!Objects.equals(permanent1, permanent2) && permanent1.shareSubtypes(permanent2, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -198,7 +199,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent {
|
|||
}
|
||||
else {
|
||||
Permanent firstTarget = game.getPermanent(this.getTargets().get(0));
|
||||
if (firstTarget != null && CardUtil.shareSubtypes(firstTarget, targetPermanent, game)) {
|
||||
if (firstTarget != null && firstTarget.shareSubtypes(targetPermanent, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue