mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
rework partner variants, add tests
This commit is contained in:
parent
fec3599b73
commit
8375d6b606
13 changed files with 128 additions and 128 deletions
|
|
@ -1,38 +0,0 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.constants.Zone;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class PartnerFatherAndSonAbility extends StaticAbility implements MageSingleton {
|
||||
|
||||
private static final PartnerFatherAndSonAbility instance = new PartnerFatherAndSonAbility();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static PartnerFatherAndSonAbility getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private PartnerFatherAndSonAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Partner—Father & son <i>(You can have two commanders if both have this ability.)</i>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartnerFatherAndSonAbility copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.constants.Zone;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class PartnerSurvivorsAbility extends StaticAbility implements MageSingleton {
|
||||
|
||||
private static final PartnerSurvivorsAbility instance = new PartnerSurvivorsAbility();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static PartnerSurvivorsAbility getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private PartnerSurvivorsAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Partner—Survivors <i>(You can have two commanders if both have this ability.)</i>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartnerSurvivorsAbility copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
80
Mage/src/main/java/mage/constants/PartnerVariantType.java
Normal file
80
Mage/src/main/java/mage/constants/PartnerVariantType.java
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
package mage.constants;
|
||||
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum PartnerVariantType {
|
||||
FATHER_AND_SON("Father & son"),
|
||||
SURVIVORS("Survivors");
|
||||
|
||||
private final String name;
|
||||
|
||||
PartnerVariantType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public PartnerVariantAbility makeAbility() {
|
||||
return new PartnerVariantAbility(this);
|
||||
}
|
||||
|
||||
private static Set<PartnerVariantType> getTypes(Card card) {
|
||||
return CardUtil
|
||||
.castStream(card.getAbilities(), PartnerVariantAbility.class)
|
||||
.map(PartnerVariantAbility::getType)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public static boolean checkCommanders(Card commander1, Card commander2) {
|
||||
Set<PartnerVariantType> types1 = getTypes(commander1);
|
||||
if (types1.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Set<PartnerVariantType> types2 = getTypes(commander2);
|
||||
if (types2.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
types1.retainAll(types2);
|
||||
return !types1.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
class PartnerVariantAbility extends StaticAbility {
|
||||
|
||||
private final PartnerVariantType type;
|
||||
|
||||
PartnerVariantAbility(PartnerVariantType type) {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private PartnerVariantAbility(final PartnerVariantAbility ability) {
|
||||
super(ability);
|
||||
this.type = ability.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartnerVariantAbility copy() {
|
||||
return new PartnerVariantAbility(this);
|
||||
}
|
||||
|
||||
public PartnerVariantType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Partner—" + type + " <i>(You can have two commanders if both have this ability.)</i>";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package mage.util.validation;
|
||||
|
||||
import mage.abilities.keyword.PartnerFatherAndSonAbility;
|
||||
import mage.cards.Card;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum PartnerFatherAndSonValidator implements CommanderValidator {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean checkPartner(Card commander1, Card commander2) {
|
||||
return commander1.getAbilities().containsClass(PartnerFatherAndSonAbility.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package mage.util.validation;
|
||||
|
||||
import mage.abilities.keyword.PartnerSurvivorsAbility;
|
||||
import mage.cards.Card;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum PartnerSurvivorsValidator implements CommanderValidator {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean checkPartner(Card commander1, Card commander2) {
|
||||
return commander1.getAbilities().containsClass(PartnerSurvivorsAbility.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package mage.util.validation;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.constants.PartnerVariantType;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum PartnerVariantValidator implements CommanderValidator {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean checkPartner(Card commander1, Card commander2) {
|
||||
return PartnerVariantType.checkCommanders(commander1, commander2);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue