Merge branch 'magefree/master'

This commit is contained in:
Samuel Sandeen 2016-09-08 19:12:19 -04:00
commit ac6a289275
95 changed files with 2166 additions and 145 deletions

View file

@ -7,6 +7,7 @@ import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.cards.FrameStyle;
import mage.constants.CardType;
import mage.game.Game;
@ -37,6 +38,8 @@ public interface MageObject extends MageItem, Serializable {
ObjectColor getColor(Game game);
ObjectColor getFrameColor(Game game);
FrameStyle getFrameStyle();
ManaCosts<ManaCost> getManaCost();

View file

@ -39,6 +39,7 @@ import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.keyword.ChangelingAbility;
import mage.abilities.mana.ManaAbility;
import mage.cards.FrameStyle;
import mage.constants.CardType;
import mage.game.Game;
import mage.util.CardUtil;
@ -52,6 +53,7 @@ public abstract class MageObjectImpl implements MageObject {
protected ManaCosts<ManaCost> manaCost;
protected ObjectColor color;
protected ObjectColor frameColor;
protected FrameStyle frameStyle;
protected List<CardType> cardType = new ArrayList<>();
protected List<String> subtype = new ArrayList<>();
protected List<String> supertype = new ArrayList<>();
@ -71,6 +73,7 @@ public abstract class MageObjectImpl implements MageObject {
toughness = new MageInt(0);
color = new ObjectColor();
frameColor = new ObjectColor();
frameStyle = FrameStyle.M15_NORMAL;
manaCost = new ManaCostsImpl<>("");
abilities = new AbilitiesImpl<>();
}
@ -82,6 +85,7 @@ public abstract class MageObjectImpl implements MageObject {
text = object.text;
color = object.color.copy();
frameColor = object.frameColor.copy();
frameStyle = object.frameStyle;
power = object.power.copy();
toughness = object.toughness.copy();
abilities = object.abilities.copy();
@ -221,6 +225,11 @@ public abstract class MageObjectImpl implements MageObject {
}
}
@Override
public FrameStyle getFrameStyle() {
return frameStyle;
}
@Override
public ManaCosts<ManaCost> getManaCost() {
return manaCost;

View file

@ -0,0 +1,85 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.costs.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author emerald000
*/
public class PayEnergyCost extends CostImpl {
private final int amount;
public PayEnergyCost(int amount) {
this.amount = amount;
setText();
}
public PayEnergyCost(PayEnergyCost cost) {
super(cost);
this.amount = cost.amount;
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
Player player = game.getPlayer(controllerId);
return player != null && player.getCounters().getCount(CounterType.ENERGY) >= amount;
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player player = game.getPlayer(controllerId);
if (player != null) {
player.getCounters().removeCounter(CounterType.ENERGY, amount);
paid = true;
}
return paid;
}
@Override
public PayEnergyCost copy() {
return new PayEnergyCost(this);
}
private void setText() {
StringBuilder sb = new StringBuilder("Pay ");
for (int i = 0; i < amount; i++) {
sb.append("{E}");
}
this.text = sb.toString();
}
}

View file

@ -65,12 +65,12 @@ public class Effects extends ArrayList<Effect> {
StringBuilder sbText = new StringBuilder();
String lastRule = null;
for (Effect effect: this) {
String endString = "";
String endString = "";
String nextRule = effect.getText(mode);
if (nextRule != null) {
if (nextRule.startsWith("and ") || nextRule.startsWith("with ")) {
endString = " ";
} else if (nextRule.startsWith(",")) {
} else if (nextRule.startsWith(",") || nextRule.startsWith(" ")) {
endString = "";
} else if (lastRule != null && lastRule.length()> 3) {
if (!lastRule.endsWith(".") && !lastRule.endsWith("<br>")) {
@ -84,7 +84,7 @@ public class Effects extends ArrayList<Effect> {
}
lastRule = nextRule;
}
if (lastRule != null && lastRule.length()> 3 &&
if (lastRule != null && lastRule.length()> 3 &&
!lastRule.endsWith(".") &&
!lastRule.endsWith("\"") &&
!lastRule.startsWith("<b>Level ") &&

View file

@ -193,10 +193,10 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
token.addAbility(FlyingAbility.getInstance());
}
if (tokenPower != Integer.MIN_VALUE) {
token.setPower(tokenPower);
token.getPower().modifyBaseValue(tokenPower);
}
if (tokenToughness != Integer.MIN_VALUE) {
token.setToughness(tokenToughness);
token.getToughness().modifyBaseValue(tokenToughness);
}
if (additionalSubType != null && !token.getSubtype(game).contains(additionalSubType)) {
token.getSubtype(game).add(additionalSubType);

View file

@ -32,6 +32,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -48,16 +49,30 @@ import mage.util.CardUtil;
public class SweepEffect extends OneShotEffect {
private final String sweepSubtype;
private FilterPermanent setFilter = null;
private boolean notTarget = true;
public SweepEffect(String sweepSubtype) {
super(Outcome.Benefit);
this.sweepSubtype = sweepSubtype;
this.staticText = "<i>Sweep</i> - Return any number of " + sweepSubtype + (sweepSubtype.endsWith("s") ? "" : "s") + " you control to their owner's hand";
}
public SweepEffect(FilterPermanent filter, String text, boolean notTarget) {
super(Outcome.Benefit);
this.sweepSubtype = text;
this.staticText = "Return any number of " + text + " you control to their owner's hand";
this.setFilter = filter;
this.notTarget = notTarget;
}
public SweepEffect(final SweepEffect effect) {
super(effect);
this.sweepSubtype = effect.sweepSubtype;
this.setFilter = effect.setFilter;
this.notTarget = effect.notTarget;
}
@Override
@ -69,9 +84,15 @@ public class SweepEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterPermanent filter = new FilterControlledLandPermanent(new StringBuilder("any number of ").append(sweepSubtype).append("s you control").toString());
filter.add(new SubtypePredicate(sweepSubtype));
Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
FilterPermanent filter;
if (setFilter == null) {
filter = new FilterControlledLandPermanent(new StringBuilder("any number of ").append(sweepSubtype).append("s you control").toString());
filter.add(new SubtypePredicate(sweepSubtype));
} else {
filter = setFilter;
}
Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, notTarget);
if (controller.chooseTarget(outcome, target, source, game)) {
game.getState().setValue(CardUtil.getCardZoneString("sweep", source.getSourceId(), game), target.getTargets().size());
controller.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);

View file

@ -27,17 +27,15 @@
*/
package mage.abilities.keyword;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.ServoToken;
import mage.players.Player;
import mage.util.CardUtil;
@ -105,15 +103,3 @@ class FabricateEffect extends OneShotEffect {
return false;
}
}
class ServoToken extends Token {
ServoToken() {
super("Servo", "1/1 colorless Servo artifact creature token");
cardType.add(CardType.ARTIFACT);
cardType.add(CardType.CREATURE);
subtype.add("Servo");
power = new MageInt(1);
toughness = new MageInt(1);
}
}

View file

@ -0,0 +1,79 @@
/*
* 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.cards;
/**
*
* @author StravantUser
*/
public enum FrameStyle {
/**
* The default card frame, normal M15 card frames
*/
M15_NORMAL(BorderType.M15, false),
/**
* Battle for Zendkiar full art basic lands
*/
BFZ_FULL_ART_BASIC(BorderType.M15, true),
/**
* Zenkikar full art lands
*/
ZEN_FULL_ART_BASIC(BorderType.MOD, true),
/**
* Unhinged full art lands
*/
UNH_FULL_ART_BASIC(BorderType.SPC, true),
/**
* Unglued full art lands
*/
UGL_FULL_ART_BASIC(BorderType.SPC, true);
/**
* General type of card
*/
public enum BorderType {
/**
* Various specialty borders
* EG: Unhinged, Unglued
*/
SPC,
/**
* Old border cards
*/
OLD,
/**
* Modern border cards (8th -> Theros)
*/
MOD,
/**
* M15 border cards (M14 -> current)
*/
M15
}
private BorderType borderType;
private boolean isFullArt;
public BorderType getBorderType() {
return borderType;
}
public boolean isFullArt() {
return isFullArt;
}
FrameStyle(BorderType borderType, boolean isFullArt) {
this.borderType = borderType;
this.isFullArt = isFullArt;
}
}

View file

@ -30,6 +30,7 @@ public class MockCard extends CardImpl {
this.subtype = card.getSubTypes();
this.supertype = card.getSupertypes();
this.usesVariousArt = card.usesVariousArt();
this.manaCost = new ManaCostsImpl(join(card.getManaCosts()));
@ -37,6 +38,7 @@ public class MockCard extends CardImpl {
this.color = card.getColor();
this.frameColor = card.getFrameColor();
this.frameStyle = card.getFrameStyle();
this.splitCard = card.isSplitCard();
this.flipCard = card.isFlipCard();

View file

@ -36,6 +36,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.cards.FrameStyle;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.ObjectColor;
@ -100,6 +101,8 @@ public class CardInfo {
@DatabaseField
protected String frameColor;
@DatabaseField
protected String frameStyle;
@DatabaseField
protected boolean splitCard;
@DatabaseField
protected boolean splitCardHalf;
@ -138,6 +141,7 @@ public class CardInfo {
this.secondSideName = secondSide.getName();
}
this.frameStyle = card.getFrameStyle().toString();
this.frameColor = card.getFrameColor(null).toString();
this.blue = card.getColor(null).isBlue();
this.black = card.getColor(null).isBlack();
@ -227,6 +231,10 @@ public class CardInfo {
return new ObjectColor(frameColor);
}
public FrameStyle getFrameStyle() {
return FrameStyle.valueOf(this.frameStyle);
}
private String joinList(List<String> items) {
StringBuilder sb = new StringBuilder();
for (Object item : items) {

View file

@ -62,16 +62,16 @@ public enum CardRepository {
private static final String JDBC_URL = "jdbc:h2:file:./db/cards.h2;AUTO_SERVER=TRUE";
private static final String VERSION_ENTITY_NAME = "card";
// raise this if db structure was changed
private static final long CARD_DB_VERSION = 46;
private static final long CARD_DB_VERSION = 47;
// raise this if new cards were added to the server
private static final long CARD_CONTENT_VERSION = 57;
private static final long CARD_CONTENT_VERSION = 59;
private Dao<CardInfo, Object> cardDao;
private Set<String> classNames;
private final TreeSet<String> landTypes = new TreeSet();
private CardRepository() {
CardRepository() {
File file = new File("db");
if (!file.exists()) {
file.mkdirs();

View file

@ -39,6 +39,7 @@ import mage.abilities.common.CastCommanderAbility;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.cards.Card;
import mage.cards.FrameStyle;
import mage.constants.CardType;
import mage.game.Game;
import mage.util.GameLog;
@ -150,6 +151,11 @@ public class Commander implements CommandObject {
return card.getFrameColor(game);
}
@Override
public FrameStyle getFrameStyle() {
return card.getFrameStyle();
}
@Override
public ManaCosts<ManaCost> getManaCost() {
return card.getManaCost();

View file

@ -38,6 +38,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.cards.FrameStyle;
import mage.constants.CardType;
import mage.game.Game;
import mage.util.GameLog;
@ -55,6 +56,7 @@ public class Emblem implements CommandObject {
private UUID id;
private UUID controllerId;
private UUID sourceId;
private FrameStyle frameStyle;
private Abilities<Ability> abilites = new AbilitiesImpl<>();
private String expansionSetCodeForImage = null;
@ -65,11 +67,17 @@ public class Emblem implements CommandObject {
public Emblem(final Emblem emblem) {
this.id = emblem.id;
this.name = emblem.name;
this.frameStyle = emblem.frameStyle;
this.controllerId = emblem.controllerId;
this.sourceId = emblem.sourceId;
this.abilites = emblem.abilites.copy();
}
@Override
public FrameStyle getFrameStyle() {
return frameStyle;
}
@Override
public void assignNewId() {
this.id = UUID.randomUUID();

View file

@ -120,6 +120,7 @@ public class PermanentCard extends PermanentImpl {
this.cardType.addAll(card.getCardType());
this.color = card.getColor(null).copy();
this.frameColor = card.getFrameColor(null).copy();
this.frameStyle = card.getFrameStyle();
this.manaCost = card.getManaCost().copy();
if (card instanceof PermanentCard) {
this.maxLevelCounters = ((PermanentCard) card).maxLevelCounters;

View file

@ -49,6 +49,8 @@ public class PermanentToken extends PermanentImpl {
this.token = token.copy();
this.token.getAbilities().newId(); // neccessary if token has ability like DevourAbility()
this.token.getAbilities().setSourceId(objectId);
this.power.modifyBaseValue(token.getPower().getBaseValueModified());
this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified());
this.copyFromToken(this.token, game, false); // needed to have at this time (e.g. for subtypes for entersTheBattlefield replacement effects)
}
@ -62,6 +64,9 @@ public class PermanentToken extends PermanentImpl {
public void reset(Game game) {
copyFromToken(token, game, true);
super.reset(game);
// Because the P/T objects have there own base value for reset we have to take it from there instead of from the basic token object
this.power.resetToBaseValue();
this.toughness.resetToBaseValue();
}
private void copyFromToken(Token token, Game game, boolean reset) {
@ -83,8 +88,7 @@ public class PermanentToken extends PermanentImpl {
this.cardType = token.getCardType();
this.color = token.getColor(game).copy();
this.frameColor = token.getFrameColor(game);
this.power.modifyBaseValue(token.getPower().getBaseValueModified());
this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified());
this.frameStyle = token.getFrameStyle();
this.supertype = token.getSupertype();
this.subtype = token.getSubtype(game);
this.tokenDescriptor = token.getTokenDescriptor();

View file

@ -46,6 +46,7 @@ import mage.abilities.keyword.BestowAbility;
import mage.abilities.keyword.MorphAbility;
import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.cards.FrameStyle;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -77,6 +78,7 @@ public class Spell extends StackObjImpl implements Card {
private final Card card;
private final ObjectColor color;
private final ObjectColor frameColor;
private final FrameStyle frameStyle;
private final SpellAbility ability;
private final Zone fromZone;
private final UUID id;
@ -90,6 +92,7 @@ public class Spell extends StackObjImpl implements Card {
this.card = card;
this.color = card.getColor(null).copy();
this.frameColor = card.getFrameColor(null).copy();
this.frameStyle = card.getFrameStyle();
id = ability.getId();
this.ability = ability;
this.ability.setControllerId(controllerId);
@ -131,6 +134,7 @@ public class Spell extends StackObjImpl implements Card {
this.faceDown = spell.faceDown;
this.color = spell.color.copy();
this.frameColor = spell.color.copy();
this.frameStyle = spell.frameStyle;
}
public boolean activate(Game game, boolean noMana) {
@ -492,6 +496,11 @@ public class Spell extends StackObjImpl implements Card {
return frameColor;
}
@Override
public FrameStyle getFrameStyle() {
return frameStyle;
}
@Override
public ManaCosts<ManaCost> getManaCost() {
return card.getManaCost();

View file

@ -49,6 +49,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.cards.Card;
import mage.cards.FrameStyle;
import mage.constants.AbilityType;
import mage.constants.AbilityWord;
import mage.constants.CardType;
@ -198,6 +199,12 @@ public class StackAbility extends StackObjImpl implements Ability {
return ability.getSourceObject(game).getFrameColor(game);
}
@Override
public FrameStyle getFrameStyle() {
// Abilities all use the same frame
return FrameStyle.M15_NORMAL;
}
@Override
public ManaCosts<ManaCost> getManaCost() {
return emptyCost;

View file

@ -38,7 +38,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import mage.cards.Card;
@ -53,7 +52,6 @@ import mage.util.RandomUtil;
*/
public class Library implements Serializable {
private boolean emptyDraw;
private final Deque<UUID> library = new ArrayDeque<>();
private final UUID playerId;