mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Fixed Identity Thief copying creature with +1/+1 counter gets P/T boost from it, but not counter (fixes #2131).
This commit is contained in:
parent
d1c25b0662
commit
d0db2d51ed
33 changed files with 407 additions and 385 deletions
|
|
@ -24,8 +24,7 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -49,15 +48,28 @@ public class MageInt implements Serializable, Copyable<MageInt> {
|
|||
};
|
||||
|
||||
protected int baseValue;
|
||||
protected int baseValueModified;
|
||||
protected int boostedValue;
|
||||
protected String cardValue = "";
|
||||
|
||||
public MageInt(int value) {
|
||||
this.baseValue = value;
|
||||
this.baseValueModified = baseValue;
|
||||
this.boostedValue = baseValue;
|
||||
this.cardValue = Integer.toString(value);
|
||||
}
|
||||
|
||||
public MageInt(int baseValue, String cardValue) {
|
||||
this.baseValue = baseValue;
|
||||
this.baseValueModified = baseValue;
|
||||
this.boostedValue = baseValue;
|
||||
this.cardValue = cardValue;
|
||||
}
|
||||
|
||||
public MageInt(int baseValue, int baseValueModified, int boostedValue, String cardValue) {
|
||||
this.baseValue = baseValue;
|
||||
this.baseValueModified = baseValueModified;
|
||||
this.boostedValue = boostedValue;
|
||||
this.cardValue = cardValue;
|
||||
}
|
||||
|
||||
|
|
@ -66,24 +78,37 @@ public class MageInt implements Serializable, Copyable<MageInt> {
|
|||
if (this == EmptyMageInt) {
|
||||
return this;
|
||||
}
|
||||
return new MageInt(baseValue, cardValue);
|
||||
return new MageInt(baseValue, baseValueModified, boostedValue, cardValue);
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
public int getBaseValue() {
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
public void initValue(int value) {
|
||||
this.baseValue = value;
|
||||
public int getBaseValueModified() {
|
||||
return baseValueModified;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return boostedValue;
|
||||
}
|
||||
|
||||
public void modifyBaseValue(int value) {
|
||||
this.baseValueModified = value;
|
||||
this.boostedValue = value;
|
||||
this.cardValue = Integer.toString(value);
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
this.baseValue = value;
|
||||
this.boostedValue = value;
|
||||
}
|
||||
|
||||
public void boostValue(int amount) {
|
||||
this.baseValue += amount;
|
||||
this.boostedValue += amount;
|
||||
}
|
||||
|
||||
public void resetToBaseValue() {
|
||||
this.boostedValue = this.baseValueModified;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -47,13 +47,12 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* This effect lets the card be a 2/2 face-down creature, with no text,
|
||||
* no name, no subtypes, and no mana cost, if it's face down on the battlefield.
|
||||
* And it adds the a TurnFaceUpAbility ability.
|
||||
*
|
||||
* This effect lets the card be a 2/2 face-down creature, with no text, no name,
|
||||
* no subtypes, and no mana cost, if it's face down on the battlefield. And it
|
||||
* adds the a TurnFaceUpAbility ability.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
public enum FaceDownType {
|
||||
|
|
@ -65,15 +64,15 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
|
||||
protected int zoneChangeCounter;
|
||||
protected Ability turnFaceUpAbility = null;
|
||||
protected MageObjectReference objectReference= null;
|
||||
protected MageObjectReference objectReference = null;
|
||||
protected boolean foundPermanent;
|
||||
protected FaceDownType faceDownType;
|
||||
|
||||
public BecomesFaceDownCreatureEffect(Duration duration, FaceDownType faceDownType){
|
||||
public BecomesFaceDownCreatureEffect(Duration duration, FaceDownType faceDownType) {
|
||||
this(null, null, duration, faceDownType);
|
||||
}
|
||||
|
||||
public BecomesFaceDownCreatureEffect(Costs<Cost> turnFaceUpCosts, FaceDownType faceDownType){
|
||||
public BecomesFaceDownCreatureEffect(Costs<Cost> turnFaceUpCosts, FaceDownType faceDownType) {
|
||||
this(turnFaceUpCosts, null, faceDownType);
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +96,6 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
this.faceDownType = faceDownType;
|
||||
}
|
||||
|
||||
|
||||
public BecomesFaceDownCreatureEffect(final BecomesFaceDownCreatureEffect effect) {
|
||||
super(effect);
|
||||
this.zoneChangeCounter = effect.zoneChangeCounter;
|
||||
|
|
@ -147,11 +145,11 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
} else {
|
||||
permanent = game.getPermanent(source.getSourceId());
|
||||
}
|
||||
|
||||
|
||||
if (permanent != null && permanent.isFaceDown(game)) {
|
||||
if (!foundPermanent) {
|
||||
foundPermanent = true;
|
||||
switch(faceDownType) {
|
||||
switch (faceDownType) {
|
||||
case MANIFESTED:
|
||||
case MANUAL: // sets manifested image
|
||||
permanent.setManifested(true);
|
||||
|
|
@ -184,11 +182,9 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
if (ability.getWorksFaceDown()) {
|
||||
ability.setRuleVisible(false);
|
||||
continue;
|
||||
} else {
|
||||
if (!ability.getRuleVisible() && !ability.getEffects().isEmpty()) {
|
||||
if (ability.getEffects().get(0) instanceof BecomesFaceDownCreatureEffect) {
|
||||
continue;
|
||||
}
|
||||
} else if (!ability.getRuleVisible() && !ability.getEffects().isEmpty()) {
|
||||
if (ability.getEffects().get(0) instanceof BecomesFaceDownCreatureEffect) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
abilitiesToRemove.add(ability);
|
||||
|
|
@ -200,14 +196,12 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanent.getPower().setValue(2);
|
||||
permanent.getToughness().setValue(2);
|
||||
// permanent.getPower().setValue(2);
|
||||
// permanent.getToughness().setValue(2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (duration.equals(Duration.Custom) && foundPermanent == true) {
|
||||
discard();
|
||||
}
|
||||
} else if (duration.equals(Duration.Custom) && foundPermanent == true) {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
if (mode == null || mode.getTargets().size() == 0) {
|
||||
if (mode == null || mode.getTargets().isEmpty()) {
|
||||
return "no target";
|
||||
}
|
||||
Target target = mode.getTargets().get(0);
|
||||
|
|
|
|||
|
|
@ -208,7 +208,6 @@ class FlashbackEffect extends OneShotEffect {
|
|||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + " flashbacks " + card.getLogName());
|
||||
}
|
||||
// spellAbility.setCostModificationActive(false); // prevents to apply cost modification twice for flashbacked spells
|
||||
if (controller.cast(spellAbility, game, false)) {
|
||||
ContinuousEffect effect = new FlashbackReplacementEffect();
|
||||
effect.setTargetPointer(new FixedTarget(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId())));
|
||||
|
|
|
|||
|
|
@ -295,8 +295,8 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
}
|
||||
|
||||
public static void setPermanentToFaceDownCreature(MageObject mageObject) {
|
||||
mageObject.getPower().initValue(2);
|
||||
mageObject.getToughness().initValue(2);
|
||||
mageObject.getPower().modifyBaseValue(2);
|
||||
mageObject.getToughness().modifyBaseValue(2);
|
||||
mageObject.getAbilities().clear();
|
||||
mageObject.getColor(null).setColor(new ObjectColor());
|
||||
mageObject.setName("");
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ public class PermanentCard extends PermanentImpl {
|
|||
}
|
||||
|
||||
private void init(Card card, Game game) {
|
||||
power = card.getPower().copy();
|
||||
toughness = card.getToughness().copy();
|
||||
copyFromCard(card);
|
||||
// if temporary added abilities to the spell/card exist, you need to add it to the permanent derived from that card
|
||||
Abilities<Ability> otherAbilities = game.getState().getAllOtherAbilities(card.getId());
|
||||
|
|
@ -94,6 +96,8 @@ public class PermanentCard extends PermanentImpl {
|
|||
// when the permanent is reset, copy all original values from the card
|
||||
// must copy card each reset so that the original values don't get modified
|
||||
copyFromCard(card);
|
||||
power.resetToBaseValue();
|
||||
toughness.resetToBaseValue();
|
||||
super.reset(game);
|
||||
}
|
||||
|
||||
|
|
@ -115,8 +119,6 @@ public class PermanentCard extends PermanentImpl {
|
|||
this.cardType.addAll(card.getCardType());
|
||||
this.color = card.getColor(null).copy();
|
||||
this.manaCost = card.getManaCost().copy();
|
||||
this.power = card.getPower().copy();
|
||||
this.toughness = card.getToughness().copy();
|
||||
if (card instanceof PermanentCard) {
|
||||
this.maxLevelCounters = ((PermanentCard) card).maxLevelCounters;
|
||||
}
|
||||
|
|
@ -232,6 +234,8 @@ public class PermanentCard extends PermanentImpl {
|
|||
@Override
|
||||
public boolean turnFaceUp(Game game, UUID playerId) {
|
||||
if (super.turnFaceUp(game, playerId)) {
|
||||
power.modifyBaseValue(power.getBaseValue());
|
||||
toughness.modifyBaseValue(toughness.getBaseValue());
|
||||
setManifested(false);
|
||||
setMorphed(false);
|
||||
return true;
|
||||
|
|
@ -241,7 +245,7 @@ public class PermanentCard extends PermanentImpl {
|
|||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (this.isTransformed()) {
|
||||
if (this.isTransformed() && card.getSecondCardFace() != null) {
|
||||
card.getSecondCardFace().adjustTargets(ability, game);
|
||||
} else {
|
||||
card.adjustTargets(ability, game);
|
||||
|
|
@ -250,7 +254,7 @@ public class PermanentCard extends PermanentImpl {
|
|||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
if (this.isTransformed()) {
|
||||
if (this.isTransformed() && card.getSecondCardFace() != null) {
|
||||
card.getSecondCardFace().adjustCosts(ability, game);
|
||||
} else {
|
||||
card.adjustCosts(ability, game);
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ public class PermanentToken extends PermanentImpl {
|
|||
}
|
||||
this.cardType = token.getCardType();
|
||||
this.color = token.getColor(game).copy();
|
||||
this.power.initValue(token.getPower().getValue());
|
||||
this.toughness.initValue(token.getToughness().getValue());
|
||||
this.power.modifyBaseValue(token.getPower().getBaseValueModified());
|
||||
this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified());
|
||||
this.supertype = token.getSupertype();
|
||||
this.subtype = token.getSubtype();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,11 +81,11 @@ public class Token extends MageObjectImpl {
|
|||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public Token(String name, String description, int power, int toughness) {
|
||||
this(name, description);
|
||||
this.power.setValue(power);
|
||||
this.toughness.setValue(toughness);
|
||||
this.power.modifyBaseValue(power);
|
||||
this.toughness.modifyBaseValue(toughness);
|
||||
}
|
||||
|
||||
public Token(String name, String description, ObjectColor color, List<String> subtype, int power, int toughness, Abilities<Ability> abilities) {
|
||||
|
|
@ -93,8 +93,8 @@ public class Token extends MageObjectImpl {
|
|||
this.cardType.add(CardType.CREATURE);
|
||||
this.color = color.copy();
|
||||
this.subtype = subtype;
|
||||
this.power.setValue(power);
|
||||
this.toughness.setValue(toughness);
|
||||
this.power.modifyBaseValue(power);
|
||||
this.toughness.modifyBaseValue(toughness);
|
||||
if (abilities != null) {
|
||||
this.abilities = abilities.copy();
|
||||
}
|
||||
|
|
@ -217,11 +217,11 @@ public class Token extends MageObjectImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void setPower(int power) {
|
||||
this.power.setValue(power);
|
||||
}
|
||||
|
||||
|
||||
public void setToughness(int toughness) {
|
||||
this.toughness.setValue(toughness);
|
||||
}
|
||||
|
|
@ -264,17 +264,13 @@ public class Token extends MageObjectImpl {
|
|||
if (availableImageSetCodes.size() > 0) {
|
||||
if (availableImageSetCodes.contains(code)) {
|
||||
setOriginalExpansionSetCode(code);
|
||||
} else {
|
||||
// we should not set random set if appropriate set is already used
|
||||
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()
|
||||
|| !availableImageSetCodes.contains(getOriginalExpansionSetCode())) {
|
||||
setOriginalExpansionSetCode(availableImageSetCodes.get(new Random().nextInt(availableImageSetCodes.size())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()) {
|
||||
setOriginalExpansionSetCode(code);
|
||||
} else // we should not set random set if appropriate set is already used
|
||||
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()
|
||||
|| !availableImageSetCodes.contains(getOriginalExpansionSetCode())) {
|
||||
setOriginalExpansionSetCode(availableImageSetCodes.get(new Random().nextInt(availableImageSetCodes.size())));
|
||||
}
|
||||
} else if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()) {
|
||||
setOriginalExpansionSetCode(code);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,9 +108,9 @@ public class CopyTokenFunction implements Function<Token, Card> {
|
|||
ability.setSourceId(target.getId());
|
||||
target.addAbility(ability);
|
||||
}
|
||||
// Needed to do it this way because only the cardValue does not include the increased value from cards like "Intangible Virtue" will be copied.
|
||||
target.getPower().initValue(Integer.parseInt(sourceObj.getPower().toString()));
|
||||
target.getToughness().initValue(Integer.parseInt(sourceObj.getToughness().toString()));
|
||||
|
||||
target.getPower().modifyBaseValue(sourceObj.getPower().getBaseValueModified());
|
||||
target.getToughness().modifyBaseValue(sourceObj.getToughness().getBaseValueModified());
|
||||
|
||||
return target;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue