[STX] add more cards (#7720)

* implement AcademicProbation
* implement AugmenterPugilist // EchoingEquation
* Implement BalefulMastery
* implement BasicConjuration
* implement ClosingStatement
* Test framework: added custom effect to return card from any zone to hand;

Co-authored-by: Oleg Agafonov <jaydi85@gmail.com>
This commit is contained in:
htrajan 2021-04-09 06:56:34 -07:00 committed by GitHub
parent ac2c2acfe4
commit 10cd439955
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 766 additions and 57 deletions

View file

@ -15,19 +15,29 @@ import java.util.Locale;
public class IsPhaseCondition implements Condition {
protected TurnPhase turnPhase;
protected boolean yourTurn;
public IsPhaseCondition(TurnPhase turnPhase) {
this(turnPhase, false);
}
public IsPhaseCondition(TurnPhase turnPhase, boolean yourTurn) {
this.turnPhase = turnPhase;
this.yourTurn = yourTurn;
}
@Override
public boolean apply(Game game, Ability source) {
return turnPhase == game.getTurn().getPhaseType();
return turnPhase == game.getTurn().getPhaseType() && (!yourTurn || game.getActivePlayerId().equals(source.getControllerId()));
}
@Override
public String toString() {
return new StringBuilder("during ").append(turnPhase).toString().toLowerCase(Locale.ENGLISH);
return new StringBuilder("during ")
.append(yourTurn ? "your " : "")
.append(turnPhase)
.toString()
.toLowerCase(Locale.ENGLISH);
}
}

View file

@ -1,4 +1,3 @@
package mage.abilities.costs;
import mage.abilities.Ability;
@ -16,13 +15,15 @@ import mage.players.Player;
import mage.util.CardUtil;
import java.util.Iterator;
import mage.MageObject;
import java.util.UUID;
/**
* @author LevelX2
*/
public class AlternativeCostSourceAbility extends StaticAbility implements AlternativeSourceCosts {
private static final String ALTERNATIVE_COST_ACTIVATION_KEY = "AlternativeCostActivated";
private Costs<AlternativeCost2> alternateCosts = new CostsImpl<>();
protected Condition condition;
protected String rule;
@ -159,6 +160,9 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
}
}
}
// save activated status
game.getState().setValue(getActivatedKey(ability), Boolean.TRUE);
} else {
return false;
}
@ -169,6 +173,38 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
return isActivated(ability, game);
}
private String getActivatedKey(Ability source) {
return getActivatedKey(this.getOriginalId(), source.getSourceId(), source.getSourceObjectZoneChangeCounter());
}
private static String getActivatedKey(UUID alternativeCostOriginalId, UUID sourceId, int sourceZCC) {
// can't use sourceId cause copied cards are different...
// TODO: enable sourceId after copy card fix (it must copy cards with all related game state values)
return ALTERNATIVE_COST_ACTIVATION_KEY + "_" + alternativeCostOriginalId + "_" /*+ sourceId + "_"*/ + sourceZCC;
}
/**
* Search activated status of alternative cost.
* <p>
* If you need it on resolve then use current ZCC (on stack)
* If you need it on battlefield then use previous ZCC (-1)
*
* @param game
* @param source
* @param alternativeCostOriginalId you must save originalId on card's creation
* @param searchPrevZCC true on battlefield, false on stack
* @return
*/
public static boolean getActivatedStatus(Game game, Ability source, UUID alternativeCostOriginalId, boolean searchPrevZCC) {
String key = getActivatedKey(
alternativeCostOriginalId,
source.getSourceId(),
source.getSourceObjectZoneChangeCounter() + (searchPrevZCC ? -1 : 0)
);
Boolean status = (Boolean) game.getState().getValue(key);
return status != null && status;
}
@Override
public boolean isActivated(Ability source, Game game) {
Costs<AlternativeCost2> alternativeCostsToCheck;

View file

@ -78,7 +78,7 @@ public class CopyEffect extends ContinuousEffectImpl {
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD, source.getSourceObjectZoneChangeCounter());
// As long as the permanent is still in the LKI continue to copy to get triggered abilities to TriggeredAbilites for dies events.
// As long as the permanent is still in the LKI continue to copy to get triggered abilities to TriggeredAbilities for dies events.
if (permanent == null) {
discard();
return false;

View file

@ -0,0 +1,55 @@
package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.util.CardUtil;
/**
* This effect must be used in tandem with ChooseACardNameEffect
*/
public class OpponentsCantCastChosenUntilNextTurnEffect extends ContinuousRuleModifyingEffectImpl {
public OpponentsCantCastChosenUntilNextTurnEffect() {
super(Duration.UntilYourNextTurn, Outcome.Benefit);
staticText = "Until your next turn, your opponents can't cast spells with the chosen name";
}
public OpponentsCantCastChosenUntilNextTurnEffect(final OpponentsCantCastChosenUntilNextTurnEffect effect) {
super(effect);
}
@Override
public OpponentsCantCastChosenUntilNextTurnEffect copy() {
return new OpponentsCantCastChosenUntilNextTurnEffect(this);
}
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source.getSourceId());
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (mageObject != null && cardName != null) {
return "You can't cast a card named " + cardName + " (" + mageObject.getIdName() + ").";
}
return null;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL_LATE;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
MageObject object = game.getObject(event.getSourceId());
return object != null && CardUtil.haveSameNames(object, cardName, game);
}
return false;
}
}