mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
More correct checking for having subtypes (card.hasSubtype()). Changeling ability. Refactored all cards.
This commit is contained in:
parent
2da9518486
commit
f13ba5d7fb
24 changed files with 126 additions and 21 deletions
|
@ -100,7 +100,7 @@ class AshenSkinZuberaWatcher extends WatcherImpl<AshenSkinZuberaWatcher> {
|
|||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (card != null && card.getSubtype().contains("Zubera")) {
|
||||
if (card != null && card.hasSubtype("Zubera")) {
|
||||
zuberasDiedThisTurn++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class DrippingTongueZuberaWatcher extends WatcherImpl<DrippingTongueZuberaWatche
|
|||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (card != null && card.getSubtype().contains("Zubera")) {
|
||||
if (card != null && card.hasSubtype("Zubera")) {
|
||||
zuberasDiedThisTurn++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ class EmberFistZuberaWatcher extends WatcherImpl<EmberFistZuberaWatcher> {
|
|||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (card != null && card.getSubtype().contains("Zubera")) {
|
||||
if (card != null && card.hasSubtype("Zubera")) {
|
||||
zuberasDiedThisTurn++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class FloatingDreamZuberaWatcher extends WatcherImpl<FloatingDreamZuberaWatcher>
|
|||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (card != null && card.getSubtype().contains("Zubera")) {
|
||||
if (card != null && card.hasSubtype("Zubera")) {
|
||||
zuberasDiedThisTurn++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ class SeshiroTheAnointedAbility extends TriggeredAbilityImpl<SeshiroTheAnointedA
|
|||
if (event instanceof DamagedPlayerEvent) {
|
||||
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
|
||||
Permanent p = game.getPermanent(event.getSourceId());
|
||||
if (damageEvent.isCombatDamage() && p != null && p.getSubtype().contains("Snake")) {
|
||||
if (damageEvent.isCombatDamage() && p != null && p.hasSubtype("Snake")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class SilentChantZuberaWatcher extends WatcherImpl<SilentChantZuberaWatcher> {
|
|||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (card != null && card.getSubtype().contains("Zubera")) {
|
||||
if (card != null && card.hasSubtype("Zubera")) {
|
||||
zuberasDiedThisTurn++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ class StormtideLeviathanEffect extends ContinuousEffectImpl<StormtideLeviathanEf
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), game)) {
|
||||
if (!permanent.getSubtype().contains("Island"))
|
||||
if (!permanent.hasSubtype("Island"))
|
||||
permanent.getSubtype().add("Island");
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -30,7 +30,6 @@ package mage.sets.riseoftheeldrazi;
|
|||
import java.util.UUID;
|
||||
|
||||
import mage.ConditionalMana;
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageObject;
|
||||
|
@ -40,7 +39,6 @@ import mage.abilities.condition.Condition;
|
|||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.abilities.mana.BasicManaAbility;
|
||||
import mage.abilities.mana.ColorlessManaAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
|
||||
|
@ -98,7 +96,7 @@ class EldraziManaCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object != null && object.getSubtype().contains("Eldrazi") && !object.getColor().hasColor()) {
|
||||
if (object != null && object.hasSubtype("Eldrazi") && !object.getColor().hasColor()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -113,7 +113,7 @@ class MyrManaCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object != null && object.getSubtype().contains("Myr")) {
|
||||
if (object != null && object.hasSubtype("Myr")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -124,7 +124,7 @@ class PrecursorGolemCopyTriggeredAbility extends TriggeredAbilityImpl<PrecursorG
|
|||
for (UUID target : effect.getTargetPointer().getTargets(sa)) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if (permanent != null) {
|
||||
if (!permanent.getSubtype().contains("Golem")) {
|
||||
if (!permanent.hasSubtype("Golem")) {
|
||||
return false;
|
||||
}
|
||||
if (targetGolem == null) {
|
||||
|
|
|
@ -108,7 +108,7 @@ class ReaperKingAbility extends TriggeredAbilityImpl<ReaperKingAbility> {
|
|||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent.getControllerId().equals(this.controllerId)
|
||||
&& permanent.getCardType().contains(CardType.CREATURE)
|
||||
&& permanent.getSubtype().contains("Scarecrow")
|
||||
&& permanent.hasSubtype("Scarecrow")
|
||||
&& !targetId.equals(this.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ class JuggernautEffect extends CantBlockSourceEffect {
|
|||
|
||||
@Override
|
||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
|
||||
return !blocker.getSubtype().contains("Wall");
|
||||
return !blocker.hasSubtype("Wall");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -115,7 +115,7 @@ class EyeOfUginCostReductionEffect extends CostModificationEffectImpl<EyeOfUginC
|
|||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if ( abilityToModify instanceof SpellAbility ) {
|
||||
Card sourceCard = game.getCard(((SpellAbility)abilityToModify).getSourceId());
|
||||
if ( sourceCard != null && sourceCard.getSubtype().contains("Eldrazi") && sourceCard.getOwnerId().equals(source.getControllerId()) ) {
|
||||
if ( sourceCard != null && sourceCard.hasSubtype("Eldrazi") && sourceCard.getOwnerId().equals(source.getControllerId()) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class KalastriaHighbornTriggeredAbility extends TriggeredAbilityImpl<KalastriaHi
|
|||
zEvent.getToZone() == Zone.GRAVEYARD &&
|
||||
zEvent.getFromZone() == Zone.BATTLEFIELD &&
|
||||
permanent.getControllerId().equals(this.getControllerId()) &&
|
||||
permanent.getSubtype().contains("Vampire"))
|
||||
permanent.hasSubtype("Vampire"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ class BladeOfTheBloodchiefEffect extends OneShotEffect<BladeOfTheBloodchiefEffec
|
|||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
if ( creature.getSubtype().contains("Vampire") ) {
|
||||
if ( creature.hasSubtype("Vampire") ) {
|
||||
creature.addCounters(new PlusOneCounter(2), game);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -96,7 +96,7 @@ class ValakutTheMoltenPinnacleTriggeredAbility extends TriggeredAbilityImpl<Vala
|
|||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.BATTLEFIELD) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.controllerId)) {
|
||||
if(permanent.getSubtype().contains("Mountain")){
|
||||
if(permanent.hasSubtype("Mountain")){
|
||||
|
||||
int count = game.getBattlefield().count(ValakutTheMoltenPinnacle.filter, permanent.getControllerId(), game);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ public interface MageObject extends MageItem, Serializable {
|
|||
|
||||
public List<CardType> getCardType();
|
||||
public List<String> getSubtype();
|
||||
public boolean hasSubtype(String subtype);
|
||||
public List<String> getSupertype();
|
||||
|
||||
public Abilities<Ability> getAbilities();
|
||||
|
|
|
@ -39,6 +39,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.keyword.ChangelingAbility;
|
||||
import mage.game.Game;
|
||||
|
||||
public abstract class MageObjectImpl<T extends MageObjectImpl<T>> implements MageObject {
|
||||
|
@ -150,4 +151,25 @@ public abstract class MageObjectImpl<T extends MageObjectImpl<T>> implements Mag
|
|||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {}
|
||||
|
||||
@Override
|
||||
public boolean hasSubtype(String subtype) {
|
||||
if (subtype == null) {
|
||||
return false;
|
||||
}
|
||||
if (subtype.contains(subtype)) {
|
||||
return true;
|
||||
}
|
||||
else { // checking for Changeling
|
||||
// first make sure input parameter is not creature type
|
||||
// if so, then ChangelingAbility doesn't matter
|
||||
if (subtype.equals("Mountain") || subtype.equals("Island") || subtype.equals("Plains")
|
||||
|| subtype.equals("Forest") || subtype.equals("Swamp") || subtype.equals("Aura")
|
||||
|| subtype.equals("Equipment") || subtype.equals("Fortification")) {
|
||||
return false;
|
||||
}
|
||||
// as it is creature subtype, then check the existence of Changeling
|
||||
return abilities.contains(ChangelingAbility.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class AllyEntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl
|
|||
if (zEvent.getToZone() == Zone.BATTLEFIELD
|
||||
&& permanent.getControllerId().equals(this.controllerId)
|
||||
&& (targetId.equals(this.getSourceId())
|
||||
|| (permanent.getSubtype().contains("Ally") && !targetId.equals(this.getSourceId())))) {
|
||||
|| (permanent.hasSubtype("Ally") && !targetId.equals(this.getSourceId())))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
66
Mage/src/mage/abilities/keyword/ChangelingAbility.java
Normal file
66
Mage/src/mage/abilities/keyword/ChangelingAbility.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* 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.abilities.keyword;
|
||||
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.StaticAbility;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class ChangelingAbility extends StaticAbility<ChangelingAbility> {
|
||||
|
||||
private static final ChangelingAbility fINSTANCE = new ChangelingAbility();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
public static ChangelingAbility getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private ChangelingAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Changeling (This card is every creature type at all times.)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangelingAbility copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
}
|
|
@ -37,6 +37,7 @@ import mage.ObjectColor;
|
|||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.keyword.ChangelingAbility;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -169,8 +170,10 @@ public class FilterObject<E extends MageObject, T extends FilterObject<E, T>> ex
|
|||
}
|
||||
|
||||
if (subtype.size() > 0) {
|
||||
if (!compString.compare(subtype, object.getSubtype(), scopeSubtype, notSubtype))
|
||||
return notFilter;
|
||||
if (!object.getAbilities().contains(ChangelingAbility.getInstance())) {
|
||||
if (!compString.compare(subtype, object.getSubtype(), scopeSubtype, notSubtype))
|
||||
return notFilter;
|
||||
}
|
||||
}
|
||||
|
||||
if (supertype.size() > 0) {
|
||||
|
|
|
@ -119,6 +119,11 @@ public class Emblem implements CommandObject {
|
|||
return emptyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubtype(String subtype) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return emptyList;
|
||||
|
|
|
@ -206,6 +206,11 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
return card.getSubtype();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubtype(String subtype) {
|
||||
return card.hasSubtype(subtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return card.getSupertype();
|
||||
|
|
|
@ -119,6 +119,11 @@ public class StackAbility implements StackObject, Ability {
|
|||
return emptyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubtype(String subtype) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return emptyList;
|
||||
|
|
Loading…
Reference in a new issue