forked from External/mage
* Some minor changes to logging and return code handling.
This commit is contained in:
parent
94be7cb4da
commit
4c33359fe2
22 changed files with 862 additions and 888 deletions
|
|
@ -68,7 +68,8 @@ public class PutTopCardOfLibraryIntoGraveTargetEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
return player.moveCards(player.getLibrary().getTopCards(game, numberCards.calculate(game, source, this)), Zone.GRAVEYARD, source, game);
|
||||
player.moveCards(player.getLibrary().getTopCards(game, numberCards.calculate(game, source, this)), Zone.GRAVEYARD, source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,14 +74,10 @@ public class ReturnSourceFromGraveyardToBattlefieldEffect extends OneShotEffect
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (game.getState().getZone(source.getSourceId()) != Zone.GRAVEYARD) {
|
||||
return false;
|
||||
}
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player;
|
||||
if (ownerControl) {
|
||||
player = game.getPlayer(card.getOwnerId());
|
||||
|
|
@ -91,7 +87,10 @@ public class ReturnSourceFromGraveyardToBattlefieldEffect extends OneShotEffect
|
|||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return player.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, true, null);
|
||||
if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
|
||||
player.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, true, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
|
|
@ -45,25 +45,25 @@ import mage.util.CardUtil;
|
|||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class SacrificeEffect extends OneShotEffect{
|
||||
public class SacrificeEffect extends OneShotEffect {
|
||||
|
||||
private FilterPermanent filter;
|
||||
private String preText;
|
||||
private DynamicValue count;
|
||||
|
||||
public SacrificeEffect (FilterPermanent filter, int count, String preText ) {
|
||||
public SacrificeEffect(FilterPermanent filter, int count, String preText) {
|
||||
this(filter, new StaticValue(count), preText);
|
||||
}
|
||||
|
||||
public SacrificeEffect (FilterPermanent filter, DynamicValue count, String preText ) {
|
||||
public SacrificeEffect(FilterPermanent filter, DynamicValue count, String preText) {
|
||||
super(Outcome.Sacrifice);
|
||||
this.filter = filter;
|
||||
this.count = count;
|
||||
this.preText = preText;
|
||||
setText();
|
||||
}
|
||||
|
||||
public SacrificeEffect (final SacrificeEffect effect ) {
|
||||
|
||||
public SacrificeEffect(final SacrificeEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.count = effect.count;
|
||||
|
|
@ -87,24 +87,20 @@ public class SacrificeEffect extends OneShotEffect{
|
|||
|
||||
Target target = new TargetPermanent(amount, amount, newFilter, true);
|
||||
|
||||
// A spell or ability could have removed the only legal target this player
|
||||
// had, if thats the case this ability should fizzle.
|
||||
if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) {
|
||||
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.canRespond()) {
|
||||
player.chooseTarget(Outcome.Sacrifice, target, source, game);
|
||||
}
|
||||
|
||||
for ( int idx = 0; idx < target.getTargets().size(); idx++) {
|
||||
for (int idx = 0; idx < target.getTargets().size(); idx++) {
|
||||
Permanent permanent = game.getPermanent(target.getTargets().get(idx));
|
||||
|
||||
if ( permanent != null ) {
|
||||
if (permanent != null) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAmount(DynamicValue amount) {
|
||||
|
|
@ -128,7 +124,7 @@ public class SacrificeEffect extends OneShotEffect{
|
|||
sb.append("sacrifice ");
|
||||
} else {
|
||||
sb.append(" sacrifice ");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append(CardUtil.numberToText(count.toString(), "a")).append(' ');
|
||||
sb.append(filter.getMessage());
|
||||
|
|
|
|||
|
|
@ -24,13 +24,12 @@
|
|||
* 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.effects.common;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -41,22 +40,21 @@ import mage.game.permanent.Permanent;
|
|||
public class UntapSourceEffect extends OneShotEffect {
|
||||
|
||||
public UntapSourceEffect() {
|
||||
super(Outcome.Untap);
|
||||
staticText = "untap {this}";
|
||||
}
|
||||
super(Outcome.Untap);
|
||||
staticText = "untap {this}";
|
||||
}
|
||||
|
||||
public UntapSourceEffect(final UntapSourceEffect effect) {
|
||||
super(effect);
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
permanent.untap(game);
|
||||
return true;
|
||||
permanent.untap(game);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -64,4 +62,4 @@ public class UntapSourceEffect extends OneShotEffect {
|
|||
return new UntapSourceEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class AddCountersTargetEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return affectedTargets > 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,20 +76,19 @@ public class RemoveCounterTargetEffect extends OneShotEffect {
|
|||
game.informPlayers("Removed " + toRemove.getCount() + ' ' + toRemove.getName()
|
||||
+ " counter from " + p.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Card c = game.getCard(targetPointer.getFirst(game, source));
|
||||
if (c != null && counter != null && c.getCounters(game).getCount(counter.getName()) >= counter.getCount()) {
|
||||
c.removeCounters(counter.getName(), counter.getCount(), game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder("Removed ").append(counter.getCount()).append(' ').append(counter.getName())
|
||||
.append(" counter from ").append(c.getName())
|
||||
.append(" (").append(c.getCounters(game).getCount(counter.getName())).append(" left)").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Card c = game.getCard(targetPointer.getFirst(game, source));
|
||||
if (c != null && counter != null && c.getCounters(game).getCount(counter.getName()) >= counter.getCount()) {
|
||||
c.removeCounters(counter.getName(), counter.getCount(), game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder("Removed ").append(counter.getCount()).append(' ').append(counter.getName())
|
||||
.append(" counter from ").append(c.getName())
|
||||
.append(" (").append(c.getCounters(game).getCount(counter.getName())).append(" left)").toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private Counter selectCounterType(Game game, Ability source, Permanent permanent) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue