Merge origin/master

This commit is contained in:
LevelX2 2015-10-06 16:08:40 +02:00
commit 2c54cacbc3
5 changed files with 164 additions and 63 deletions

View file

@ -27,6 +27,9 @@
*/ */
package mage.sets.magic2015; package mage.sets.magic2015;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -48,10 +51,6 @@ import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* @author noxx * @author noxx
*/ */
@ -145,7 +144,7 @@ class SoulOfShandalarTarget extends TargetPermanent {
@Override @Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Set<UUID> possibleTargets = new HashSet<UUID>(); Set<UUID> possibleTargets = new HashSet<>();
MageObject object = game.getObject(sourceId); MageObject object = game.getObject(sourceId);
for (StackObject item : game.getState().getStack()) { for (StackObject item : game.getState().getStack()) {

View file

@ -27,7 +27,12 @@
*/ */
package mage.sets.onslaught; package mage.sets.onslaught;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -39,10 +44,8 @@ import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
@ -68,14 +71,7 @@ public class BlatantThievery extends CardImpl {
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) { if (ability instanceof SpellAbility) {
ability.getTargets().clear(); ability.getTargets().clear();
for (UUID opponentId : game.getOpponents(ability.getControllerId())) { ability.addTarget(new BlatantThieveryTarget(game.getOpponents(ability.getControllerId()).size()));
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterPermanent filter = new FilterPermanent("permanent controlled by " + opponent.getName());
filter.add(new ControllerIdPredicate(opponentId));
ability.addTarget(new TargetPermanent(filter));
}
}
} }
} }
@ -103,11 +99,117 @@ class BlatantThieveryEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
for (Target target : source.getTargets()) { for (UUID targetId : getTargetPointer().getTargets(game, source)) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame); ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame);
effect.setTargetPointer(new FixedTarget(target.getFirstTarget())); effect.setTargetPointer(new FixedTarget(targetId));
game.addEffect(effect, source); game.addEffect(effect, source);
} }
return true; return true;
} }
} }
class BlatantThieveryTarget extends TargetPermanent {
Map<UUID, UUID> targetOpponent = new HashMap<>();
public BlatantThieveryTarget(int opponents) {
super(opponents, opponents, new FilterPermanent("a permanent for each opponent"), false);
}
public BlatantThieveryTarget(final BlatantThieveryTarget target) {
super(target);
this.targetOpponent.putAll(target.targetOpponent);
}
@Override
public boolean canTarget(UUID controllerId, UUID objectId, Ability source, Game game) {
Permanent targetObject = game.getPermanent(objectId);
if (targetObject == null || !game.getOpponents(source.getControllerId()).contains(targetObject.getControllerId())) {
return false;
}
// If a permanent changes controller after being targeted but before this spell resolves, you won't gain control of that permanent.
if (targetOpponent.containsKey(objectId)) {
if (!targetOpponent.get(objectId).equals(targetObject.getControllerId())) {
return false;
}
} else {
// if already a target from this opponent exists, another can't be target
if (targetOpponent.values().contains(targetObject.getControllerId())) {
return false;
}
}
return super.canTarget(controllerId, objectId, source, game);
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> opponents = new HashSet<>();
for (UUID targetId : getTargets()) {
Permanent oldTargets = game.getPermanent(targetId);
if (oldTargets != null) {
opponents.add(oldTargets.getControllerId());
}
}
Set<UUID> possibleTargets = new HashSet<>();
MageObject mageObject = game.getObject(sourceId);
if (mageObject == null) {
return possibleTargets;
}
for (UUID opponentId : game.getOpponents(sourceControllerId)) {
if (opponents.contains(opponentId)) {
// Target for this opponent already selected
continue;
}
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponentId)) {
if (permanent.canBeTargetedBy(mageObject, sourceControllerId, game)) {
possibleTargets.add(permanent.getId());
}
}
}
return possibleTargets;
}
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
for (UUID opponentId : game.getOpponents(sourceControllerId)) {
boolean targetAvailable = false;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponentId)) {
if (!targets.containsKey(permanent.getId())) {
MageObject mageObject = game.getObject(sourceId);
if (mageObject != null && permanent.canBeTargetedBy(mageObject, sourceControllerId, game)) {
targetAvailable = true;
break;
}
} else {
targetAvailable = true;
break;
}
}
if (!targetAvailable) {
return false;
}
}
return true;
}
@Override
public void addTarget(UUID objectId, int amount, Ability source, Game game, boolean skipEvent) {
Permanent targetObject = game.getPermanent(objectId);
if (targetObject != null) {
targetOpponent.put(objectId, targetObject.getControllerId());
}
super.addTarget(objectId, amount, source, game, skipEvent);
}
@Override
public void remove(UUID id) {
super.remove(id);
targetOpponent.remove(id);
}
@Override
public BlatantThieveryTarget copy() {
return new BlatantThieveryTarget(this);
}
}

View file

@ -28,11 +28,6 @@
package mage.sets.planechase2012; package mage.sets.planechase2012;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -41,6 +36,10 @@ import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.keyword.HasteAbility; import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game; import mage.game.Game;
@ -60,20 +59,20 @@ public class MassMutiny extends CardImpl {
super(ownerId, 48, "Mass Mutiny", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{R}{R}"); super(ownerId, 48, "Mass Mutiny", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{R}{R}");
this.expansionSetCode = "PC2"; this.expansionSetCode = "PC2";
this.getSpellAbility().addEffect(new MassMutinyEffect());
// For each opponent, gain control of up to one target creature that player controls until end of turn. Untap those creatures. They gain haste until end of turn. // For each opponent, gain control of up to one target creature that player controls until end of turn. Untap those creatures. They gain haste until end of turn.
this.getSpellAbility().addEffect(new MassMutinyEffect());
} }
@Override @Override
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) { if (ability instanceof SpellAbility) {
for(UUID opponentId : game.getOpponents(ability.getControllerId())) { for (UUID opponentId : game.getOpponents(ability.getControllerId())) {
Player opponent = game.getPlayer(opponentId); Player opponent = game.getPlayer(opponentId);
if (opponent != null) { if (opponent != null) {
ability.getTargets().clear(); ability.getTargets().clear();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature from opponent " + opponent.getLogName()); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature from opponent " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponentId)); filter.add(new ControllerIdPredicate(opponentId));
TargetCreaturePermanent target = new TargetCreaturePermanent(0,1, filter,false); TargetCreaturePermanent target = new TargetCreaturePermanent(0, 1, filter, false);
ability.addTarget(target); ability.addTarget(target);
} }
} }
@ -90,7 +89,6 @@ public class MassMutiny extends CardImpl {
} }
} }
class MassMutinyEffect extends OneShotEffect { class MassMutinyEffect extends OneShotEffect {
public MassMutinyEffect() { public MassMutinyEffect() {
@ -110,7 +108,7 @@ class MassMutinyEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
boolean result = false; boolean result = false;
for (Target target: source.getTargets()) { for (Target target : source.getTargets()) {
if (target instanceof TargetCreaturePermanent) { if (target instanceof TargetCreaturePermanent) {
Permanent targetCreature = game.getPermanent(target.getFirstTarget()); Permanent targetCreature = game.getPermanent(target.getFirstTarget());
if (targetCreature != null) { if (targetCreature != null) {

View file

@ -6,18 +6,19 @@ import mage.abilities.Ability;
import mage.game.Game; import mage.game.Game;
public class BasicManaEffect extends ManaEffect { public class BasicManaEffect extends ManaEffect {
protected Mana mana; protected Mana mana;
public BasicManaEffect(Mana mana) { public BasicManaEffect(Mana mana) {
super(); super();
this.mana = mana; this.mana = mana;
staticText = "Add " + mana.toString() + " to your mana pool"; staticText = "add " + mana.toString() + " to your mana pool";
} }
public BasicManaEffect(ConditionalMana conditionalMana) { public BasicManaEffect(ConditionalMana conditionalMana) {
super(); super();
this.mana = conditionalMana; this.mana = conditionalMana;
staticText = "Add " + mana.toString() + " to your mana pool. " + conditionalMana.getDescription(); staticText = "add " + mana.toString() + " to your mana pool. " + conditionalMana.getDescription();
} }
public BasicManaEffect(final BasicManaEffect effect) { public BasicManaEffect(final BasicManaEffect effect) {

View file

@ -1,31 +1,30 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * 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 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * 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 * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.filter; package mage.filter;
import java.util.ArrayList; import java.util.ArrayList;
@ -44,6 +43,7 @@ import mage.game.permanent.Permanent;
* @author North * @author North
*/ */
public class FilterPermanent extends FilterObject<Permanent> implements FilterInPlay<Permanent> { public class FilterPermanent extends FilterObject<Permanent> implements FilterInPlay<Permanent> {
protected List<ObjectPlayerPredicate<ObjectPlayer<Permanent>>> extraPredicates = new ArrayList<>(); protected List<ObjectPlayerPredicate<ObjectPlayer<Permanent>>> extraPredicates = new ArrayList<>();
public FilterPermanent() { public FilterPermanent() {
@ -64,6 +64,7 @@ public class FilterPermanent extends FilterObject<Permanent> implements FilterIn
this.add(new SubtypePredicate(subtype)); this.add(new SubtypePredicate(subtype));
} }
@Override
public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) {
if (!this.match(permanent, game)) { if (!this.match(permanent, game)) {
return false; return false;