Merge pull request #2880 from ingmargoudt/master

put the writing of equipped and enchanted in the attachmenttype
This commit is contained in:
ingmargoudt 2017-02-19 23:59:25 +01:00 committed by GitHub
commit 48a1fe8602
25 changed files with 46 additions and 120 deletions

View file

@ -88,11 +88,7 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public String getRule() { public String getRule() {
StringBuilder sb = new StringBuilder("Whenever "); StringBuilder sb = new StringBuilder("Whenever ");
if (attachmentType.equals(AttachmentType.EQUIPMENT)) { sb.append(attachmentType.verb().toLowerCase());
sb.append("equipped");
} else {
sb.append("enchanted");
}
return sb.append(" creature attacks, ").append(super.getRule()).toString(); return sb.append(" creature attacks, ").append(super.getRule()).toString();
} }
} }

View file

@ -109,16 +109,12 @@ public class CantBeTargetedAttachedEffect extends ContinuousRuleModifyingEffectI
return staticText; return staticText;
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType.equals(AttachmentType.AURA)) { sb.append(attachmentType.verb() + " creature");
sb.append("Enchanted creature");
} else {
sb.append("Equipped creature");
}
sb.append(" can't be the target of "); sb.append(" can't be the target of ");
sb.append(filterSource.getMessage()); sb.append(filterSource.getMessage());
if (!duration.toString().isEmpty()) { if (!duration.toString().isEmpty()) {
sb.append(' '); sb.append(' ');
if (duration.equals(Duration.EndOfTurn)) { if (duration == Duration.EndOfTurn) {
sb.append("this turn"); sb.append("this turn");
} else { } else {
sb.append(duration.toString()); sb.append(duration.toString());

View file

@ -40,7 +40,6 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
*
* @author jeff * @author jeff
*/ */
public class RegenerateAttachedEffect extends ReplacementEffectImpl { public class RegenerateAttachedEffect extends ReplacementEffectImpl {
@ -102,13 +101,8 @@ public class RegenerateAttachedEffect extends ReplacementEffectImpl {
} }
return false; return false;
} }
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); staticText = "Regenerate " + attachmentType.verb().toLowerCase() + " creature";
if (attachmentType == AttachmentType.AURA) {
sb.append("Regenerate enchanted creature");
} else if (attachmentType == AttachmentType.EQUIPMENT) {
sb.append("Regenerate equipped creature");
}
staticText = sb.toString();
} }
} }

View file

@ -44,11 +44,7 @@ public class AttacksIfAbleAttachedEffect extends RequirementEffect {
public AttacksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) { public AttacksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) {
super(duration); super(duration);
if (attachmentType == AttachmentType.AURA) { this.staticText = attachmentType.verb() + " creature attacks each turn if able";
this.staticText = "Enchanted creature attacks each turn if able";
} else {
this.staticText = "Equipped creature attacks each turn if able";
}
} }
public AttacksIfAbleAttachedEffect(final AttacksIfAbleAttachedEffect effect) { public AttacksIfAbleAttachedEffect(final AttacksIfAbleAttachedEffect effect) {

View file

@ -36,7 +36,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
@ -44,11 +43,7 @@ public class BlocksIfAbleAttachedEffect extends RequirementEffect {
public BlocksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) { public BlocksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) {
super(duration); super(duration);
if (attachmentType == AttachmentType.AURA) { this.staticText = attachmentType.verb() + " creature blocks each turn if able";
this.staticText = "Enchanted creature blocks each turn if able";
} else {
this.staticText = "Equipped creature blocks each turn if able";
}
} }
public BlocksIfAbleAttachedEffect(final BlocksIfAbleAttachedEffect effect) { public BlocksIfAbleAttachedEffect(final BlocksIfAbleAttachedEffect effect) {

View file

@ -37,7 +37,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
@ -45,11 +44,7 @@ public class CanBlockOnlyFlyingAttachedEffect extends RestrictionEffect {
public CanBlockOnlyFlyingAttachedEffect(AttachmentType attachmentType) { public CanBlockOnlyFlyingAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield); super(Duration.WhileOnBattlefield);
if (attachmentType == AttachmentType.AURA) { this.staticText = attachmentType.verb() + " creature can block only creatures with flying";
this.staticText = "Enchanted creature can block only creatures with flying";
} else {
this.staticText = "Equipped creature can block only creatures with flying";
}
} }
public CanBlockOnlyFlyingAttachedEffect(final CanBlockOnlyFlyingAttachedEffect effect) { public CanBlockOnlyFlyingAttachedEffect(final CanBlockOnlyFlyingAttachedEffect effect) {

View file

@ -20,11 +20,7 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect {
public CantAttackAloneAttachedEffect(AttachmentType attachmentType) { public CantAttackAloneAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield); super(Duration.WhileOnBattlefield);
if (attachmentType == AttachmentType.AURA) { this.staticText = attachmentType.verb() + " creature can't attack alone";
this.staticText = "Enchanted creature can't attack alone";
} else {
this.staticText = "Equipped creature can't attack alone";
}
} }
public CantAttackAloneAttachedEffect(final CantAttackAloneAttachedEffect effect) { public CantAttackAloneAttachedEffect(final CantAttackAloneAttachedEffect effect) {

View file

@ -44,11 +44,7 @@ public class CantAttackAttachedEffect extends RestrictionEffect {
public CantAttackAttachedEffect(AttachmentType attachmentType) { public CantAttackAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield); super(Duration.WhileOnBattlefield);
if (attachmentType == AttachmentType.AURA) { this.staticText = attachmentType.verb() + " creature can't attack";
this.staticText = "Enchanted creature can't attack";
} else {
this.staticText = "Equipped creature can't attack";
}
} }
public CantAttackAttachedEffect(final CantAttackAttachedEffect effect) { public CantAttackAttachedEffect(final CantAttackAttachedEffect effect) {

View file

@ -35,18 +35,13 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public class CantAttackBlockAttachedEffect extends RestrictionEffect { public class CantAttackBlockAttachedEffect extends RestrictionEffect {
public CantAttackBlockAttachedEffect(AttachmentType attachmentType) { public CantAttackBlockAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield); super(Duration.WhileOnBattlefield);
if (attachmentType == AttachmentType.AURA) { this.staticText = attachmentType.verb() + " creature can't attack or block";
this.staticText = "Enchanted creature can't attack or block";
} else {
this.staticText = "Equipped creature can't attack or block";
}
} }
public CantAttackBlockAttachedEffect(final CantAttackBlockAttachedEffect effect) { public CantAttackBlockAttachedEffect(final CantAttackBlockAttachedEffect effect) {

View file

@ -46,7 +46,7 @@ public class CantAttackBlockUnlessPaysAttachedEffect extends PayCostToAttackBloc
public CantAttackBlockUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) { public CantAttackBlockUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK_AND_BLOCK, manaCosts); super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK_AND_BLOCK, manaCosts);
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted " : "Equipped ") staticText = attachmentType.verb()
+ " creature can't attack or block unless its controller pays " + " creature can't attack or block unless its controller pays "
+ (manaCosts == null ? "" : manaCosts.getText()); + (manaCosts == null ? "" : manaCosts.getText());
} }

View file

@ -46,11 +46,7 @@ public class CantAttackControllerAttachedEffect extends RestrictionEffect {
public CantAttackControllerAttachedEffect(AttachmentType attachmentType) { public CantAttackControllerAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield); super(Duration.WhileOnBattlefield);
if (attachmentType == AttachmentType.AURA) { this.staticText = attachmentType.verb() + " creature can't attack you or a planeswalker you control";
this.staticText = "Enchanted creature can't attack you or a planeswalker you control";
} else {
this.staticText = "Equipped creature can't attack you or a planeswalker you control";
}
} }
public CantAttackControllerAttachedEffect(final CantAttackControllerAttachedEffect effect) { public CantAttackControllerAttachedEffect(final CantAttackControllerAttachedEffect effect) {

View file

@ -46,7 +46,7 @@ public class CantAttackUnlessPaysAttachedEffect extends PayCostToAttackBlockEffe
public CantAttackUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) { public CantAttackUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK, manaCosts); super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK, manaCosts);
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted " : "Equipped ") staticText = attachmentType.verb()
+ " creature can't attack unless its controller pays " + " creature can't attack unless its controller pays "
+ (manaCosts == null ? "" : manaCosts.getText()); + (manaCosts == null ? "" : manaCosts.getText());
} }

View file

@ -42,11 +42,7 @@ public class CantBeBlockedAttachedEffect extends RestrictionEffect {
public CantBeBlockedAttachedEffect(AttachmentType attachmentType) { public CantBeBlockedAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield); super(Duration.WhileOnBattlefield);
if (attachmentType == AttachmentType.AURA) { this.staticText = attachmentType.verb() + " creature can't be blocked";
this.staticText = "Enchanted creature can't be blocked";
} else {
this.staticText = "Equipped creature can't be blocked";
}
} }
public CantBeBlockedAttachedEffect(CantBeBlockedAttachedEffect effect) { public CantBeBlockedAttachedEffect(CantBeBlockedAttachedEffect effect) {

View file

@ -36,7 +36,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect { public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect {
@ -47,11 +46,7 @@ public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect {
super(duration); super(duration);
this.filter = filter; this.filter = filter;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA) { sb.append(attachmentType.verb());
sb.append("Enchanted ");
} else {
sb.append("Equipped ");
}
staticText = sb.append(" creature can't be blocked ") staticText = sb.append(" creature can't be blocked ")
.append(filter.getMessage().startsWith("except by") ? "" : "by ").append(filter.getMessage()).toString(); .append(filter.getMessage().startsWith("except by") ? "" : "by ").append(filter.getMessage()).toString();
} }

View file

@ -54,7 +54,7 @@ public class CantBeBlockedByOneAttachedEffect extends ContinuousEffectImpl {
super(duration, Outcome.Benefit); super(duration, Outcome.Benefit);
this.amount = amount; this.amount = amount;
this.attachmentType = attachmentType; this.attachmentType = attachmentType;
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted" : "Equipped") + " creature can't be blocked except by " + amount + " or more creatures"; staticText = attachmentType.verb() + " creature can't be blocked except by " + amount + " or more creatures";
} }
public CantBeBlockedByOneAttachedEffect(final CantBeBlockedByOneAttachedEffect effect) { public CantBeBlockedByOneAttachedEffect(final CantBeBlockedByOneAttachedEffect effect) {

View file

@ -56,11 +56,8 @@ public class CantBlockAttachedEffect extends RestrictionEffect {
super(duration); super(duration);
this.filter = filter; this.filter = filter;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA) { sb.append(attachmentType.verb());
sb.append("Enchanted creature can't block"); sb.append(" creature can't block");
} else {
sb.append("Equipped creature can't block");
}
if (!filter.getMessage().equals("creature")) { if (!filter.getMessage().equals("creature")) {
sb.append(' ').append(filter.getMessage()); sb.append(' ').append(filter.getMessage());
} }

View file

@ -29,6 +29,7 @@
package mage.abilities.effects.common.combat; package mage.abilities.effects.common.combat;
import java.util.UUID; import java.util.UUID;
import mage.constants.AttachmentType; import mage.constants.AttachmentType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -37,7 +38,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public class MustBeBlockedByAllAttachedEffect extends RequirementEffect { public class MustBeBlockedByAllAttachedEffect extends RequirementEffect {
@ -51,7 +51,7 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect {
public MustBeBlockedByAllAttachedEffect(Duration duration, AttachmentType attachmentType) { public MustBeBlockedByAllAttachedEffect(Duration duration, AttachmentType attachmentType) {
super(duration); super(duration);
this.attachmentType = attachmentType; this.attachmentType = attachmentType;
staticText = "All creatures able to block " + (attachmentType.equals(AttachmentType.AURA) ? "enchanted":"equipped") + " creature do so"; staticText = "All creatures able to block " + attachmentType.verb().toLowerCase() + " creature do so";
} }
public MustBeBlockedByAllAttachedEffect(final MustBeBlockedByAllAttachedEffect effect) { public MustBeBlockedByAllAttachedEffect(final MustBeBlockedByAllAttachedEffect effect) {

View file

@ -84,11 +84,7 @@ public class AddCardColorAttachedEffect extends ContinuousEffectImpl {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA) sb.append(attachmentType.verb());
sb.append("Enchanted");
else if (attachmentType == AttachmentType.EQUIPMENT)
sb.append("Equipped");
sb.append(" creature is a ").append(addedColor.getDescription()).append(" in addition to its colors"); sb.append(" creature is a ").append(addedColor.getDescription()).append(" in addition to its colors");
staticText = sb.toString(); staticText = sb.toString();
} }

View file

@ -72,11 +72,8 @@ public class AddCardSubtypeAttachedEffect extends ContinuousEffectImpl {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA)
sb.append("Enchanted");
else if (attachmentType == AttachmentType.EQUIPMENT)
sb.append("Equipped");
sb.append(attachmentType.verb());
sb.append(" creature becomes ").append(addedSubtype).append(" in addition to its other types"); //TODO add attacked card type detection sb.append(" creature becomes ").append(addedSubtype).append(" in addition to its other types"); //TODO add attacked card type detection
staticText = sb.toString(); staticText = sb.toString();
} }

View file

@ -72,11 +72,7 @@ public class AddCardTypeAttachedEffect extends ContinuousEffectImpl {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA) sb.append(attachmentType.verb());
sb.append("Enchanted");
else if (attachmentType == AttachmentType.EQUIPMENT)
sb.append("Equipped");
sb.append(" creature becomes ").append(addedCardType.toString()).append(" in addition to its other types"); //TODO add attacked card type detection sb.append(" creature becomes ").append(addedCardType.toString()).append(" in addition to its other types"); //TODO add attacked card type detection
staticText = sb.toString(); staticText = sb.toString();
} }

View file

@ -124,11 +124,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA) { sb.append(attachmentType.verb());
sb.append("Enchanted");
} else if (attachmentType == AttachmentType.EQUIPMENT) {
sb.append("Equipped");
}
sb.append(" creature "); sb.append(" creature ");
if (duration == Duration.WhileOnBattlefield) { if (duration == Duration.WhileOnBattlefield) {
sb.append("has "); sb.append("has ");

View file

@ -83,11 +83,7 @@ public class LoseAbilityAttachedEffect extends ContinuousEffectImpl {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA) { sb.append(attachmentType.verb());
sb.append("Enchanted");
} else if (attachmentType == AttachmentType.EQUIPMENT) {
sb.append("Equipped");
}
sb.append(" creature "); sb.append(" creature ");
if (duration == Duration.WhileOnBattlefield) { if (duration == Duration.WhileOnBattlefield) {
sb.append("loses "); sb.append("loses ");

View file

@ -75,11 +75,7 @@ public class SetCardColorAttachedEffect extends ContinuousEffectImpl {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA) sb.append(attachmentType.verb());
sb.append("Enchanted");
else if (attachmentType == AttachmentType.EQUIPMENT)
sb.append("Equipped");
sb.append(" creature is ").append(setColor.getDescription()); sb.append(" creature is ").append(setColor.getDescription());
staticText = sb.toString(); staticText = sb.toString();
} }

View file

@ -29,6 +29,7 @@ package mage.abilities.effects.common.continuous;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
@ -88,12 +89,7 @@ public class SetCardSubtypeAttachedEffect extends ContinuousEffectImpl {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (attachmentType == AttachmentType.AURA) { sb.append(attachmentType.verb());
sb.append("Enchanted");
} else if (attachmentType == AttachmentType.EQUIPMENT) {
sb.append("Equipped");
}
sb.append(" creature is a"); sb.append(" creature is a");
for (String subtype : this.setSubtypes) { for (String subtype : this.setSubtypes) {
sb.append(' ').append(subtype); sb.append(' ').append(subtype);

View file

@ -5,6 +5,16 @@ package mage.constants;
* @author North * @author North
*/ */
public enum AttachmentType { public enum AttachmentType {
EQUIPMENT, EQUIPMENT("Equipped"),
AURA AURA("Enchanted");
String verb;
public String verb(){
return verb;
}
AttachmentType(String verb){
this.verb = verb;
}
} }