mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +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;
|
||||
|
||||
import mage.Constants.TargetController;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
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> {
|
||||
|
||||
private TargetController targetController;
|
||||
|
||||
public AtEndOfTurnDelayedTriggeredAbility(Effect effect) {
|
||||
this(effect, TargetController.ANY);
|
||||
}
|
||||
|
||||
public AtEndOfTurnDelayedTriggeredAbility(Effect effect, TargetController targetController) {
|
||||
super(effect);
|
||||
this.targetController = targetController;
|
||||
}
|
||||
|
||||
public AtEndOfTurnDelayedTriggeredAbility(AtEndOfTurnDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.targetController = ability.targetController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.END_TURN_STEP_PRE) {
|
||||
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;
|
||||
}
|
||||
|
@ -62,6 +92,22 @@ public class AtEndOfTurnDelayedTriggeredAbility extends DelayedTriggeredAbility<
|
|||
|
||||
@Override
|
||||
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;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
|
@ -36,8 +37,6 @@ import mage.cards.Card;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -53,9 +52,9 @@ public class ExileTargetEffect extends OneShotEffect<ExileTargetEffect> {
|
|||
this.exileId = exileId;
|
||||
}
|
||||
|
||||
public ExileTargetEffect(String exileZone) {
|
||||
public ExileTargetEffect(String effectText) {
|
||||
this();
|
||||
this.exileZone = exileZone;
|
||||
this.staticText = effectText;
|
||||
}
|
||||
|
||||
public ExileTargetEffect() {
|
||||
|
@ -76,11 +75,6 @@ public class ExileTargetEffect extends OneShotEffect<ExileTargetEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
|
||||
// if (exileId == null) {
|
||||
// exileId = getId();
|
||||
// }
|
||||
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(exileId, exileZone, source.getSourceId(), game);
|
||||
} else {
|
||||
|
@ -94,6 +88,9 @@ public class ExileTargetEffect extends OneShotEffect<ExileTargetEffect> {
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
if (mode.getTargets().isEmpty()) {
|
||||
return "Exile it";
|
||||
} else {
|
||||
|
|
|
@ -49,6 +49,7 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
|||
|
||||
private boolean revealCards = false;
|
||||
private boolean forceShuffle;
|
||||
private String rulePrefix;
|
||||
|
||||
public SearchLibraryPutInHandEffect(TargetCardInLibrary target) {
|
||||
this(target, false, true);
|
||||
|
@ -59,15 +60,22 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
|||
}
|
||||
|
||||
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);
|
||||
this.revealCards = revealCards;
|
||||
this.forceShuffle = forceShuffle;
|
||||
this.rulePrefix = rulePrefix;
|
||||
setText();
|
||||
}
|
||||
|
||||
public SearchLibraryPutInHandEffect(final SearchLibraryPutInHandEffect effect) {
|
||||
super(effect);
|
||||
this.revealCards = effect.revealCards;
|
||||
this.forceShuffle = effect.forceShuffle;
|
||||
this.rulePrefix = effect.rulePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,8 +86,9 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards cards = new CardsImpl();
|
||||
|
@ -104,14 +113,15 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
|||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
if (forceShuffle)
|
||||
if (forceShuffle) {
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Search your library for ");
|
||||
sb.append(rulePrefix);
|
||||
if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) {
|
||||
sb.append("up to ").append(target.getMaxNumberOfTargets()).append(" ");
|
||||
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 {
|
||||
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");
|
||||
else
|
||||
}
|
||||
else {
|
||||
sb.append(". If you do, shuffle your library");
|
||||
|
||||
}
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.abilities.mana;
|
|||
|
||||
import mage.Constants;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.DelayedTriggeredAbilities;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
|
|
Loading…
Reference in a new issue