mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Merge pull request #2880 from ingmargoudt/master
put the writing of equipped and enchanted in the attachmenttype
This commit is contained in:
commit
48a1fe8602
25 changed files with 46 additions and 120 deletions
|
@ -88,11 +88,7 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder("Whenever ");
|
||||
if (attachmentType.equals(AttachmentType.EQUIPMENT)) {
|
||||
sb.append("equipped");
|
||||
} else {
|
||||
sb.append("enchanted");
|
||||
}
|
||||
sb.append(attachmentType.verb().toLowerCase());
|
||||
return sb.append(" creature attacks, ").append(super.getRule()).toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,16 +109,12 @@ public class CantBeTargetedAttachedEffect extends ContinuousRuleModifyingEffectI
|
|||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (attachmentType.equals(AttachmentType.AURA)) {
|
||||
sb.append("Enchanted creature");
|
||||
} else {
|
||||
sb.append("Equipped creature");
|
||||
}
|
||||
sb.append(attachmentType.verb() + " creature");
|
||||
sb.append(" can't be the target of ");
|
||||
sb.append(filterSource.getMessage());
|
||||
if (!duration.toString().isEmpty()) {
|
||||
sb.append(' ');
|
||||
if (duration.equals(Duration.EndOfTurn)) {
|
||||
if (duration == Duration.EndOfTurn) {
|
||||
sb.append("this turn");
|
||||
} else {
|
||||
sb.append(duration.toString());
|
||||
|
|
|
@ -40,7 +40,6 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeff
|
||||
*/
|
||||
public class RegenerateAttachedEffect extends ReplacementEffectImpl {
|
||||
|
@ -102,13 +101,8 @@ public class RegenerateAttachedEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
sb.append("Regenerate enchanted creature");
|
||||
} else if (attachmentType == AttachmentType.EQUIPMENT) {
|
||||
sb.append("Regenerate equipped creature");
|
||||
}
|
||||
staticText = sb.toString();
|
||||
staticText = "Regenerate " + attachmentType.verb().toLowerCase() + " creature";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,11 +44,7 @@ public class AttacksIfAbleAttachedEffect extends RequirementEffect {
|
|||
|
||||
public AttacksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) {
|
||||
super(duration);
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
this.staticText = "Enchanted creature attacks each turn if able";
|
||||
} else {
|
||||
this.staticText = "Equipped creature attacks each turn if able";
|
||||
}
|
||||
this.staticText = attachmentType.verb() + " creature attacks each turn if able";
|
||||
}
|
||||
|
||||
public AttacksIfAbleAttachedEffect(final AttacksIfAbleAttachedEffect effect) {
|
||||
|
|
|
@ -36,7 +36,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
@ -44,11 +43,7 @@ public class BlocksIfAbleAttachedEffect extends RequirementEffect {
|
|||
|
||||
public BlocksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) {
|
||||
super(duration);
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
this.staticText = "Enchanted creature blocks each turn if able";
|
||||
} else {
|
||||
this.staticText = "Equipped creature blocks each turn if able";
|
||||
}
|
||||
this.staticText = attachmentType.verb() + " creature blocks each turn if able";
|
||||
}
|
||||
|
||||
public BlocksIfAbleAttachedEffect(final BlocksIfAbleAttachedEffect effect) {
|
||||
|
|
|
@ -37,7 +37,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
@ -45,11 +44,7 @@ public class CanBlockOnlyFlyingAttachedEffect extends RestrictionEffect {
|
|||
|
||||
public CanBlockOnlyFlyingAttachedEffect(AttachmentType attachmentType) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
this.staticText = "Enchanted creature can block only creatures with flying";
|
||||
} else {
|
||||
this.staticText = "Equipped creature can block only creatures with flying";
|
||||
}
|
||||
this.staticText = attachmentType.verb() + " creature can block only creatures with flying";
|
||||
}
|
||||
|
||||
public CanBlockOnlyFlyingAttachedEffect(final CanBlockOnlyFlyingAttachedEffect effect) {
|
||||
|
|
|
@ -20,11 +20,7 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect {
|
|||
|
||||
public CantAttackAloneAttachedEffect(AttachmentType attachmentType) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
this.staticText = "Enchanted creature can't attack alone";
|
||||
} else {
|
||||
this.staticText = "Equipped creature can't attack alone";
|
||||
}
|
||||
this.staticText = attachmentType.verb() + " creature can't attack alone";
|
||||
}
|
||||
|
||||
public CantAttackAloneAttachedEffect(final CantAttackAloneAttachedEffect effect) {
|
||||
|
|
|
@ -44,11 +44,7 @@ public class CantAttackAttachedEffect extends RestrictionEffect {
|
|||
|
||||
public CantAttackAttachedEffect(AttachmentType attachmentType) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
this.staticText = "Enchanted creature can't attack";
|
||||
} else {
|
||||
this.staticText = "Equipped creature can't attack";
|
||||
}
|
||||
this.staticText = attachmentType.verb() + " creature can't attack";
|
||||
}
|
||||
|
||||
public CantAttackAttachedEffect(final CantAttackAttachedEffect effect) {
|
||||
|
|
|
@ -35,18 +35,13 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantAttackBlockAttachedEffect extends RestrictionEffect {
|
||||
|
||||
public CantAttackBlockAttachedEffect(AttachmentType attachmentType) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
this.staticText = "Enchanted creature can't attack or block";
|
||||
} else {
|
||||
this.staticText = "Equipped creature can't attack or block";
|
||||
}
|
||||
this.staticText = attachmentType.verb() + " creature can't attack or block";
|
||||
}
|
||||
|
||||
public CantAttackBlockAttachedEffect(final CantAttackBlockAttachedEffect effect) {
|
||||
|
|
|
@ -46,8 +46,8 @@ public class CantAttackBlockUnlessPaysAttachedEffect extends PayCostToAttackBloc
|
|||
|
||||
public CantAttackBlockUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK_AND_BLOCK, manaCosts);
|
||||
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted " : "Equipped ")
|
||||
+ "creature can't attack or block unless its controller pays "
|
||||
staticText = attachmentType.verb()
|
||||
+ " creature can't attack or block unless its controller pays "
|
||||
+ (manaCosts == null ? "" : manaCosts.getText());
|
||||
}
|
||||
|
||||
|
|
|
@ -46,11 +46,7 @@ public class CantAttackControllerAttachedEffect extends RestrictionEffect {
|
|||
|
||||
public CantAttackControllerAttachedEffect(AttachmentType attachmentType) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
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";
|
||||
}
|
||||
this.staticText = attachmentType.verb() + " creature can't attack you or a planeswalker you control";
|
||||
}
|
||||
|
||||
public CantAttackControllerAttachedEffect(final CantAttackControllerAttachedEffect effect) {
|
||||
|
|
|
@ -46,8 +46,8 @@ public class CantAttackUnlessPaysAttachedEffect extends PayCostToAttackBlockEffe
|
|||
|
||||
public CantAttackUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK, manaCosts);
|
||||
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted " : "Equipped ")
|
||||
+ "creature can't attack unless its controller pays "
|
||||
staticText = attachmentType.verb()
|
||||
+ " creature can't attack unless its controller pays "
|
||||
+ (manaCosts == null ? "" : manaCosts.getText());
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,7 @@ public class CantBeBlockedAttachedEffect extends RestrictionEffect {
|
|||
|
||||
public CantBeBlockedAttachedEffect(AttachmentType attachmentType) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
this.staticText = "Enchanted creature can't be blocked";
|
||||
} else {
|
||||
this.staticText = "Equipped creature can't be blocked";
|
||||
}
|
||||
this.staticText = attachmentType.verb() + " creature can't be blocked";
|
||||
}
|
||||
|
||||
public CantBeBlockedAttachedEffect(CantBeBlockedAttachedEffect effect) {
|
||||
|
|
|
@ -36,7 +36,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect {
|
||||
|
@ -47,13 +46,9 @@ public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect {
|
|||
super(duration);
|
||||
this.filter = filter;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
sb.append("Enchanted ");
|
||||
} else {
|
||||
sb.append("Equipped ");
|
||||
}
|
||||
staticText = sb.append("creature can't be blocked ")
|
||||
.append(filter.getMessage().startsWith("except by") ? "":"by ").append(filter.getMessage()).toString();
|
||||
sb.append(attachmentType.verb());
|
||||
staticText = sb.append(" creature can't be blocked ")
|
||||
.append(filter.getMessage().startsWith("except by") ? "" : "by ").append(filter.getMessage()).toString();
|
||||
}
|
||||
|
||||
public CantBeBlockedByCreaturesAttachedEffect(final CantBeBlockedByCreaturesAttachedEffect effect) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class CantBeBlockedByOneAttachedEffect extends ContinuousEffectImpl {
|
|||
super(duration, Outcome.Benefit);
|
||||
this.amount = amount;
|
||||
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) {
|
||||
|
|
|
@ -56,11 +56,8 @@ public class CantBlockAttachedEffect extends RestrictionEffect {
|
|||
super(duration);
|
||||
this.filter = filter;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (attachmentType == AttachmentType.AURA) {
|
||||
sb.append("Enchanted creature can't block");
|
||||
} else {
|
||||
sb.append("Equipped creature can't block");
|
||||
}
|
||||
sb.append(attachmentType.verb());
|
||||
sb.append(" creature can't block");
|
||||
if (!filter.getMessage().equals("creature")) {
|
||||
sb.append(' ').append(filter.getMessage());
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.AttachmentType;
|
||||
import mage.constants.Duration;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -37,7 +38,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class MustBeBlockedByAllAttachedEffect extends RequirementEffect {
|
||||
|
@ -51,7 +51,7 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect {
|
|||
public MustBeBlockedByAllAttachedEffect(Duration duration, AttachmentType attachmentType) {
|
||||
super(duration);
|
||||
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) {
|
||||
|
@ -84,7 +84,7 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect {
|
|||
public UUID mustBlockAttacker(Ability source, Game game) {
|
||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
return attachment.getAttachedTo() ;
|
||||
return attachment.getAttachedTo();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -84,11 +84,7 @@ public class AddCardColorAttachedEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void setText() {
|
||||
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 is a ").append(addedColor.getDescription()).append(" in addition to its colors");
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -72,11 +72,8 @@ public class AddCardSubtypeAttachedEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void setText() {
|
||||
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
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -72,11 +72,7 @@ public class AddCardTypeAttachedEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void setText() {
|
||||
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(addedCardType.toString()).append(" in addition to its other types"); //TODO add attacked card type detection
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -124,11 +124,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void setText() {
|
||||
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 ");
|
||||
if (duration == Duration.WhileOnBattlefield) {
|
||||
sb.append("has ");
|
||||
|
|
|
@ -83,11 +83,7 @@ public class LoseAbilityAttachedEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void setText() {
|
||||
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 ");
|
||||
if (duration == Duration.WhileOnBattlefield) {
|
||||
sb.append("loses ");
|
||||
|
|
|
@ -75,11 +75,7 @@ public class SetCardColorAttachedEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void setText() {
|
||||
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 is ").append(setColor.getDescription());
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.abilities.effects.common.continuous;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.repository.CardRepository;
|
||||
|
@ -88,12 +89,7 @@ public class SetCardSubtypeAttachedEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void setText() {
|
||||
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 is a");
|
||||
for (String subtype : this.setSubtypes) {
|
||||
sb.append(' ').append(subtype);
|
||||
|
|
|
@ -5,6 +5,16 @@ package mage.constants;
|
|||
* @author North
|
||||
*/
|
||||
public enum AttachmentType {
|
||||
EQUIPMENT,
|
||||
AURA
|
||||
EQUIPMENT("Equipped"),
|
||||
AURA("Enchanted");
|
||||
|
||||
String verb;
|
||||
|
||||
public String verb(){
|
||||
return verb;
|
||||
}
|
||||
|
||||
AttachmentType(String verb){
|
||||
this.verb = verb;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue