[DTK] Added 5 multicolor cards.

This commit is contained in:
LevelX2 2015-03-18 15:59:16 +01:00
parent 8e169649f3
commit 32eba22309
14 changed files with 837 additions and 42 deletions

View file

@ -68,7 +68,7 @@ public abstract class ContinuousRuleModifyingEffectImpl extends ContinuousEffect
* @param duration
* @param outcome
* @param messageToUser - Every time the effect replaces an event, the user gets a message in a dialog window.
* Don't set it to true if the event heppens regularly or very often. The message can be
* Don't set it to true if the event happens regularly or very often. The message itself can be
* changed by overriding the getInfoMessage method.
* @param messageToLog - Every time the effect replaces an event, a message is posted to the game log. The message
* can be changed by overriding the getInfoMessage method.

View file

@ -34,6 +34,7 @@ import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.TargetController;
import mage.game.Game;
import mage.players.Player;
@ -42,22 +43,27 @@ import mage.players.Player;
* @author LevelX2
*/
public class CantGainLifeAllEffect extends ContinuousEffectImpl {
private TargetController targetController;
public CantGainLifeAllEffect() {
this(Duration.WhileOnBattlefield);
}
public CantGainLifeAllEffect(Duration duration) {
this(duration, TargetController.ANY);
}
public CantGainLifeAllEffect(Duration duration, TargetController targetController) {
super(duration, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit);
StringBuilder sb = new StringBuilder("Players can't gain life");
if (!this.duration.toString().isEmpty()) {
sb.append(" ").append(duration.toString());
}
staticText = sb.toString();
this.targetController = targetController;
staticText = setText();
}
public CantGainLifeAllEffect(final CantGainLifeAllEffect effect) {
super(effect);
this.targetController = effect.targetController;
}
@Override
@ -68,17 +74,69 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId: controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null)
{
player.setCanGainLife(false);
}
if (controller != null) {
switch (targetController) {
case YOU:
controller.setCanGainLife(false);
break;
case NOT_YOU:
for (UUID playerId: controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null && !player.equals(controller)) {
player.setCanGainLife(false);
}
}
break;
case OPPONENT:
for (UUID playerId: controller.getInRange()) {
if (controller.hasOpponent(playerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.setCanGainLife(false);
}
}
}
break;
case ANY:
for (UUID playerId: controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.setCanGainLife(false);
}
}
break;
}
return true;
}
return false;
}
private String setText() {
StringBuilder sb = new StringBuilder();
switch (targetController) {
case YOU:
sb.append("You");
break;
case NOT_YOU:
sb.append("Other players");
break;
case OPPONENT:
sb.append("Your opponents");
break;
case ANY:
sb.append("Players");
break;
}
sb.append(" can't gain life");
if (!this.duration.toString().isEmpty()) {
sb.append(" ");
if (duration.equals(Duration.EndOfTurn)) {
sb.append("this turn");
} else {
sb.append(duration.toString());
}
}
return sb.toString();
}
}

View file

@ -106,17 +106,7 @@ public class ReboundAbility extends TriggeredAbilityImpl {
if (event.getType() == EventType.SPELL_CAST && this.installReboundEffect) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && spell.getSourceId().equals(this.getSourceId())) {
Effect reboundEffect = new ReboundEffect();
boolean found = false;
for (Effect effect : spell.getSpellAbility().getEffects()) {
if (effect instanceof ReboundEffect) {
found = true;
break;
}
}
if (!found) {
spell.getSpellAbility().addEffect(reboundEffect);
}
addReboundEffectToSpellIfMissing(spell);
this.installReboundEffect = false;
}
}
@ -132,6 +122,20 @@ public class ReboundAbility extends TriggeredAbilityImpl {
public ReboundAbility copy() {
return new ReboundAbility(this);
}
static public void addReboundEffectToSpellIfMissing(Spell spell) {
Effect reboundEffect = new ReboundEffect();
boolean found = false;
for (Effect effect : spell.getSpellAbility().getEffects()) {
if (effect instanceof ReboundEffect) {
found = true;
break;
}
}
if (!found) {
spell.getSpellAbility().addEffect(reboundEffect);
}
}
}
/**