Merge pull request #7103 from magefree/cardfix/ArchonOfValorsReach

Fixed Archon of Valors Reach ContinuousRuleModifyingEffect not working
This commit is contained in:
Oleg Agafonov 2020-10-02 16:51:54 +02:00 committed by GitHub
commit aba9f6895b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,11 +19,12 @@ import mage.game.events.GameEvent;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import static mage.game.events.GameEvent.EventType.CAST_SPELL;
/** /**
* @author TheElk801 * @author TheElk801
*/ */
public final class ArchonOfValorsReach extends CardImpl { public final class ArchonOfValorsReach extends CardImpl {
public ArchonOfValorsReach(UUID ownerId, CardSetInfo setInfo) { public ArchonOfValorsReach(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}{W}");
@ -74,26 +75,29 @@ class ArchonOfValorsReachReplacementEffect extends ContinuousRuleModifyingEffect
@Override @Override
public String getInfoMessage(Ability source, GameEvent event, Game game) { public String getInfoMessage(Ability source, GameEvent event, Game game) {
Object savedType = game.getState().getValue(source.getSourceId() + "_type"); Object savedType = game.getState().getValue(source.getSourceId() + "_type");
Card sourceCard = game.getCard(source.getSourceId()); Card card = game.getCard(event.getSourceId());
if (savedType instanceof String && sourceCard != null) { if (savedType instanceof String && card != null) {
CardType cardType = CardType.fromString((String) savedType); CardType cardType = CardType.fromString((String) savedType);
return "You can't cast " + cardType.toString() + " spells (" + sourceCard.getIdName() + ")."; return "You can't cast " + cardType.toString() + " spells (" + card.getIdName() + ").";
} }
return null; return null;
} }
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL; return event.getType() == CAST_SPELL;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Object savedType = game.getState().getValue(source.getSourceId() + "_type"); Object savedType = game.getState().getValue(source.getSourceId() + "_type");
Card sourceCard = game.getCard(source.getSourceId()); Card card = game.getCard(event.getSourceId());
if (savedType instanceof String && sourceCard != null) {
if (savedType instanceof String && card != null) {
CardType cardType = CardType.fromString((String) savedType); CardType cardType = CardType.fromString((String) savedType);
return cardType != null && sourceCard != null && sourceCard.getCardType().contains(cardType); if (cardType != null && card != null && card.getCardType().contains(cardType)) {
return true;
}
} }
return false; return false;
} }