mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Merge branch 'master' into giant-oyster
This commit is contained in:
commit
b1be4ad7d5
100 changed files with 3683 additions and 421 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -24,6 +23,11 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
|||
private final int zoneChangeCounter;
|
||||
|
||||
public MageObjectReference(MageObject mageObject, Game game) {
|
||||
if (mageObject == null) {
|
||||
this.sourceId = null;
|
||||
this.zoneChangeCounter = -1;
|
||||
return;
|
||||
}
|
||||
this.sourceId = mageObject.getId();
|
||||
this.zoneChangeCounter = mageObject.getZoneChangeCounter(game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1051,7 +1051,8 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
|
||||
/**
|
||||
* Returns if this {@link Mana} object has more than or equal values of mana
|
||||
* as the passed in {@link Mana} object.
|
||||
* as the passed in {@link Mana} object. Ignores {Any} mana to prevent
|
||||
* endless iterations.
|
||||
*
|
||||
* @param mana the mana to compare with
|
||||
* @return if this object has more than or equal mana to the passed in
|
||||
|
|
@ -1090,13 +1091,44 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
moreMana = mana1;
|
||||
lessMana = mana2;
|
||||
}
|
||||
if (lessMana.getWhite() > moreMana.getWhite()
|
||||
|| lessMana.getRed() > moreMana.getRed()
|
||||
|| lessMana.getGreen() > moreMana.getGreen()
|
||||
|| lessMana.getBlue() > moreMana.getBlue()
|
||||
|| lessMana.getBlack() > moreMana.getBlack()
|
||||
|| lessMana.getColorless() > moreMana.getColorless()
|
||||
|| lessMana.getAny() > moreMana.getAny()) {
|
||||
int anyDiff = mana2.getAny() - mana1.getAny();
|
||||
if (lessMana.getWhite() > moreMana.getWhite()) {
|
||||
anyDiff -= lessMana.getWhite() - moreMana.getWhite();
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getRed() > moreMana.getRed()) {
|
||||
anyDiff -= lessMana.getRed() - moreMana.getRed();
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getGreen() > moreMana.getGreen()) {
|
||||
anyDiff -= lessMana.getGreen() - moreMana.getGreen();
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getBlue() > moreMana.getBlue()) {
|
||||
anyDiff -= lessMana.getBlue() - moreMana.getBlue();
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getBlack() > moreMana.getBlack()) {
|
||||
anyDiff -= lessMana.getBlack() - moreMana.getBlack();
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getColorless() > moreMana.getColorless()) {
|
||||
anyDiff -= lessMana.getColorless() - moreMana.getColorless();
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getAny() > moreMana.getAny()) {
|
||||
return null;
|
||||
}
|
||||
return moreMana;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import mage.abilities.effects.ContinuousEffectImpl;
|
|||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
public class CopyTokenEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected Token token;
|
||||
|
||||
public CopyTokenEffect(Token token) {
|
||||
|
|
@ -28,19 +28,19 @@ public class CopyTokenEffect extends ContinuousEffectImpl {
|
|||
permanent.setName(token.getName());
|
||||
permanent.getColor(game).setColor(token.getColor(game));
|
||||
permanent.getCardType().clear();
|
||||
for (CardType type: token.getCardType()) {
|
||||
for (CardType type : token.getCardType()) {
|
||||
permanent.addCardType(type);
|
||||
}
|
||||
permanent.getSubtype(game).clear();
|
||||
for (SubType type: token.getSubtype(game)) {
|
||||
for (SubType type : token.getSubtype(game)) {
|
||||
permanent.getSubtype(game).add(type);
|
||||
}
|
||||
permanent.getSuperType().clear();
|
||||
for (SuperType type: token.getSuperType()) {
|
||||
for (SuperType type : token.getSuperType()) {
|
||||
permanent.addSuperType(type);
|
||||
}
|
||||
permanent.getAbilities().clear();
|
||||
for (Ability ability: token.getAbilities()) {
|
||||
for (Ability ability : token.getAbilities()) {
|
||||
permanent.addAbility(ability, game);
|
||||
}
|
||||
permanent.getPower().setValue(token.getPower().getValue());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public class LoseArtifactTypeTargetEffect extends ContinuousEffectImpl{
|
||||
|
||||
public LoseArtifactTypeTargetEffect(Duration duration) {
|
||||
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Neutral);
|
||||
dependencyTypes.add(DependencyType.ArtifactAddingRemoving);
|
||||
setText("isn't an artifact");
|
||||
}
|
||||
|
||||
public LoseArtifactTypeTargetEffect(final LoseArtifactTypeTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoseArtifactTypeTargetEffect copy() {
|
||||
return new LoseArtifactTypeTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game); //To change body of generated methods, choose Tools | Templates.
|
||||
if (duration.isOnlyValidIfNoZoneChange()) {
|
||||
// If source permanent is no longer onto battlefield discard the effect
|
||||
if (source.getSourcePermanentIfItStillExists(game) == null) {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
for (UUID targetId : targetPointer.getTargets(game, source)) {
|
||||
if (targetId != null) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
permanent.getCardType().remove(CardType.ARTIFACT);
|
||||
permanent.getSubtype(game).removeAll(SubType.getArtifactTypes(false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -35,14 +35,12 @@ public class EquipAbility extends ActivatedAbilityImpl {
|
|||
|
||||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
ActivationStatus activationStatus = super.canActivate(playerId, game);
|
||||
if (activationStatus.canActivate()) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null && permanent.hasSubtype(SubType.EQUIPMENT, game)) {
|
||||
return activationStatus;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null && permanent.hasSubtype(SubType.EQUIPMENT, game) && !permanent.isCreature()) {
|
||||
return super.canActivate(playerId, game);
|
||||
} else {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
return activationStatus;
|
||||
}
|
||||
|
||||
public EquipAbility(final EquipAbility ability) {
|
||||
|
|
|
|||
|
|
@ -2,13 +2,22 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TimingRule;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -17,10 +26,29 @@ import mage.target.TargetPermanent;
|
|||
|
||||
//20091005 - 702.64
|
||||
public class FortifyAbility extends ActivatedAbilityImpl {
|
||||
public FortifyAbility(Zone zone, AttachEffect effect, Cost cost) {
|
||||
super(zone, effect, cost);
|
||||
this.addTarget(new TargetPermanent(new FilterControlledLandPermanent()));
|
||||
timing = TimingRule.SORCERY;
|
||||
|
||||
public FortifyAbility(int cost) {
|
||||
this(Outcome.AddAbility, new GenericManaCost(cost));
|
||||
}
|
||||
|
||||
public FortifyAbility(Outcome outcome, Cost cost) {
|
||||
this(outcome, cost, new TargetPermanent(new FilterControlledLandPermanent()));
|
||||
}
|
||||
|
||||
public FortifyAbility(Outcome outcome, Cost cost, Target target) {
|
||||
super(Zone.BATTLEFIELD, new AttachEffect(outcome, "Fortify"), cost);
|
||||
this.addTarget(target);
|
||||
this.timing = TimingRule.SORCERY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null && permanent.hasSubtype(SubType.FORTIFICATION, game) && !permanent.isCreature() && !permanent.isLand()) {
|
||||
return super.canActivate(playerId, game);
|
||||
} else {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
}
|
||||
|
||||
public FortifyAbility(final FortifyAbility ability) {
|
||||
|
|
@ -31,4 +59,10 @@ public class FortifyAbility extends ActivatedAbilityImpl {
|
|||
public FortifyAbility copy() {
|
||||
return new FortifyAbility(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Fortify " + costs.getText() + manaCosts.getText() + " (" + manaCosts.getText() + ": <i>Attach to target land you control. Fortify only as a sorcery.)</i>";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
|
|
@ -42,6 +42,7 @@ public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
List<Mana> netManas = new ArrayList<>();
|
||||
if (netMana.isEmpty() && game != null) {
|
||||
Player controller = game.getPlayer(getControllerId());
|
||||
if (controller != null) {
|
||||
|
|
@ -68,7 +69,8 @@ public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl
|
|||
}
|
||||
}
|
||||
}
|
||||
return netMana;
|
||||
netManas.addAll(netMana);
|
||||
return netManas;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ public class ConditionalManaAbility extends ActivatedManaAbilityImpl {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
List<Mana> newNetMana = new ArrayList<>();
|
||||
newNetMana.addAll(conditionalManaEffect.getNetMana(game, this));
|
||||
return newNetMana;
|
||||
return new ArrayList<>(conditionalManaEffect.getNetMana(game, this));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
boolean hasTapCost = hasTapCost(abilities.get(0));
|
||||
for (Mana netMana : netManas) {
|
||||
for (Mana mana : copy) {
|
||||
if (!hasTapCost || checkTappedForManaReplacement(abilities.get(0), game, netMana)) {
|
||||
if (!hasTapCost /* || checkTappedForManaReplacement(abilities.get(0), game, netMana) */) { // Seems to produce endless iterations so deactivated for now: https://github.com/magefree/mage/issues/5023
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(netMana);
|
||||
|
|
@ -114,6 +114,7 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
}
|
||||
|
||||
public void addManaWithCost(List<ActivatedManaAbilityImpl> abilities, Game game) {
|
||||
int replaces = 0;
|
||||
if (isEmpty()) {
|
||||
this.add(new Mana());
|
||||
}
|
||||
|
|
@ -187,7 +188,7 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
Mana moreValuable = Mana.getMoreValuableMana(newMana, existingMana);
|
||||
if (moreValuable != null) {
|
||||
existingMana.setToMana(moreValuable);
|
||||
logger.trace("mana replaced " + newMana.toString() + " <=> " + existingMana.toString() + " from " + ability.getRule());
|
||||
replaces++;
|
||||
continue CombineWithExisting;
|
||||
}
|
||||
}
|
||||
|
|
@ -203,6 +204,10 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (this.size() > 30 || replaces > 30) {
|
||||
logger.trace("ManaOptionsCosts " + this.size() + " Ign:" + replaces + " => " + this.toString());
|
||||
logger.trace("Abilities: " + abilities.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void addMana(Mana addMana) {
|
||||
|
|
@ -255,20 +260,28 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
this.clear();
|
||||
for (Mana mana : copy) {
|
||||
Mana oldMan = mana.copy();
|
||||
if (mana.includesMana(cost)) {
|
||||
// colorless costs can be paid with different colored mana, can lead to different color combinations
|
||||
if (mana.includesMana(cost)) { // it can be paid
|
||||
// generic mana costs can be paid with different colored mana, can lead to different color combinations
|
||||
if (cost.getGeneric() > 0 && cost.getGeneric() > (mana.getGeneric() + mana.getColorless())) {
|
||||
Mana coloredCost = cost.copy();
|
||||
coloredCost.setGeneric(0);
|
||||
mana.subtract(coloredCost);
|
||||
boolean oldManaWasReplaced = false;
|
||||
for (Mana payCombination : getPossiblePayCombinations(cost.getGeneric(), mana)) {
|
||||
Mana newMana = mana.copy();
|
||||
newMana.subtract(payCombination);
|
||||
newMana.add(addMana);
|
||||
if (oldMan.contains(newMana) && oldMan.count() > newMana.count()) {
|
||||
newMana.setToMana(oldMan);
|
||||
Mana moreValuable = Mana.getMoreValuableMana(oldMan, newMana);
|
||||
if (!oldMan.equals(moreValuable)) {
|
||||
this.add(newMana);
|
||||
if (moreValuable != null) {
|
||||
oldManaWasReplaced = true; // the new mana includes all possibilities of the old one
|
||||
}
|
||||
}
|
||||
this.add(newMana);
|
||||
|
||||
}
|
||||
if (!oldManaWasReplaced) {
|
||||
this.add(oldMan);
|
||||
}
|
||||
} else {
|
||||
while (mana.includesMana(cost)) {
|
||||
|
|
@ -303,28 +316,33 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
existingManas.add(new Mana());
|
||||
}
|
||||
for (Mana existingMana : existingManas) {
|
||||
Mana manaToPay = manaAvailable.copy();
|
||||
manaToPay.subtract(existingMana);
|
||||
if (manaToPay.getBlack() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.BlackMana(1).toString())) {
|
||||
manaToPay.subtract(Mana.BlackMana(1));
|
||||
Mana manaToPayFrom = manaAvailable.copy();
|
||||
manaToPayFrom.subtract(existingMana);
|
||||
if (manaToPayFrom.getBlack() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.BlackMana(1).toString())) {
|
||||
manaToPayFrom.subtract(Mana.BlackMana(1));
|
||||
addManaCombination(Mana.BlackMana(1), existingMana, payCombinations, payCombinationsStrings);
|
||||
}
|
||||
if (manaToPay.getBlue() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.BlueMana(1).toString())) {
|
||||
manaToPay.subtract(Mana.BlueMana(1));
|
||||
if (manaToPayFrom.getBlue() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.BlueMana(1).toString())) {
|
||||
manaToPayFrom.subtract(Mana.BlueMana(1));
|
||||
addManaCombination(Mana.BlueMana(1), existingMana, payCombinations, payCombinationsStrings);
|
||||
}
|
||||
if (manaToPay.getGreen() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.GreenMana(1).toString())) {
|
||||
manaToPay.subtract(Mana.GreenMana(1));
|
||||
if (manaToPayFrom.getGreen() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.GreenMana(1).toString())) {
|
||||
manaToPayFrom.subtract(Mana.GreenMana(1));
|
||||
addManaCombination(Mana.GreenMana(1), existingMana, payCombinations, payCombinationsStrings);
|
||||
}
|
||||
if (manaToPay.getRed() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.RedMana(1).toString())) {
|
||||
manaToPay.subtract(Mana.RedMana(1));
|
||||
if (manaToPayFrom.getRed() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.RedMana(1).toString())) {
|
||||
manaToPayFrom.subtract(Mana.RedMana(1));
|
||||
addManaCombination(Mana.RedMana(1), existingMana, payCombinations, payCombinationsStrings);
|
||||
}
|
||||
if (manaToPay.getWhite() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.WhiteMana(1).toString())) {
|
||||
manaToPay.subtract(Mana.WhiteMana(1));
|
||||
if (manaToPayFrom.getWhite() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.WhiteMana(1).toString())) {
|
||||
manaToPayFrom.subtract(Mana.WhiteMana(1));
|
||||
addManaCombination(Mana.WhiteMana(1), existingMana, payCombinations, payCombinationsStrings);
|
||||
}
|
||||
// Pay with any only needed if colored payment was not possible
|
||||
if (payCombinations.isEmpty() && manaToPayFrom.getAny() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.AnyMana(1).toString())) {
|
||||
manaToPayFrom.subtract(Mana.AnyMana(1));
|
||||
addManaCombination(Mana.AnyMana(1), existingMana, payCombinations, payCombinationsStrings);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -352,5 +370,16 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
list.add(s);
|
||||
}
|
||||
}
|
||||
// Remove fully included variations
|
||||
for (int i = this.size() - 1; i >= 0; i--) {
|
||||
for (int ii = 0; ii < i; ii++) {
|
||||
Mana moreValuable = Mana.getMoreValuableMana(this.get(i), this.get(ii));
|
||||
if (moreValuable != null) {
|
||||
this.get(ii).setToMana(moreValuable);
|
||||
this.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.Cost;
|
||||
|
|
@ -55,7 +55,7 @@ public class SimpleManaAbility extends ActivatedManaAbilityImpl {
|
|||
if (predictable) {
|
||||
return super.getNetMana(game);
|
||||
}
|
||||
return netMana;
|
||||
return new ArrayList<Mana>(netMana);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -54,7 +53,7 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implemen
|
|||
}
|
||||
return newNetMana;
|
||||
}
|
||||
return netMana;
|
||||
return new ArrayList<Mana>(netMana);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public enum CardRepository {
|
|||
// raise this if db structure was changed
|
||||
private static final long CARD_DB_VERSION = 51;
|
||||
// raise this if new cards were added to the server
|
||||
private static final long CARD_CONTENT_VERSION = 115;
|
||||
private static final long CARD_CONTENT_VERSION = 116;
|
||||
private Dao<CardInfo, Object> cardDao;
|
||||
private Set<String> classNames;
|
||||
|
||||
|
|
@ -159,7 +159,10 @@ public enum CardRepository {
|
|||
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
|
||||
qb.distinct().selectColumns("name");
|
||||
Where where = qb.where();
|
||||
where.and(where.not().not().like("supertypes", '%' + SuperType.BASIC.name() + '%'), where.like("types", '%' + CardType.LAND.name() + '%'));
|
||||
where.and(
|
||||
where.not().like("supertypes", '%' + SuperType.BASIC.name() + '%'),
|
||||
where.like("types", '%' + CardType.LAND.name() + '%')
|
||||
);
|
||||
List<CardInfo> results = cardDao.query(qb.prepare());
|
||||
for (CardInfo card : results) {
|
||||
int result = card.getName().indexOf(" // ");
|
||||
|
|
@ -252,7 +255,10 @@ public enum CardRepository {
|
|||
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
|
||||
qb.distinct().selectColumns("name");
|
||||
Where where = qb.where();
|
||||
where.and(where.not().like("types", '%' + CardType.CREATURE.name() + '%'), where.not().like("types", '%' + CardType.LAND.name() + '%'));
|
||||
where.and(
|
||||
where.not().like("types", '%' + CardType.CREATURE.name() + '%'),
|
||||
where.not().like("types", '%' + CardType.LAND.name() + '%')
|
||||
);
|
||||
List<CardInfo> results = cardDao.query(qb.prepare());
|
||||
for (CardInfo card : results) {
|
||||
int result = card.getName().indexOf(" // ");
|
||||
|
|
@ -275,7 +281,10 @@ public enum CardRepository {
|
|||
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
|
||||
qb.distinct().selectColumns("name");
|
||||
Where where = qb.where();
|
||||
where.and(where.not().like("types", '%' + CardType.ARTIFACT.name() + '%'), where.not().like("types", '%' + CardType.LAND.name() + '%'));
|
||||
where.and(
|
||||
where.not().like("types", '%' + CardType.ARTIFACT.name() + '%'),
|
||||
where.not().like("types", '%' + CardType.LAND.name() + '%')
|
||||
);
|
||||
List<CardInfo> results = cardDao.query(qb.prepare());
|
||||
for (CardInfo card : results) {
|
||||
int result = card.getName().indexOf(" // ");
|
||||
|
|
|
|||
|
|
@ -462,6 +462,16 @@ public enum SubType {
|
|||
return subTypeSet;
|
||||
}
|
||||
|
||||
public static Set<SubType> getArtifactTypes(boolean withCustomSets) {
|
||||
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
||||
for (SubType subType : values()) {
|
||||
if (subType.getSubTypeSet() == SubTypeSet.ArtifactType && (withCustomSets || !subType.customSet)) {
|
||||
subTypes.add(subType);
|
||||
}
|
||||
}
|
||||
return subTypes;
|
||||
}
|
||||
|
||||
public static Set<SubType> getPlaneswalkerTypes(boolean withCustomSets) {
|
||||
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
||||
for (SubType subType : values()) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package mage.filter.predicate.mageobject;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
|
||||
public class SharesColorPredicate implements Predicate<MageObject> {
|
||||
|
||||
private final ObjectColor color;
|
||||
|
||||
public SharesColorPredicate(ObjectColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(MageObject input, Game game) {
|
||||
return color != null && input.getColor(game).shares(color);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "shares a color";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
package mage.filter.predicate.permanent;
|
||||
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public class ControllerIsActivePlayerPredicate implements Predicate<Permanent> {
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
if(input.getControllerId() == null){
|
||||
return false;
|
||||
}
|
||||
return game.getActivePlayerId().equals(input.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "controlled by the active player";
|
||||
}
|
||||
}
|
||||
32
Mage/src/main/java/mage/game/permanent/token/OxToken.java
Normal file
32
Mage/src/main/java/mage/game/permanent/token/OxToken.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public final class OxToken extends TokenImpl {
|
||||
|
||||
public OxToken() {
|
||||
super("Ox", "2/4 white Ox creature token");
|
||||
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setWhite(true);
|
||||
subtype.add(SubType.OX);
|
||||
power = new MageInt(2);
|
||||
toughness = new MageInt(4);
|
||||
|
||||
}
|
||||
|
||||
public OxToken(final OxToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OxToken copy() {
|
||||
return new OxToken(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -2647,6 +2647,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
available.addMana(manaAbilities, game);
|
||||
}
|
||||
for (Abilities<ActivatedManaAbilityImpl> manaAbilities : sourceWithCosts) {
|
||||
available.removeDuplicated();
|
||||
available.addManaWithCost(manaAbilities, game);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
package mage.watchers.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public class WasBlockedThisTurnWatcher extends Watcher {
|
||||
|
||||
private final Set<MageObjectReference> wasBlockedThisTurnCreatures;
|
||||
|
||||
public WasBlockedThisTurnWatcher() {
|
||||
super(WasBlockedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
|
||||
wasBlockedThisTurnCreatures = new HashSet<>();
|
||||
}
|
||||
|
||||
public WasBlockedThisTurnWatcher(final WasBlockedThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
wasBlockedThisTurnCreatures = new HashSet<>(watcher.wasBlockedThisTurnCreatures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Watcher copy() {
|
||||
return new WasBlockedThisTurnWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
|
||||
this.wasBlockedThisTurnCreatures.add(new MageObjectReference(event.getTargetId(), game));
|
||||
}
|
||||
}
|
||||
|
||||
public Set<MageObjectReference> getWasBlockedThisTurnCreatures() {
|
||||
return this.wasBlockedThisTurnCreatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
wasBlockedThisTurnCreatures.clear();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue