Merge origin/master

This commit is contained in:
LevelX2 2016-05-22 16:02:44 +02:00
commit b565b832b0
4 changed files with 143 additions and 7 deletions

View file

@ -28,13 +28,13 @@
package mage.sets.planechase2012;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
@ -54,7 +54,6 @@ public class LastStand extends CardImpl {
super(ownerId, 100, "Last Stand", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{W}{U}{B}{R}{G}");
this.expansionSetCode = "PC2";
// Target opponent loses 2 life for each Swamp you control. Last Stand deals damage equal to the number of Mountains you control to target creature. Put a 1/1 green Saproling creature token onto the battlefield for each Forest you control. You gain 2 life for each Plains you control. Draw a card for each Island you control, then discard that many cards.
this.getSpellAbility().addEffect(new LastStandEffect());
this.getSpellAbility().addTarget(new TargetOpponent());
@ -108,7 +107,7 @@ class LastStandEffect extends OneShotEffect {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (opponent != null) {
int swamps = game.getBattlefield().count(filterSwamp, source.getSourceId(), source.getControllerId(), game);
opponent.damage(swamps, source.getSourceId(), game, false, true);
opponent.loseLife(swamps * 2, game);
}
// Last Stand deals damage equal to the number of Mountains you control to target creature.
Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
@ -125,7 +124,7 @@ class LastStandEffect extends OneShotEffect {
}
// You gain 2 life for each Plains you control.
int plains = game.getBattlefield().count(filterPlains, source.getSourceId(), source.getControllerId(), game);
controller.gainLife(plains, game);
controller.gainLife(plains * 2, game);
// Draw a card for each Island you control, then discard that many cards
int islands = game.getBattlefield().count(filterIsland, source.getSourceId(), source.getControllerId(), game);
if (islands > 0) {

View file

@ -45,6 +45,7 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.KickerAbility;
import mage.cards.CardImpl;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
@ -111,6 +112,9 @@ class DralnusPetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null && source.getAbilityType().equals(AbilityType.STATIC)) {
permanent = game.getPermanentEntering(source.getSourceId());
}
if (controller != null && permanent != null) {
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null

View file

@ -0,0 +1,133 @@
/*
* 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.sets.stronghold;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
* @author spjspj
*/
public class Portcullis extends CardImpl {
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature");
public Portcullis(UUID ownerId) {
super(ownerId, 133, "Portcullis", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{4}");
this.expansionSetCode = "STH";
// Whenever a creature enters the battlefield, if there are two or more other creatures on the battlefield, exile that creature.
String rule = "Whenever a creature enters the battlefield, if there are two or more other creatures on the battlefield, exile that creature";
TriggeredAbility ability = new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new PortcullisExileEffect(), filter, false, SetTargetPointer.PERMANENT, rule);
MoreThanXCreaturesOnBFCondition condition = new MoreThanXCreaturesOnBFCondition(2);
this.addAbility(new ConditionalTriggeredAbility(ability, condition, rule));
// Return that card to the battlefield under its owner's control when Portcullis leaves the battlefield.
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD), false);
this.addAbility(ability2);
}
public Portcullis(final Portcullis card) {
super(card);
}
@Override
public Portcullis copy() {
return new Portcullis(this);
}
}
class MoreThanXCreaturesOnBFCondition implements Condition {
protected final int value;
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures on field");
public MoreThanXCreaturesOnBFCondition(int value) {
this.value = value;
}
@Override
public final boolean apply(Game game, Ability source) {
PermanentsOnBattlefieldCount amount = new PermanentsOnBattlefieldCount(filter);
int count = amount.calculate(game, source, null);
return count > value;
}
}
class PortcullisExileEffect extends OneShotEffect {
public PortcullisExileEffect() {
super(Outcome.Neutral);
this.staticText = "Whenever a creature enters the battlefield, if there are two or more other creatures on the battlefield, exile that creature.";
}
public PortcullisExileEffect(final PortcullisExileEffect effect) {
super(effect);
}
@Override
public PortcullisExileEffect copy() {
return new PortcullisExileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null && creature != null) {
Player controller = game.getPlayer(creature.getControllerId());
Zone currentZone = game.getState().getZone(creature.getId());
if (currentZone.equals(Zone.BATTLEFIELD)) {
controller.moveCardsToExile(creature, source, game, true, CardUtil.getCardExileZoneId(game, source), permanent.getIdName());
}
}
return false;
}
}

View file

@ -2,7 +2,7 @@
[![Join the chat at https://gitter.im/magefree/mage](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magefree/mage?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
XMage allows you to play Magic against one or more online players or computer opponents. It includes full rules enforcement for over **13,000** unique cards (26,000 counting all cards from different editions). Starting with Shadowmoor, all regular sets have nearly all the cards implemented ([detailed overview](http://ct-magefree.rhcloud.com/stats)).
XMage allows you to play Magic against one or more online players or computer opponents. It includes full rules enforcement for over **13,000** unique cards (over 26,000 counting all cards from different editions). Starting with Morningtide, all regular sets have nearly all the cards implemented ([detailed overview](http://ct-magefree.rhcloud.com/stats)).
There are public servers where you can play XMage against other players. You can also host your own server to play against the AI and/or your friends.