mirror of
https://github.com/correl/mage.git
synced 2025-01-14 03:00:10 +00:00
Made some changes and additions to abilities and effects.
This commit is contained in:
parent
0d400b1802
commit
0913a36359
4 changed files with 72 additions and 17 deletions
|
@ -27,11 +27,13 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities.common.delayed;
|
package mage.abilities.common.delayed;
|
||||||
|
|
||||||
|
import mage.Constants.TargetController;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
import mage.abilities.DelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -39,18 +41,46 @@ import mage.game.events.GameEvent.EventType;
|
||||||
*/
|
*/
|
||||||
public class AtEndOfTurnDelayedTriggeredAbility extends DelayedTriggeredAbility<AtEndOfTurnDelayedTriggeredAbility> {
|
public class AtEndOfTurnDelayedTriggeredAbility extends DelayedTriggeredAbility<AtEndOfTurnDelayedTriggeredAbility> {
|
||||||
|
|
||||||
|
private TargetController targetController;
|
||||||
|
|
||||||
public AtEndOfTurnDelayedTriggeredAbility(Effect effect) {
|
public AtEndOfTurnDelayedTriggeredAbility(Effect effect) {
|
||||||
|
this(effect, TargetController.ANY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AtEndOfTurnDelayedTriggeredAbility(Effect effect, TargetController targetController) {
|
||||||
super(effect);
|
super(effect);
|
||||||
|
this.targetController = targetController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AtEndOfTurnDelayedTriggeredAbility(AtEndOfTurnDelayedTriggeredAbility ability) {
|
public AtEndOfTurnDelayedTriggeredAbility(AtEndOfTurnDelayedTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
|
this.targetController = ability.targetController;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.END_TURN_STEP_PRE) {
|
if (event.getType() == EventType.END_TURN_STEP_PRE) {
|
||||||
return true;
|
switch (targetController) {
|
||||||
|
case ANY:
|
||||||
|
return true;
|
||||||
|
case YOU:
|
||||||
|
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||||
|
return yours;
|
||||||
|
case OPPONENT:
|
||||||
|
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONTROLLER_ATTACHED_TO:
|
||||||
|
Permanent attachment = game.getPermanent(sourceId);
|
||||||
|
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||||
|
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
|
||||||
|
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +92,22 @@ public class AtEndOfTurnDelayedTriggeredAbility extends DelayedTriggeredAbility<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return "At the beginning of the next end step, " + modes.getText();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
switch (targetController) {
|
||||||
|
case YOU:
|
||||||
|
sb.append("At the beginning of your next end step, ");
|
||||||
|
break;
|
||||||
|
case OPPONENT:
|
||||||
|
sb.append("At the beginning of an opponent's next end step, ");
|
||||||
|
break;
|
||||||
|
case ANY:
|
||||||
|
sb.append("At the beginning of the next end step, ");
|
||||||
|
break;
|
||||||
|
case CONTROLLER_ATTACHED_TO:
|
||||||
|
sb.append("At the beginning of the next end step of enchanted creature's controller, ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sb.append(getEffects().getText(modes.getMode()));
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
|
@ -36,8 +37,6 @@ import mage.cards.Card;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -53,9 +52,9 @@ public class ExileTargetEffect extends OneShotEffect<ExileTargetEffect> {
|
||||||
this.exileId = exileId;
|
this.exileId = exileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExileTargetEffect(String exileZone) {
|
public ExileTargetEffect(String effectText) {
|
||||||
this();
|
this();
|
||||||
this.exileZone = exileZone;
|
this.staticText = effectText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExileTargetEffect() {
|
public ExileTargetEffect() {
|
||||||
|
@ -76,11 +75,6 @@ public class ExileTargetEffect extends OneShotEffect<ExileTargetEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||||
|
|
||||||
// if (exileId == null) {
|
|
||||||
// exileId = getId();
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
return permanent.moveToExile(exileId, exileZone, source.getSourceId(), game);
|
return permanent.moveToExile(exileId, exileZone, source.getSourceId(), game);
|
||||||
} else {
|
} else {
|
||||||
|
@ -94,6 +88,9 @@ public class ExileTargetEffect extends OneShotEffect<ExileTargetEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Mode mode) {
|
public String getText(Mode mode) {
|
||||||
|
if (staticText != null && !staticText.isEmpty()) {
|
||||||
|
return staticText;
|
||||||
|
}
|
||||||
if (mode.getTargets().isEmpty()) {
|
if (mode.getTargets().isEmpty()) {
|
||||||
return "Exile it";
|
return "Exile it";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
||||||
|
|
||||||
private boolean revealCards = false;
|
private boolean revealCards = false;
|
||||||
private boolean forceShuffle;
|
private boolean forceShuffle;
|
||||||
|
private String rulePrefix;
|
||||||
|
|
||||||
public SearchLibraryPutInHandEffect(TargetCardInLibrary target) {
|
public SearchLibraryPutInHandEffect(TargetCardInLibrary target) {
|
||||||
this(target, false, true);
|
this(target, false, true);
|
||||||
|
@ -59,15 +60,22 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchLibraryPutInHandEffect(TargetCardInLibrary target, boolean revealCards, boolean forceShuffle) {
|
public SearchLibraryPutInHandEffect(TargetCardInLibrary target, boolean revealCards, boolean forceShuffle) {
|
||||||
|
this(target, revealCards, forceShuffle, "Search your library for ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchLibraryPutInHandEffect(TargetCardInLibrary target, boolean revealCards, boolean forceShuffle, String rulePrefix) {
|
||||||
super(target, Outcome.DrawCard);
|
super(target, Outcome.DrawCard);
|
||||||
this.revealCards = revealCards;
|
this.revealCards = revealCards;
|
||||||
this.forceShuffle = forceShuffle;
|
this.forceShuffle = forceShuffle;
|
||||||
|
this.rulePrefix = rulePrefix;
|
||||||
setText();
|
setText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchLibraryPutInHandEffect(final SearchLibraryPutInHandEffect effect) {
|
public SearchLibraryPutInHandEffect(final SearchLibraryPutInHandEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.revealCards = effect.revealCards;
|
this.revealCards = effect.revealCards;
|
||||||
|
this.forceShuffle = effect.forceShuffle;
|
||||||
|
this.rulePrefix = effect.rulePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,8 +86,9 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player == null)
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if (player.searchLibrary(target, game)) {
|
if (player.searchLibrary(target, game)) {
|
||||||
if (target.getTargets().size() > 0) {
|
if (target.getTargets().size() > 0) {
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
|
@ -104,14 +113,15 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
||||||
player.shuffleLibrary(game);
|
player.shuffleLibrary(game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (forceShuffle)
|
if (forceShuffle) {
|
||||||
player.shuffleLibrary(game);
|
player.shuffleLibrary(game);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setText() {
|
private void setText() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Search your library for ");
|
sb.append(rulePrefix);
|
||||||
if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) {
|
if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) {
|
||||||
sb.append("up to ").append(target.getMaxNumberOfTargets()).append(" ");
|
sb.append("up to ").append(target.getMaxNumberOfTargets()).append(" ");
|
||||||
sb.append(target.getTargetName()).append(revealCards ? ", reveal them, " : "").append(" and put them into your hand");
|
sb.append(target.getTargetName()).append(revealCards ? ", reveal them, " : "").append(" and put them into your hand");
|
||||||
|
@ -119,11 +129,12 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
||||||
else {
|
else {
|
||||||
sb.append("a ").append(target.getTargetName()).append(revealCards ? ", reveal it, " : "").append(" and put that card into your hand");
|
sb.append("a ").append(target.getTargetName()).append(revealCards ? ", reveal it, " : "").append(" and put that card into your hand");
|
||||||
}
|
}
|
||||||
if (forceShuffle)
|
if (forceShuffle) {
|
||||||
sb.append(". Then shuffle your library");
|
sb.append(". Then shuffle your library");
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
sb.append(". If you do, shuffle your library");
|
sb.append(". If you do, shuffle your library");
|
||||||
|
}
|
||||||
staticText = sb.toString();
|
staticText = sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ package mage.abilities.mana;
|
||||||
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
|
import mage.abilities.DelayedTriggeredAbilities;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
import mage.abilities.DelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.ManaEffect;
|
import mage.abilities.effects.common.ManaEffect;
|
||||||
|
|
Loading…
Reference in a new issue