add Steal Artifact (from original base Alpha)

This commit is contained in:
jendave
2011-08-06 13:17:40 +00:00
parent 8216d8f88d
commit 4d2bfbd2dd
3 changed files with 164 additions and 0 deletions

1
.gitattributes vendored
View File

@@ -4528,6 +4528,7 @@ res/cardsfolder/staunch_defenders.txt -text svneol=native#text/plain
res/cardsfolder/steadfast_guard.txt -text svneol=native#text/plain
res/cardsfolder/steadfastness.txt -text svneol=native#text/plain
res/cardsfolder/steady_progress.txt -text svneol=native#text/plain
res/cardsfolder/steal_artifact.txt -text svneol=native#text/plain
res/cardsfolder/steam_blast.txt -text svneol=native#text/plain
res/cardsfolder/steam_frigate.txt -text svneol=native#text/plain
res/cardsfolder/steam_spitter.txt -text svneol=native#text/plain

View File

@@ -0,0 +1,9 @@
Name:Steal Artifact
ManaCost:2 U U
Types:Enchantment Aura
Text:You control enchanted artifact.
K:Enchant artifact
K:enControlArtifact
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/steal_artifact.jpg
End

View File

@@ -34,6 +34,16 @@ class CardFactory_Auras {
return -1;
}
private static int shouldControlArtifact(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++) {
if (a.get(i).toString().startsWith("enControlArtifact")) return i;
//if(a.get(i).toString().startsWith("enControlLand")) return i;
}
return -1;
}
public static Card getCard(final Card card, String cardName, Player owner) {
Command standardUnenchant = new Command() {
@@ -2413,6 +2423,150 @@ class CardFactory_Auras {
}// SpellAbility spell
}// enControlCreature
/*
* For Control Magic type of auras (targeting Land, Artifact, Enchantment)
*/
if (shouldControlArtifact(card) != -1) {
int n = shouldControlArtifact(card);
if (n != -1) {
String parse = card.getKeyword().get(n).toString();
card.removeIntrinsicKeyword(parse);
/*
* I borrowed this code from Control Magic aura code
*/
final SpellAbility spell = new Spell(card) {
@Override
public boolean canPlayAI() {
if(!super.canPlayAI()) return false;
CardList tgts = CardFactoryUtil.AI_getHumanArtifact(card, true);
CardListUtil.sortAttack(tgts);
CardListUtil.sortFlying(tgts);
if (tgts.isEmpty()) return false;
else {
setTargetCard(tgts.get(0));
return true;
}
}//canPlayAI()
@Override
public void resolve() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
play.add(card);
Card c = getTargetCard();
if (AllZone.GameAction.isCardInPlay(c)
&& CardFactoryUtil.canTarget(card, c)) card.enchantCard(c);
}//resolve()
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);
Command onEnchant = new Command() {
public void execute() {
if(card.isEnchanting()) {
Card crd = card.getEnchanting().get(0);
//set summoning sickness
if(crd.getKeyword().contains("Haste")) {
crd.setSickness(false);
} else {
crd.setSickness(true);
}
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
PlayerZone from = AllZone.getZone(crd);
from.remove(crd);
crd.setController(card.getController());
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
to.add(crd);
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
}
}//execute()
};//Command
Command onUnEnchant = new Command() {
public void execute() {
if(card.isEnchanting()) {
Card crd = card.getEnchanting().get(0);
if(AllZone.GameAction.isCardInPlay(crd)) {
if(crd.getKeyword().contains("Haste")) {
crd.setSickness(false);
} else {
crd.setSickness(true);
}
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
PlayerZone from = AllZone.getZone(crd);
from.remove(crd);
AllZone.Combat.removeFromCombat(crd);
Player opp = crd.getController().getOpponent();
crd.setController(opp);
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, opp);
to.add(crd);
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
}
}
}//execute()
};//Command
Command onLeavesPlay = new Command() {
public void execute() {
if(card.isEnchanting()) {
Card crd = card.getEnchanting().get(0);
card.unEnchantCard(crd);
}
}
};//Command
Input runtime = new Input() {
@Override
public void showMessage() {
CardList perms = AllZoneUtil.getCardsInPlay();
perms = perms.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.isArtifact() && CardFactoryUtil.canTarget(card, c);
}
});
stopSetNext(CardFactoryUtil.input_targetSpecific(spell, perms, "Select target artifact", true, false));
}
};
card.setSVar("PlayMain1", "TRUE");
card.addEnchantCommand(onEnchant);
card.addUnEnchantCommand(onUnEnchant);
card.addLeavesPlayCommand(onLeavesPlay);
spell.setBeforePayMana(runtime);
}// SpellAbility spell
}// enControlCreature
return card;
}