mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Implemented Spawnbroker
This commit is contained in:
parent
6679a680fd
commit
d2bc10d214
1 changed files with 174 additions and 0 deletions
174
Mage.Sets/src/mage/cards/s/Spawnbroker.java
Normal file
174
Mage.Sets/src/mage/cards/s/Spawnbroker.java
Normal file
|
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
* 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.s;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.MageObject;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.constants.TargetController;
|
||||||
|
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||||
|
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jeffwadsworth & L_J
|
||||||
|
*/
|
||||||
|
public class Spawnbroker extends CardImpl {
|
||||||
|
|
||||||
|
private static final String rule = "you may exchange control of target creature you control and target creature with power less than or equal to that creature's power an opponent controls";
|
||||||
|
|
||||||
|
public Spawnbroker(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}");
|
||||||
|
this.subtype.add(SubType.HUMAN);
|
||||||
|
this.subtype.add(SubType.WIZARD);
|
||||||
|
this.power = new MageInt(1);
|
||||||
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
|
// When Spawnbroker enters the battlefield, you may exchange control of target creature you control and target creature with power less than or equal to that creature's power an opponent controls.
|
||||||
|
Ability ability = new EntersBattlefieldTriggeredAbility(new ExchangeControlTargetEffect(Duration.Custom, rule, false, true), true);
|
||||||
|
ability.addTarget(new TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent());
|
||||||
|
ability.addTarget(new SpawnbrokerSecondTarget());
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Spawnbroker(final Spawnbroker card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Spawnbroker copy() {
|
||||||
|
return new Spawnbroker(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent extends TargetControlledPermanent {
|
||||||
|
|
||||||
|
public TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent() {
|
||||||
|
super();
|
||||||
|
filter.add(new CardTypePredicate(CardType.CREATURE));
|
||||||
|
setTargetName("creature you control");
|
||||||
|
}
|
||||||
|
|
||||||
|
public TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent(final TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent target) {
|
||||||
|
super(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||||
|
return super.canTarget(controllerId, id, source, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
|
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)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent copy() {
|
||||||
|
return new TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SpawnbrokerSecondTarget extends TargetPermanent {
|
||||||
|
|
||||||
|
private Permanent firstTarget = null;
|
||||||
|
|
||||||
|
public SpawnbrokerSecondTarget() {
|
||||||
|
super();
|
||||||
|
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||||
|
filter.add(new CardTypePredicate(CardType.CREATURE));
|
||||||
|
setTargetName("creature with power less than or equal to that creature's power an opponent controls");
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpawnbrokerSecondTarget(final SpawnbrokerSecondTarget target) {
|
||||||
|
super(target);
|
||||||
|
this.firstTarget = target.firstTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
|
if (super.canTarget(id, source, game)) {
|
||||||
|
Permanent target1 = game.getPermanent(source.getFirstTarget());
|
||||||
|
Permanent opponentPermanent = game.getPermanent(id);
|
||||||
|
if (target1 != null && opponentPermanent != null) {
|
||||||
|
return target1.getPower().getValue() >= opponentPermanent.getPower().getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
|
if (firstTarget != null) {
|
||||||
|
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 (firstTarget.getPower().getValue() >= permanent.getPower().getValue()) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||||
|
firstTarget = game.getPermanent(source.getFirstTarget());
|
||||||
|
return super.chooseTarget(Outcome.GainControl, playerId, source, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SpawnbrokerSecondTarget copy() {
|
||||||
|
return new SpawnbrokerSecondTarget(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue