mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
* Oathbreaker format - Fixed that signate spell didn't return to command zone. Added unit test for oathbreaker format (fixes #6695).
This commit is contained in:
parent
5ae041f39a
commit
29e5230469
6 changed files with 220 additions and 19 deletions
|
|
@ -22,9 +22,9 @@ import java.util.UUID;
|
|||
*/
|
||||
public class OathbreakerOnBattlefieldCondition implements Condition {
|
||||
|
||||
private UUID playerId;
|
||||
private FilterControlledPermanent filter;
|
||||
private String compatibleNames;
|
||||
private final UUID playerId;
|
||||
private final FilterControlledPermanent filter;
|
||||
private final String compatibleNames;
|
||||
|
||||
public OathbreakerOnBattlefieldCondition(Game game, UUID playerId, UUID signatureSpellId, Set<UUID> oathbreakersToSearch) {
|
||||
this.playerId = playerId;
|
||||
|
|
@ -35,17 +35,17 @@ public class OathbreakerOnBattlefieldCondition implements Condition {
|
|||
|
||||
// spell can be casted by any compatible oathbreakers
|
||||
List<PermanentIdPredicate> compatibleList = new ArrayList<>();
|
||||
List<String> compatibleNames = new ArrayList<>();
|
||||
List<String> compatibleNamesList = new ArrayList<>();
|
||||
if (oathbreakersToSearch != null && !oathbreakersToSearch.isEmpty()) {
|
||||
for (UUID id : oathbreakersToSearch) {
|
||||
Card commander = game.getCard(id);
|
||||
if (commander != null && ManaUtil.isColorIdentityCompatible(commander.getColorIdentity(), spellColors)) {
|
||||
compatibleList.add(new PermanentIdPredicate(id));
|
||||
compatibleNames.add(commander.getName());
|
||||
compatibleNamesList.add(commander.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
this.compatibleNames = String.join("; ", compatibleNames);
|
||||
this.compatibleNames = String.join("; ", compatibleNamesList);
|
||||
|
||||
if (compatibleList.isEmpty()) {
|
||||
// random id to disable condition
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ import java.util.UUID;
|
|||
that permanent and the card representing it that isn’t a commander are put into the appropriate zone, and the card
|
||||
that represents it and is a commander is put into the command zone.
|
||||
*/
|
||||
|
||||
// Oathbreaker mode: If your Oathbreaker changes zones, you may return it to the Command Zone. The Signature Spell must return to the Command Zone.
|
||||
|
||||
public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
private final UUID commanderId;
|
||||
|
|
@ -39,6 +37,17 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
private final boolean forceToMove;
|
||||
private final String commanderTypeName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param commanderId
|
||||
* @param alsoHand is the replacement effect also applied if commander
|
||||
* object goes to hand zone
|
||||
* @param alsoLibrary is the replacement effect also applied if commander
|
||||
* object goes to library zone
|
||||
* @param forceToMove used for signature spell of Oathbreaker format (spell
|
||||
* is mandatory moved to command zone instead)
|
||||
* @param commanderTypeName type of commander object to set the correct text
|
||||
*/
|
||||
public CommanderReplacementEffect(UUID commanderId, boolean alsoHand, boolean alsoLibrary, boolean forceToMove, String commanderTypeName) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
String mayStr = forceToMove ? " " : " may ";
|
||||
|
|
@ -89,11 +98,11 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (!commanderId.equals(event.getTargetId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (!game.isSimulation() && commanderId.equals(zEvent.getTargetId())) {
|
||||
// System.out.println("applies " + game.getTurnNum() + ": " + game.getObject(event.getTargetId()).getName() + ": " + zEvent.getFromZone() + " -> " + zEvent.getToZone() + "; " + game.getObject(zEvent.getSourceId()));
|
||||
// }
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
|
||||
if (zEvent.getToZone().equals(Zone.HAND) && !alsoHand) {
|
||||
return false;
|
||||
|
|
@ -106,10 +115,14 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
switch (zEvent.getToZone()) {
|
||||
case LIBRARY:
|
||||
case HAND:
|
||||
if (commanderId.equals(zEvent.getTargetId())) {
|
||||
return true;
|
||||
}
|
||||
if (forceToMove) {
|
||||
switch (zEvent.getToZone()) {
|
||||
case BATTLEFIELD:
|
||||
case GRAVEYARD:
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -119,10 +132,6 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
String originToZone = zEvent.getToZone().toString().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
if (!game.isSimulation()) {
|
||||
//System.out.println("replace " + game.getTurnNum() + ": " + game.getObject(event.getTargetId()).getName() + ": " + zEvent.getFromZone() + " -> " + zEvent.getToZone() + "; " + game.getObject(zEvent.getSourceId()));
|
||||
}
|
||||
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||
Permanent permanent = zEvent.getTarget();
|
||||
if (permanent != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue