This commit is contained in:
igoudt 2017-07-26 00:29:20 +02:00
commit dfc7f4a1c3
4 changed files with 571 additions and 301 deletions

View file

@ -0,0 +1,153 @@
/*
* 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.cards.o;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.filter.FilterPlayer;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
/**
*
* @author jeffwadsworth
*/
public class OathOfScholars extends CardImpl {
private final UUID originalId;
private static final FilterPlayer filter = new FilterPlayer();
static {
filter.add(new OathOfScholarsPredicate());
}
public OathOfScholars(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
// At the beginning of each player's upkeep, that player chooses target player who has more cards in hand than he or she does and is his or her opponent. The first player may discard his or her hand and draw three cards.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new OathOfScholarsEffect(), TargetController.ANY, false);
ability.addTarget(new TargetPlayer(1, 1, false, filter));
this.addAbility(ability);
originalId = ability.getOriginalId();
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) {
ability.setControllerId(activePlayer.getId());
ability.getTargets().clear();
TargetPlayer target = new TargetPlayer(1, 1, false, filter);
ability.getTargets().add(target);
}
}
}
public OathOfScholars(final OathOfScholars card) {
super(card);
this.originalId = card.originalId;
}
@Override
public OathOfScholars copy() {
return new OathOfScholars(this);
}
}
class OathOfScholarsPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Player>> {
@Override
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
Player targetPlayer = input.getObject();
Player firstPlayer = game.getPlayer(game.getActivePlayerId());
if (targetPlayer == null
|| firstPlayer == null
|| targetPlayer.getId().equals(firstPlayer.getId())
|| !game.getOpponents(targetPlayer.getId()).contains(firstPlayer.getId())) {
return false;
}
int countHandTargetPlayer = targetPlayer.getHand().size();
int countHandFirstPlayer = firstPlayer.getHand().size();
return countHandTargetPlayer > countHandFirstPlayer;
}
@Override
public String toString() {
return "player who has more cards in hand than he or she does";
}
}
class OathOfScholarsEffect extends OneShotEffect {
public OathOfScholarsEffect() {
super(Outcome.PutCardInPlay);
staticText = "that player chooses target player who has more cards in hand than he or she does and is his or her opponent. The first player may discard his or her hand and draw three cards";
}
public OathOfScholarsEffect(OathOfScholarsEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = game.getObject(source.getSourceId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player firstPlayer = game.getPlayer(game.getActivePlayerId());
if (sourceObject == null
|| targetPlayer == null
|| firstPlayer == null) {
return false;
}
if (firstPlayer.getHand().size() < targetPlayer.getHand().size() // the condition must be checked again on resolution
&& firstPlayer.chooseUse(Outcome.AIDontUseIt, "Do you wish to discard your hand and draw 3 cards?", source, game)) {
firstPlayer.discard(firstPlayer.getHand().size(), true, source, game);
firstPlayer.drawCards(3, game);
return true;
}
return false;
}
@Override
public OathOfScholarsEffect copy() {
return new OathOfScholarsEffect(this);
}
}

View file

@ -0,0 +1,115 @@
/*
* 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.cards.r;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.players.Player;
/**
*
* @author jeffwadsworth
*/
public class Reparations extends CardImpl {
public Reparations(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{U}");
// Whenever an opponent casts a spell that targets you or a creature you control, you may draw a card.
this.addAbility(new ReparationsTriggeredAbility());
}
public Reparations(final Reparations card) {
super(card);
}
@Override
public Reparations copy() {
return new Reparations(this);
}
}
class ReparationsTriggeredAbility extends TriggeredAbilityImpl {
public ReparationsTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), true);
}
public ReparationsTriggeredAbility(final ReparationsTriggeredAbility ability) {
super(ability);
}
@Override
public ReparationsTriggeredAbility copy() {
return new ReparationsTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.SPELL_CAST;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
UUID stackObjectId = event.getTargetId(); // spell cast
UUID casterId = event.getPlayerId(); // spell caster
StackObject stackObject = game.getStack().getStackObject(stackObjectId);
if (stackObject != null
&& game.getOpponents(controllerId).contains(casterId)) {
Player targetPlayer = game.getPlayer(stackObject.getStackAbility().getFirstTarget());
Permanent targetPermanent = game.getPermanent(stackObject.getStackAbility().getFirstTarget());
if (targetPlayer != null
&& targetPlayer.getId() == controllerId) {
return true;
}
if (targetPermanent != null
&& targetPermanent.isCreature()
&& targetPermanent.getControllerId() == controllerId) {
return true;
}
}
return false;
}
@Override
public String getRule() {
return "Whenever an opponent casts a spell that targets you or a creature you control, you may draw a card.";
}
}

View file

@ -108,6 +108,7 @@ public class Exodus extends ExpansionSet {
cards.add(new SetCardInfo("Null Brooch", 136, Rarity.RARE, mage.cards.n.NullBrooch.class));
cards.add(new SetCardInfo("Oath of Druids", 115, Rarity.RARE, mage.cards.o.OathOfDruids.class));
cards.add(new SetCardInfo("Oath of Lieges", 11, Rarity.RARE, mage.cards.o.OathOfLieges.class));
cards.add(new SetCardInfo("Oath of Scholars", 42, Rarity.RARE, mage.cards.o.OathOfScholars.class));
cards.add(new SetCardInfo("Ogre Shaman", 91, Rarity.RARE, mage.cards.o.OgreShaman.class));
cards.add(new SetCardInfo("Onslaught", 92, Rarity.COMMON, mage.cards.o.Onslaught.class));
cards.add(new SetCardInfo("Paladin en-Vec", 12, Rarity.RARE, mage.cards.p.PaladinEnVec.class));

View file

@ -226,6 +226,7 @@ public class Mirage extends ExpansionSet {
cards.add(new SetCardInfo("Reality Ripple", 87, Rarity.COMMON, mage.cards.r.RealityRipple.class));
cards.add(new SetCardInfo("Reckless Embermage", 189, Rarity.RARE, mage.cards.r.RecklessEmbermage.class));
cards.add(new SetCardInfo("Regeneration", 134, Rarity.COMMON, mage.cards.r.Regeneration.class));
cards.add(new SetCardInfo("Reparations", 338, Rarity.RARE, mage.cards.r.Reparations.class));
cards.add(new SetCardInfo("Restless Dead", 36, Rarity.COMMON, mage.cards.r.RestlessDead.class));
cards.add(new SetCardInfo("Ritual of Steel", 240, Rarity.COMMON, mage.cards.r.RitualOfSteel.class));
cards.add(new SetCardInfo("Rock Basilisk", 339, Rarity.RARE, mage.cards.r.RockBasilisk.class));